All of lore.kernel.org
 help / color / mirror / Atom feed
* [Qemu-devel] [PATCH for-2.8] hbitmap: Fix the serialization granularity's type
@ 2016-11-07 16:39 Max Reitz
  2016-11-08 16:36 ` [Qemu-devel] [Qemu-block] " Stefan Hajnoczi
  0 siblings, 1 reply; 2+ messages in thread
From: Max Reitz @ 2016-11-07 16:39 UTC (permalink / raw)
  To: qemu-block; +Cc: qemu-devel, Max Reitz, Fam Zheng, John Snow

This function returns a uint64_t, so it should not truncate its result
by performing a plain int calculation.

Signed-off-by: Max Reitz <mreitz@redhat.com>
---
 util/hbitmap.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/util/hbitmap.c b/util/hbitmap.c
index 5d1a21c..c57be76 100644
--- a/util/hbitmap.c
+++ b/util/hbitmap.c
@@ -401,7 +401,7 @@ uint64_t hbitmap_serialization_granularity(const HBitmap *hb)
 {
     /* Require at least 64 bit granularity to be safe on both 64 bit and 32 bit
      * hosts. */
-    return 64 << hb->granularity;
+    return UINT64_C(64) << hb->granularity;
 }
 
 /* Start should be aligned to serialization granularity, chunk size should be
-- 
2.10.2

^ permalink raw reply related	[flat|nested] 2+ messages in thread

* Re: [Qemu-devel] [Qemu-block] [PATCH for-2.8] hbitmap: Fix the serialization granularity's type
  2016-11-07 16:39 [Qemu-devel] [PATCH for-2.8] hbitmap: Fix the serialization granularity's type Max Reitz
@ 2016-11-08 16:36 ` Stefan Hajnoczi
  0 siblings, 0 replies; 2+ messages in thread
From: Stefan Hajnoczi @ 2016-11-08 16:36 UTC (permalink / raw)
  To: Max Reitz; +Cc: qemu-block, Fam Zheng, qemu-devel

[-- Attachment #1: Type: text/plain, Size: 847 bytes --]

On Mon, Nov 07, 2016 at 05:39:21PM +0100, Max Reitz wrote:
> This function returns a uint64_t, so it should not truncate its result
> by performing a plain int calculation.
> 
> Signed-off-by: Max Reitz <mreitz@redhat.com>
> ---
>  util/hbitmap.c | 2 +-
>  1 file changed, 1 insertion(+), 1 deletion(-)
> 
> diff --git a/util/hbitmap.c b/util/hbitmap.c
> index 5d1a21c..c57be76 100644
> --- a/util/hbitmap.c
> +++ b/util/hbitmap.c
> @@ -401,7 +401,7 @@ uint64_t hbitmap_serialization_granularity(const HBitmap *hb)
>  {
>      /* Require at least 64 bit granularity to be safe on both 64 bit and 32 bit
>       * hosts. */
> -    return 64 << hb->granularity;
> +    return UINT64_C(64) << hb->granularity;
>  }

Another instance that should be fixed:

  uint64_t start = QEMU_ALIGN_UP(num_elements, 1 << hb->granularity);

[-- Attachment #2: signature.asc --]
[-- Type: application/pgp-signature, Size: 455 bytes --]

^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2016-11-08 16:36 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2016-11-07 16:39 [Qemu-devel] [PATCH for-2.8] hbitmap: Fix the serialization granularity's type Max Reitz
2016-11-08 16:36 ` [Qemu-devel] [Qemu-block] " Stefan Hajnoczi

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.