On 03/06/2017 01:54 PM, Max Reitz wrote:
> Add missing error messages for the drivers I am comfortable to do this
> in.
> 
> Signed-off-by: Max Reitz <mre...@redhat.com>
> ---
>  block/file-posix.c | 8 +++++++-
>  block/qcow2.c      | 2 ++
>  block/qed.c        | 4 +++-
>  block/raw-format.c | 2 ++
>  4 files changed, 14 insertions(+), 2 deletions(-)
> 
> diff --git a/block/file-posix.c b/block/file-posix.c
> index 9d2bea730d..553213221c 100644
> --- a/block/file-posix.c
> +++ b/block/file-posix.c
> @@ -1341,20 +1341,26 @@ static int raw_truncate(BlockDriverState *bs, int64_t 
> offset, Error **errp)
>  {
>      BDRVRawState *s = bs->opaque;
>      struct stat st;
> +    int ret;
>  
>      if (fstat(s->fd, &st)) {
> -        return -errno;
> +        ret = -errno;
> +        error_setg_errno(errp, -ret, "Failed to fstat() the file");
> +        return ret;
>      }
>  
>      if (S_ISREG(st.st_mode)) {
>          if (ftruncate(s->fd, offset) < 0) {
> +            /* The generic error message will be fine */
>              return -errno;

Relying on a generic error message in the caller is awkward. I see it as
evidence of a partial conversion if we have an interface that requires a
return of a negative errno value to make up for when errp is not set.  I
know you aren't comfortable converting all drivers, but for the drivers
you do convert, I'd rather guarantee that ALL errors set errp.

-- 
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