[libvirt] [PATCH] Use VIR_DIV_UP macro where possible

Martin Kletzander mkletzan at redhat.com
Wed Sep 23 09:47:06 UTC 2015


Signed-off-by: Martin Kletzander <mkletzan at redhat.com>
---
Will push as trivial in a second.

 src/rpc/virnetclientstream.c | 2 +-
 src/util/virbitmap.c         | 2 +-
 2 files changed, 2 insertions(+), 2 deletions(-)

diff --git a/src/rpc/virnetclientstream.c b/src/rpc/virnetclientstream.c
index 1cc9002b0ad7..64e9cd221be2 100644
--- a/src/rpc/virnetclientstream.c
+++ b/src/rpc/virnetclientstream.c
@@ -279,7 +279,7 @@ int virNetClientStreamQueuePacket(virNetClientStreamPtr st,
         goto end;
     }

-    pieces = (length + size - 1) / size;
+    pieces = VIR_DIV_UP(length, size);
     for (piece = 0; piece < pieces; piece++) {
         if (size > length - offset)
             size = length - offset;
diff --git a/src/util/virbitmap.c b/src/util/virbitmap.c
index 4d270a910c19..57135a09f71e 100644
--- a/src/util/virbitmap.c
+++ b/src/util/virbitmap.c
@@ -71,7 +71,7 @@ virBitmapNewQuiet(size_t size)
     if (SIZE_MAX - VIR_BITMAP_BITS_PER_UNIT < size || size == 0)
         return NULL;

-    sz = (size + VIR_BITMAP_BITS_PER_UNIT - 1) / VIR_BITMAP_BITS_PER_UNIT;
+    sz = VIR_DIV_UP(size, VIR_BITMAP_BITS_PER_UNIT);

     if (VIR_ALLOC_QUIET(bitmap) < 0)
         return NULL;
--
2.5.3




More information about the libvir-list mailing list