qemu-devel
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [PATCH 5/8] util/compatfd.c: Replaced a malloc with GLib's variant


From: Thomas Huth
Subject: Re: [PATCH 5/8] util/compatfd.c: Replaced a malloc with GLib's variant
Date: Mon, 15 Mar 2021 08:29:38 +0100
User-agent: Mozilla/5.0 (X11; Linux x86_64; rv:78.0) Gecko/20100101 Thunderbird/78.8.0

On 15/03/2021 07.43, Mahmoud Mandour wrote:
    If it's unrelated, then maybe better do it in a separate patch.


I thought so but I didn't know whether it was a so-small change
that it didn't require its own patch or not. I will amend that.

    Since this is only a very small allocation, I think it would be better to
    use g_malloc() here and then simply remove the "if (info == NULL) ..." part.


I was thinking of always maintaining the semantics of the existing
code and since g_malloc() does not behave like malloc() on
error, I refrained from using g_malloc() anywhere, but of course
I'll do it since it's the better thing to do.

Keeping the semantics is normally a good idea, but the common sense in the QEMU project is to rather use g_malloc() for small allocations (if allocating some few bytes already fails, then the system is pretty much dead anyway), and only g_try_malloc() for huge allocations that really might fail on a healthy system, too.

We should likely add some text to our coding style document to make this more obvious...

I will split the patches to a two-patch series regarding the
util/compactfd.c file (one for the style change and one for
changing the malloc() call into g_malloc()) and send them
again, is that ok?

Sounds good, thanks!

 Thomas





reply via email to

[Prev in Thread] Current Thread [Next in Thread]