[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: [Qemu-trivial] [Qemu-devel] [PATCH] replace functions which are only
Re: [Qemu-trivial] [Qemu-devel] [PATCH] replace functions which are only available in glib-2.24
Tue, 15 May 2018 15:38:53 +0200
Mozilla/5.0 (X11; Linux x86_64; rv:52.0) Gecko/20100101 Thunderbird/52.7.0
On 15.05.2018 10:41, Paolo Bonzini wrote:
> On 15/05/2018 09:42, Markus Armbruster wrote:
>> Olaf Hering <address@hidden> writes:
>>> Currently the minimal supported version of glib is 2.22.
>>> Since testing is done with a glib that claims to be 2.22, but in fact
>>> has APIs from newer version of glib, this bug was not caught during
>>> submit of the patch referenced below.
>>> Replace g_realloc_n, which is available only since 2.24, with g_renew.
>> We're about to bump our required GLib version to 2.34. See
>> Message-ID: <address@hidden>
>> However, the patch may make sense for stable anyway.
> It's a good idea even for non-stable. In the end, g_*alloc*_n are
> rarely needed, and almost always g_*new* is better as it provides better
> type safety. I'm queuing the patch, and we should consider adding a
> checkpatch rule to suggest not using these functions.
Please do not queue this version of the patch - Olaf sent a v2 where he
fixed the obvious bug with "IOVAMapping *" vs. "IOVAMapping".
>>> Fixes commit 418026ca43 ("util: Introduce vfio helpers")
>>> Signed-off-by: Olaf Hering <address@hidden>
>>> This must go into stable-2.12.
>> Please see docs/devel/stable-process.rst for how to get a patch into a
>> stable release.
>>> util/vfio-helpers.c | 6 ++----
>>> 1 file changed, 2 insertions(+), 4 deletions(-)
>>> diff --git a/util/vfio-helpers.c b/util/vfio-helpers.c
>>> index 006674c916..5fd4f5f212 100644
>>> --- a/util/vfio-helpers.c
>>> +++ b/util/vfio-helpers.c
>>> @@ -522,8 +522,7 @@ static IOVAMapping *qemu_vfio_add_mapping(QEMUVFIOState
>>> assert(index >= 0);
>>> - s->mappings = g_realloc_n(s->mappings, sizeof(s->mappings),
>>> - s->nr_mappings);
>>> + s->mappings = g_renew(IOVAMapping *, s->mappings, s->nr_mappings);
>> I'm afraid this switches from allocating a bunch of IOVAMapping to a
>> bunch of IOVAMapping *. My gcc duly warns.
See v2 of the patch where Olaf fixed this already.