From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from eggs.gnu.org ([208.118.235.92]:45835) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1T1IMx-0002qZ-Eh for qemu-devel@nongnu.org; Tue, 14 Aug 2012 10:45:20 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1T1IMu-0007v1-H5 for qemu-devel@nongnu.org; Tue, 14 Aug 2012 10:45:19 -0400 Received: from mx1.redhat.com ([209.132.183.28]:9868) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1T1IMu-0007uQ-5d for qemu-devel@nongnu.org; Tue, 14 Aug 2012 10:45:16 -0400 Message-ID: <502A646F.9050107@redhat.com> Date: Tue, 14 Aug 2012 08:45:03 -0600 From: Eric Blake MIME-Version: 1.0 References: <1344953651-16622-1-git-send-email-benoit@irqsave.net> <1344953651-16622-4-git-send-email-benoit@irqsave.net> In-Reply-To: <1344953651-16622-4-git-send-email-benoit@irqsave.net> Content-Type: multipart/signed; micalg=pgp-sha256; protocol="application/pgp-signature"; boundary="------------enig155296F7A4BD397CC1FDA5FC" Subject: Re: [Qemu-devel] [RFC V3 3/9] quorum: Add quorum_open() and quorum_close(). List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: =?UTF-8?B?QmVub8OudCBDYW5ldA==?= Cc: kwolf@redhat.com, stefanha@linux.vnet.ibm.com, qemu-devel@nongnu.org, blauwirbel@gmail.com, anthony@codemonkey.ws, pbonzini@redhat.com, afaerber@suse.de, =?UTF-8?B?QmVub8OudCBDYW5ldA==?= This is an OpenPGP/MIME signed message (RFC 2440 and 3156) --------------enig155296F7A4BD397CC1FDA5FC Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: quoted-printable On 08/14/2012 08:14 AM, Beno=C3=AEt Canet wrote: > Signed-off-by: Benoit Canet Your commit message is sparse. At least document the syntax expected for opening a quorum file. > --- > block/quorum.c | 113 ++++++++++++++++++++++++++++++++++++++++++++++++= ++++++++ > 1 file changed, 113 insertions(+) >=20 > diff --git a/block/quorum.c b/block/quorum.c > index bab6175..f228428 100644 > --- a/block/quorum.c > +++ b/block/quorum.c > @@ -52,11 +52,124 @@ struct QuorumAIOCB { > int vote_ret; > }; > =20 > +/* Valid quorum filenames look like > + * quorum:n/m:path/to/image_1, ... ,path/to/image_m such as copying this in the commit message. Also, document your escape handling; I had to read it from the code, but it looks like you set up '\' to escape anything, so that '\:' and '\\' are the spellings for a literal backslash or colon in a file name. > + */ > +static int quorum_open(BlockDriverState *bs, const char *filename, int= flags) > +{ > + BDRVQuorumState *s =3D bs->opaque; > + int escape, i, j, len, ret =3D 0; escape only ever holds 0 or 1, so it should be a 'bool' instead. > + /* Get the filenames pointers */ > + escape =3D 0; s/0/false/ > + s->filenames[0] =3D names; > + len =3D strlen(names); > + for (i =3D 0, j =3D 1; i < len && j < s->m; i++) { > + if (!escape && names[i] =3D=3D ':') { > + names[i] =3D '\0'; > + s->filenames[j] =3D names + i + 1; > + j +=3D 1; Isn't this usually written 'j++'? > + } > + > + if (!escape && names[i] =3D=3D '\\') { > + escape =3D 1; s/1/true/ > + } else { > + escape =3D 0; s/0/false/ > + } Or even simplify the 'if' to a one-liner: escape =3D !escape && names[i] =3D=3D '\\'; --=20 Eric Blake eblake@redhat.com +1-919-301-3266 Libvirt virtualization library http://libvirt.org --------------enig155296F7A4BD397CC1FDA5FC 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.4.12 (GNU/Linux) Comment: Public key at http://people.redhat.com/eblake/eblake.gpg Comment: Using GnuPG with Mozilla - http://enigmail.mozdev.org/ iQEcBAEBCAAGBQJQKmRvAAoJEKeha0olJ0Nq81QIAJzTofSQrvxRg5RKDMQ3HGNc agmWZAr91hUNe77lNvh0gBstpmLquF967rW+ytDC7NdxUxBx6FEh55sf3p1cfBta Dvu5APUGAPoxctfsR3IweEj+jkQJeqdSLmP8Eb0/6ia7/2W31x4jBXZ/ZVa+Q11w UE9j4l/WhNg2aXENZWlocifrtl04GQAbNQHBCO9dXOAe53zCSaE9fX2zl9FLh8eh G7i/xJZ1WwkC1h/InzJ5V79WTiYhii7GwUYsndrAT/qycg17W9Xk9EXy1BxhwNfN grPekEMyXo5GfqF49oPksH8pf7TaNLWW039UDzj5iPT4UczVTAXS9qN9eYirKAg= =BjHv -----END PGP SIGNATURE----- --------------enig155296F7A4BD397CC1FDA5FC--