[Libguestfs] [PATCH nbdkit 1/3] common: isaligned: Use uint64_t instead of unsigned int.
Nir Soffer
nsoffer at redhat.com
Mon Sep 17 19:00:30 UTC 2018
On Mon, Sep 17, 2018 at 6:03 PM Richard W.M. Jones <rjones at redhat.com>
wrote:
> This should have no effect. However it's probably better to pass the
> full type explicitly rather than using an implicit truncation.
>
Why is it better?
We care only about the least significant bits; current code is clear about
that.
This is also specified behavior, although the only reference I can find now
is this:
https://docs.microsoft.com/en-us/cpp/c-language/conversions-from-unsigned-integral-types?view=vs-2017
Nir
> ---
> common/include/isaligned.h | 3 ++-
> 1 file changed, 2 insertions(+), 1 deletion(-)
>
> diff --git a/common/include/isaligned.h b/common/include/isaligned.h
> index e693820..9ed635e 100644
> --- a/common/include/isaligned.h
> +++ b/common/include/isaligned.h
> @@ -36,13 +36,14 @@
>
> #include <assert.h>
> #include <stdbool.h>
> +#include <stdint.h>
>
> #include "ispowerof2.h"
>
> /* Return true if size is a multiple of align. align must be power of 2.
> */
> static inline bool
> -is_aligned (unsigned int size, unsigned int align)
> +is_aligned (uint64_t size, unsigned int align)
> {
> assert (is_power_of_2 (align));
> return !(size & (align - 1));
> --
> 2.19.0.rc0
>
> _______________________________________________
> Libguestfs mailing list
> Libguestfs at redhat.com
> https://www.redhat.com/mailman/listinfo/libguestfs
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://listman.redhat.com/archives/libguestfs/attachments/20180917/6bc8cd73/attachment.htm>
More information about the Libguestfs
mailing list