On 12/17/2015 09:49 AM, Markus Armbruster wrote: > vmdk_parse_extents() reports parse errors like this: > > error_setg(errp, "Invalid extent lines:\n%s", p); > > where p points to the beginning of the malformed line in the image > descriptor. This results in a multi-line error message > > Invalid extent lines: > <first line that doesn't parse> > <remaining text that may or may not parse, if any> > > Error messages should not have newlines embedded. Since the remaining > text is not helpful, we can simply report: > > Invalid extent line: <first line that doesn't parse> > > Cc: Fam Zheng <f...@redhat.com> > Signed-off-by: Markus Armbruster <arm...@redhat.com> > --- > block/vmdk.c | 19 ++++++++++++------- > tests/qemu-iotests/059.out | 4 +--- > 2 files changed, 13 insertions(+), 10 deletions(-) >
> @@ -883,6 +880,14 @@ static int vmdk_parse_extents(const char *desc, > BlockDriverState *bs, > extent->type = g_strdup(type); > } > return 0; > + > +invalid: > + np = next_line(p); > + assert(np != p); > + if (np[-1] == '\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 <ebl...@redhat.com> -- Eric Blake eblake redhat com +1-919-301-3266 Libvirt virtualization library http://libvirt.org
signature.asc
Description: OpenPGP digital signature