[Libguestfs] [libnbd PATCH] maint: Drop useless casts

Richard W.M. Jones rjones at redhat.com
Wed May 24 19:18:32 UTC 2023


On Wed, May 24, 2023 at 10:00:03AM -0500, Eric Blake wrote:
> diff --git a/copy/main.c b/copy/main.c
> index 391c0c4f..9449440e 100644
> --- a/copy/main.c
> +++ b/copy/main.c
> @@ -371,7 +371,7 @@ main (int argc, char *argv[])
>  #else
>      t = 1;
>  #endif
> -    threads = (unsigned)t;
> +    threads = t;

This one doesn't give any warning about truncating from long (64 bits)
to unsigned (32 bits)?

> diff --git a/fuse/nbdfuse.c b/fuse/nbdfuse.c
> index 491f6db8..35d5ffac 100644
> --- a/fuse/nbdfuse.c
> +++ b/fuse/nbdfuse.c
> @@ -415,7 +415,7 @@ main (int argc, char *argv[])
>        handles_append (&nbd, h); /* reserved above, so can't fail */
>      }
>    }
> -  connections = (unsigned)nbd.len;
> +  connections = nbd.len;

Similarly this would be size_t -> unsigned, also a truncation on 64 bit.

But if there are no warnings, then:

Reviewed-by: Richard W.M. Jones <rjones at redhat.com>

Rich.

-- 
Richard Jones, Virtualization Group, Red Hat http://people.redhat.com/~rjones
Read my programming and virtualization blog: http://rwmj.wordpress.com
libguestfs lets you edit virtual machines.  Supports shell scripting,
bindings from many languages.  http://libguestfs.org


More information about the Libguestfs mailing list