From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from eggs.gnu.org ([2001:4830:134:3::10]:52656) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1a9foE-0004EJ-Ts for qemu-devel@nongnu.org; Thu, 17 Dec 2015 16:09:59 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1a9foA-0008F2-Sy for qemu-devel@nongnu.org; Thu, 17 Dec 2015 16:09:58 -0500 Received: from mx1.redhat.com ([209.132.183.28]:37083) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1a9foA-0008Er-OB for qemu-devel@nongnu.org; Thu, 17 Dec 2015 16:09:54 -0500 Received: from int-mx09.intmail.prod.int.phx2.redhat.com (int-mx09.intmail.prod.int.phx2.redhat.com [10.5.11.22]) by mx1.redhat.com (Postfix) with ESMTPS id 558B1C0B7E19 for ; Thu, 17 Dec 2015 21:09:54 +0000 (UTC) References: <1450371004-26866-1-git-send-email-armbru@redhat.com> <1450371004-26866-19-git-send-email-armbru@redhat.com> From: Eric Blake Message-ID: <567324A1.6080400@redhat.com> Date: Thu, 17 Dec 2015 14:09:53 -0700 MIME-Version: 1.0 In-Reply-To: <1450371004-26866-19-git-send-email-armbru@redhat.com> Content-Type: multipart/signed; micalg=pgp-sha256; protocol="application/pgp-signature"; boundary="vRBx64nUekqgtQ9aAMTXpLtNfXsBxtvTh" Subject: Re: [Qemu-devel] [PATCH v2 18/23] vmdk: Clean up "Invalid extent lines" error message List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: Markus Armbruster , qemu-devel@nongnu.org Cc: Fam Zheng This is an OpenPGP/MIME signed message (RFC 4880 and 3156) --vRBx64nUekqgtQ9aAMTXpLtNfXsBxtvTh Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: quoted-printable On 12/17/2015 09:49 AM, Markus Armbruster wrote: > vmdk_parse_extents() reports parse errors like this: >=20 > error_setg(errp, "Invalid extent lines:\n%s", p); >=20 > where p points to the beginning of the malformed line in the image > descriptor. This results in a multi-line error message >=20 > Invalid extent lines: > > >=20 > Error messages should not have newlines embedded. Since the remaining > text is not helpful, we can simply report: >=20 > Invalid extent line: >=20 > Cc: Fam Zheng > Signed-off-by: Markus Armbruster > --- > block/vmdk.c | 19 ++++++++++++------- > tests/qemu-iotests/059.out | 4 +--- > 2 files changed, 13 insertions(+), 10 deletions(-) >=20 > @@ -883,6 +880,14 @@ static int vmdk_parse_extents(const char *desc, Bl= ockDriverState *bs, > extent->type =3D g_strdup(type); > } > return 0; > + > +invalid: > + np =3D next_line(p); > + assert(np !=3D p); > + if (np[-1] =3D=3D '\n') > + np--; > + error_setg(errp, "Invalid extent line: %.*s", (int)(np - p), p); [Side note: It would be nice if C/POSIX had a way to specify that %.*s will take a ptrdiff_t argument, instead of forcing callers to cast to int. Oh well.] Reviewed-by: Eric Blake --=20 Eric Blake eblake redhat com +1-919-301-3266 Libvirt virtualization library http://libvirt.org --vRBx64nUekqgtQ9aAMTXpLtNfXsBxtvTh 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/ iQEcBAEBCAAGBQJWcyShAAoJEKeha0olJ0NqUy0H/1jZ7xqSecN+/wW030Bq0Ibg rgfWG7jbXCGbcDo4pgsmpT0GTJy6kgC/i4vaNoKVPpYDDcXrghEFd2fg0dg3Btbl VdgXt6priMDEj5HyE0miyWydwFlLHfnpr9GYPfpeGa/TWUIxhlgUIQh7u7xVe7mq DZcsbzpuEfMW76FJmlmSz/jKqADt0oxMw0rEKbn0GkrELA7IFeu6N2n5GJ6w1wUM hdt+iAlxi+qw5WRVblvtc//49zqSrQGlS/c+svpcYY0SptDprGeV4pvnQrR1UgDu co98JmZqCm6YMFbRVkGhxmwbChwGhUtZ7Pd3qrGvkvXgDI8F/x3xs1RZRBg535s= =2vfD -----END PGP SIGNATURE----- --vRBx64nUekqgtQ9aAMTXpLtNfXsBxtvTh--