From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from eggs.gnu.org ([2001:4830:134:3::10]:38765) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1XRjSd-0001p1-Pp for qemu-devel@nongnu.org; Wed, 10 Sep 2014 11:05:36 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1XRjSY-0003Tv-NP for qemu-devel@nongnu.org; Wed, 10 Sep 2014 11:05:31 -0400 Received: from mx1.redhat.com ([209.132.183.28]:6315) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1XRjSY-0003Tp-EC for qemu-devel@nongnu.org; Wed, 10 Sep 2014 11:05:26 -0400 Message-ID: <541068B2.3040103@redhat.com> Date: Wed, 10 Sep 2014 09:05:22 -0600 From: Eric Blake MIME-Version: 1.0 References: <1410336832-22160-1-git-send-email-armbru@redhat.com> <1410336832-22160-2-git-send-email-armbru@redhat.com> <20140910110339.GA10817@irqsave.net> In-Reply-To: <20140910110339.GA10817@irqsave.net> Content-Type: multipart/signed; micalg=pgp-sha256; protocol="application/pgp-signature"; boundary="ToONr8tnw2EepEN6X8h7s3Q9g5oLwFE0Q" Subject: Re: [Qemu-devel] [PATCH 01/23] block: Split bdrv_new_named() off bdrv_new() List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: =?UTF-8?B?QmVub8OudCBDYW5ldA==?= , Markus Armbruster Cc: kwolf@redhat.com, famz@redhat.com, qemu-devel@nongnu.org, stefanha@redhat.com This is an OpenPGP/MIME signed message (RFC 4880 and 3156) --ToONr8tnw2EepEN6X8h7s3Q9g5oLwFE0Q Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: quoted-printable On 09/10/2014 05:03 AM, Beno=C3=AEt Canet wrote: > The Wednesday 10 Sep 2014 =C3=A0 10:13:30 (+0200), Markus Armbruster wr= ote : >> Creating an anonymous BDS can't fail. Make that obvious. >> >> Signed-off-by: Markus Armbruster >> --- >> /* create a new block device (by default it is empty) */ >> -BlockDriverState *bdrv_new(const char *device_name, Error **errp) >> +BlockDriverState *bdrv_new_named(const char *device_name, Error **err= p) >> { >> BlockDriverState *bs; >> - int i; >> + >> + assert(*device_name); >=20 > This assert that device_name is not a null pointer. No, it assumes that device_name is non-NULL and blindly dereferences it; it is asserting that the first byte of the dereferenced pointer is not NU= L. > But here we are pretty sure that the BDS should be named given the name= of the function. > Should we bake an assert on device_name[0] !=3D '\0' to avoid bdrv_new_= named being called > with "" as device_name ? That's already what the code does. About the only thing it could do differently is: assert(device_name && *device_name); --=20 Eric Blake eblake redhat com +1-919-301-3266 Libvirt virtualization library http://libvirt.org --ToONr8tnw2EepEN6X8h7s3Q9g5oLwFE0Q 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 iQEcBAEBCAAGBQJUEGiyAAoJEKeha0olJ0NqhM8H/itBl7kmgDmdzJLqbutp+5Me K+skFbUbZsreD1iro54D3caMMJBuUMXrRVnHCyCPP0q92k/PA+X6fEYmRsg9i52N YKWB8IW5C4LlRXpw6IKQW4DO4v86zquZ9aL6mmvXqKSEQ3Yo2Ny+V9WcTimH0MZ9 nz7ybqYiFZz6T7WnIoPBcD6PYRxrhklP4Sa0RTQYEHGsJnVWAfhgcg3AxJ0umjOn VCzSc85wvxMc4qndJ6YpKdkHVaRE00GFjEfv+imO4gKz+gj7hEYlNi2Qo0ejrgoB aGuidPAa/M79qTZvBmipNkVMIE2WlHMcCsk7K0nSIqVNLjtETjiiZ12RjOh1Uhs= =gSZa -----END PGP SIGNATURE----- --ToONr8tnw2EepEN6X8h7s3Q9g5oLwFE0Q--