Received: from eggs.gnu.org ([2001:4830:134:3::10]:39423) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1buR7y-0003E6-IT for qemu-devel@nongnu.org; Wed, 12 Oct 2016 17:31:55 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1buR7w-0004EH-G0 for qemu-devel@nongnu.org; Wed, 12 Oct 2016 17:31:53 -0400 References: <20161012204907.25941-1-mreitz@redhat.com> <20161012204907.25941-2-mreitz@redhat.com> From: Eric Blake Message-ID: <1667e429-c342-1ff0-95cf-d3f4bd95c9ea@redhat.com> Date: Wed, 12 Oct 2016 16:31:44 -0500 MIME-Version: 1.0 In-Reply-To: <20161012204907.25941-2-mreitz@redhat.com> Content-Type: multipart/signed; micalg=pgp-sha256; protocol="application/pgp-signature"; boundary="S5tLWq3dWaAxnOqLIqUMIqhvOUpXxNWkC" Subject: Re: [Qemu-devel] [PATCH 1/3] block: Fix bdrv_iterate_format() sorting List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: Max Reitz , qemu-block@nongnu.org Cc: Kevin Wolf , Hao QingFeng , qemu-devel@nongnu.org, Stefan Hajnoczi This is an OpenPGP/MIME signed message (RFC 4880 and 3156) --S5tLWq3dWaAxnOqLIqUMIqhvOUpXxNWkC From: Eric Blake To: Max Reitz , qemu-block@nongnu.org Cc: Kevin Wolf , Hao QingFeng , qemu-devel@nongnu.org, Stefan Hajnoczi Message-ID: <1667e429-c342-1ff0-95cf-d3f4bd95c9ea@redhat.com> Subject: Re: [Qemu-devel] [PATCH 1/3] block: Fix bdrv_iterate_format() sorting References: <20161012204907.25941-1-mreitz@redhat.com> <20161012204907.25941-2-mreitz@redhat.com> In-Reply-To: <20161012204907.25941-2-mreitz@redhat.com> Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: quoted-printable On 10/12/2016 03:49 PM, Max Reitz wrote: > bdrv_iterate_format() did not actually sort the formats by name but by > "pointer interpreted as string". That is probably not what we intended > to do, so fix it (by changing qsort_strcmp() so it matches the example > from qsort()'s manual page). >=20 > Signed-off-by: Max Reitz > --- > block.c | 2 +- > 1 file changed, 1 insertion(+), 1 deletion(-) I'm a bit surprised that code sanitizers like Coverity or ASAN aren't (yet?) able to flag this. Reviewed-by: Eric Blake >=20 > diff --git a/block.c b/block.c > index bb1f1ec..e46e4b2 100644 > --- a/block.c > +++ b/block.c > @@ -2789,7 +2789,7 @@ const char *bdrv_get_format_name(BlockDriverState= *bs) > =20 > static int qsort_strcmp(const void *a, const void *b) > { > - return strcmp(a, b); > + return strcmp(*(char *const *)a, *(char *const *)b); > } > =20 > void bdrv_iterate_format(void (*it)(void *opaque, const char *name), >=20 --=20 Eric Blake eblake redhat com +1-919-301-3266 Libvirt virtualization library http://libvirt.org --S5tLWq3dWaAxnOqLIqUMIqhvOUpXxNWkC Content-Type: application/pgp-signature; name="signature.asc" Content-Description: OpenPGP digital signature Content-Disposition: attachment; filename="signature.asc" -----BEGIN PGP SIGNATURE----- Version: GnuPG v2 Comment: Public key at http://people.redhat.com/eblake/eblake.gpg Comment: Using GnuPG with Thunderbird - http://www.enigmail.net/ iQEcBAEBCAAGBQJX/qvAAAoJEKeha0olJ0Nq9m4IAJw0n7m8rwaJ4S4rj8P4iySE K6CeoTawuLBXyFc6xCWlObIr3eyWoxTfoG2xF5V82ELSE6dfO6iZkoFbvAYO+oGk N+fnrESx0rrx4zkiQESutO+pX0Q4or1oLLAK/VLntTkn18olcmZ1a2rJTS6T0o1F ZQoh5pAGXCg9lx3ifmpM/LG9+2wlp9e9dOWInR50+qHzJBjePF+Qvh5uzEAfWr2V wht/wx6QBL/xImR3UJaWF66IatvN7CcHKUDs07CKPcOjWhmLoxdryd2a55mh7hsh 212dSu4kBO+e5xS173u+cOCnOsfsnRe+Z8m/lInsGG+7nzDJyW8dx2ez01In4Jc= =h7MQ -----END PGP SIGNATURE----- --S5tLWq3dWaAxnOqLIqUMIqhvOUpXxNWkC--