[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: [Qemu-devel] [PATCH 10/10] qapi: Clean up null checking in generated
From: |
Eric Blake |
Subject: |
Re: [Qemu-devel] [PATCH 10/10] qapi: Clean up null checking in generated visitors |
Date: |
Thu, 06 Feb 2014 20:10:41 -0700 |
User-agent: |
Mozilla/5.0 (X11; Linux x86_64; rv:24.0) Gecko/20100101 Thunderbird/24.2.0 |
On 02/06/2014 07:30 AM, Markus Armbruster wrote:
> Visitors get passed a pointer to the visited object. The generated
> visitors try to cope with this pointer being null in some places, for
> instance like this:
>
> visit_start_optional(m, obj ? &(*obj)->has_name : NULL, "name", &err);
>
> visit_start_optional() passes its second argument to Visitor method
> start_optional. Two out of two methods dereference it
> unconditionally.
Let's see if I can find them without Coverity's help...
opts-visitor.c:opts_start_optional
qmp-input-visitor.c:qmp_input_start_optional
string-input-visitor.c:parse_start_optional
Your counting is off :) All three unconditionally dereference.
[While at it, this code style from parse_start_optional, and similar in
other locations, is rather verbose:
if (!siv->string) {
*present = false;
return;
}
*present = true;
}
Shorter would be:
*present = !!siv->string;
}
but that doesn't affect this patch]
>
> I fail to see how hits pointer could legitimately be null.
>
> All this useless null checking is highly redundant, which Coverity
> duly reports. About 200 times.
>
> Remove the useless null checks.
>
> Signed-off-by: Markus Armbruster <address@hidden>
> ---
> scripts/qapi-visit.py | 14 +++++++-------
> 1 file changed, 7 insertions(+), 7 deletions(-)
Reviewed-by: Eric Blake <address@hidden>
--
Eric Blake eblake redhat com +1-919-301-3266
Libvirt virtualization library http://libvirt.org
signature.asc
Description: OpenPGP digital signature
- [Qemu-devel] [PATCH 01/10] tests/qapi-schema: Actually check successful QMP command response, (continued)
- [Qemu-devel] [PATCH 01/10] tests/qapi-schema: Actually check successful QMP command response, Markus Armbruster, 2014/02/06
- [Qemu-devel] [PATCH 03/10] tests/qapi-schema: Cover simple argument types, Markus Armbruster, 2014/02/06
- [Qemu-devel] [PATCH 06/10] tests/qapi-schema: Cover union types with base, Markus Armbruster, 2014/02/06
- [Qemu-devel] [PATCH 05/10] tests/qapi-schema: Cover complex types with base, Markus Armbruster, 2014/02/06
- [Qemu-devel] [PATCH 10/10] qapi: Clean up null checking in generated visitors, Markus Armbruster, 2014/02/06
- Re: [Qemu-devel] [PATCH 10/10] qapi: Clean up null checking in generated visitors,
Eric Blake <=
- Re: [Qemu-devel] [PATCH 10/10] qapi: Clean up null checking in generated visitors, Paolo Bonzini, 2014/02/07
- Re: [Qemu-devel] [PATCH 10/10] qapi: Clean up null checking in generated visitors, Markus Armbruster, 2014/02/07
- Re: [Qemu-devel] [PATCH 10/10] qapi: Clean up null checking in generated visitors, Paolo Bonzini, 2014/02/07
- Re: [Qemu-devel] [PATCH 10/10] qapi: Clean up null checking in generated visitors, Markus Armbruster, 2014/02/10
- Re: [Qemu-devel] [PATCH 10/10] qapi: Clean up null checking in generated visitors, Paolo Bonzini, 2014/02/11
- Re: [Qemu-devel] [PATCH 10/10] qapi: Clean up null checking in generated visitors, Markus Armbruster, 2014/02/11
[Qemu-devel] [PATCH 02/10] tests/qapi-schema: Cover optional command arguments, Markus Armbruster, 2014/02/06
[Qemu-devel] [PATCH 08/10] qapi: Drop nonsensical header guard in generated qapi-visit.c, Markus Armbruster, 2014/02/06