From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from eggs.gnu.org ([2001:4830:134:3::10]:34079) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1WBbq7-0005Wm-0m for qemu-devel@nongnu.org; Thu, 06 Feb 2014 22:10:55 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1WBbq2-0000aA-DA for qemu-devel@nongnu.org; Thu, 06 Feb 2014 22:10:50 -0500 Received: from mx1.redhat.com ([209.132.183.28]:9139) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1WBbq2-0000a6-4o for qemu-devel@nongnu.org; Thu, 06 Feb 2014 22:10:46 -0500 Message-ID: <52F44EB1.8010306@redhat.com> Date: Thu, 06 Feb 2014 20:10:41 -0700 From: Eric Blake MIME-Version: 1.0 References: <1391697000-5855-1-git-send-email-armbru@redhat.com> <1391697000-5855-11-git-send-email-armbru@redhat.com> In-Reply-To: <1391697000-5855-11-git-send-email-armbru@redhat.com> Content-Type: multipart/signed; micalg=pgp-sha256; protocol="application/pgp-signature"; boundary="qXuTcqnQfrLMjIawCfXFtAc52QfsT2GHH" Subject: Re: [Qemu-devel] [PATCH 10/10] qapi: Clean up null checking in generated visitors List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: Markus Armbruster , qemu-devel@nongnu.org Cc: kwolf@redhat.com, mdroth@linux.vnet.ibm.com, aliguori@amazon.com This is an OpenPGP/MIME signed message (RFC 4880 and 3156) --qXuTcqnQfrLMjIawCfXFtAc52QfsT2GHH Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: quoted-printable 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: >=20 > visit_start_optional(m, obj ? &(*obj)->has_name : NULL, "name", &er= r); >=20 > 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 =3D false; return; } *present =3D true; } Shorter would be: *present =3D !!siv->string; } but that doesn't affect this patch] >=20 > I fail to see how hits pointer could legitimately be null. >=20 > All this useless null checking is highly redundant, which Coverity > duly reports. About 200 times. >=20 > Remove the useless null checks. >=20 > Signed-off-by: Markus Armbruster > --- > scripts/qapi-visit.py | 14 +++++++------- > 1 file changed, 7 insertions(+), 7 deletions(-) Reviewed-by: Eric Blake --=20 Eric Blake eblake redhat com +1-919-301-3266 Libvirt virtualization library http://libvirt.org --qXuTcqnQfrLMjIawCfXFtAc52QfsT2GHH Content-Type: application/pgp-signature; name="signature.asc" Content-Description: OpenPGP digital signature Content-Disposition: attachment; filename="signature.asc" -----BEGIN PGP SIGNATURE----- Version: GnuPG v1 Comment: Public key at http://people.redhat.com/eblake/eblake.gpg Comment: Using GnuPG with Thunderbird - http://www.enigmail.net/ iQEcBAEBCAAGBQJS9E6xAAoJEKeha0olJ0NqnT8H/Rs55nKR3o04FWlW7DyhWpFF N/lJ4DdiVYnu93Ec/ZyWLo8pckwDLunbJcXtNSPnauZQtxg13VzKF5LIXC0CAGhU hl99POU8/ZZKe76njzL3SlKrvUC/C7c/AFXA5DT6U+9chb4gSz4aYMXq7h3GrBIG 0Bi20IJTVDNRHliqfjwpJYOwQDrb+G8Bu0vLu9YRcEUPwjm/vFQSaCzfPQrWanJH ZGNOABEeLHabECQmDbbeZrUBFPaq+EaQKpFT731acA7mGF2HQoUczYv6O2xYrO2A /A1DmJTb92gVmxgj4PLpoSDH6yzfW/+A/1C2rvaLMN8HN64O/llDpu+HiwCEhgM= =xUxc -----END PGP SIGNATURE----- --qXuTcqnQfrLMjIawCfXFtAc52QfsT2GHH--