qemu-devel
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [Qemu-devel] [PATCH v2 18/23] vmdk: Clean up "Invalid extent lines"


From: Eric Blake
Subject: Re: [Qemu-devel] [PATCH v2 18/23] vmdk: Clean up "Invalid extent lines" error message
Date: Thu, 17 Dec 2015 14:09:53 -0700
User-agent: Mozilla/5.0 (X11; Linux x86_64; rv:38.0) Gecko/20100101 Thunderbird/38.3.0

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 <address@hidden>
> Signed-off-by: Markus Armbruster <address@hidden>
> ---
>  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 <address@hidden>

-- 
Eric Blake   eblake redhat com    +1-919-301-3266
Libvirt virtualization library http://libvirt.org

Attachment: signature.asc
Description: OpenPGP digital signature


reply via email to

[Prev in Thread] Current Thread [Next in Thread]