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

Re: [Xen-devel] [PATCH 07 of 18] tools/blktap2: fix build errors caused by Werror in tdqcow_get_parent_id



Olaf Hering writes ("[Xen-devel] [PATCH 07 of 18] tools/blktap2: fix build 
errors caused by Werror in tdqcow_get_parent_id"):
> tools/blktap2: fix build errors caused by Werror in tdqcow_get_parent_id
> 
> -O2 -Wall -Werror triggers these warnings:
> 
> block-qcow.c: In function 'tdqcow_get_parent_id':
> block-qcow.c:1457:17: warning: 'type' may be used uninitialized in this 
> function [-Wuninitialized]
> 
> The compiler can not know that open() writes to errno so it has to
> assume that errno can be zero.

Yes.

> Since tdqcow_get_image_type() has just
> one caller which expects a bool as return type, adjust return codes so
> that the compiler knows when 'type' is initialised.

I don't think this is a step in the right direction.  In a better
world the caller would report the errno value.  Throwing the errno
value away is not an improvement.

> Signed-off-by: Olaf Hering <olaf@xxxxxxxxx>
> 
> diff -r 51c773447549 -r 16f6fc42abaa tools/blktap2/drivers/block-qcow.c
> --- a/tools/blktap2/drivers/block-qcow.c
> +++ b/tools/blktap2/drivers/block-qcow.c
> @@ -1408,12 +1408,12 @@ tdqcow_get_image_type(const char *file, 
>  
>       fd = open(file, O_RDONLY);
>       if (fd == -1)
> -             return -errno;
> +             return -1;

This can be fixed here by adding
   assert(errno);

>       size = read(fd, &header, sizeof(header));
>       close(fd);
>       if (size != sizeof(header))
> -             return (errno ? -errno : -EIO);
> +             return -1;

And this seems not to have a problem; surely just leaving it unchanged
is sufficient ?

Ian.

_______________________________________________
Xen-devel mailing list
Xen-devel@xxxxxxxxxxxxx
http://lists.xen.org/xen-devel


 


Rackspace

Lists.xenproject.org is hosted with RackSpace, monitoring our
servers 24x7x365 and backed by RackSpace's Fanatical Support®.