[PATCH 1/6] virBitmapNewCopy: Reimplement bitmap copying to prevent failure

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

 



virBitmapCopy has a failure condition, which is impossible to meet when
creating a new copy. Copy the contents directly to make it obvious that
virBitmapNewCopy can't fail.

Signed-off-by: Peter Krempa <pkrempa@xxxxxxxxxx>
---
 src/util/virbitmap.c | 10 ++--------
 1 file changed, 2 insertions(+), 8 deletions(-)

diff --git a/src/util/virbitmap.c b/src/util/virbitmap.c
index 74d1883d94..c62438a3a6 100644
--- a/src/util/virbitmap.c
+++ b/src/util/virbitmap.c
@@ -655,20 +655,14 @@ virBitmapParseUnlimited(const char *str)
  * virBitmapNewCopy:
  * @src: the source bitmap.
  *
- * Makes a copy of bitmap @src.
- *
- * returns the copied bitmap on success, or NULL otherwise. Caller
- * should call virBitmapFree to free the returned bitmap.
+ * Returns a copy of bitmap @src.
  */
 virBitmapPtr
 virBitmapNewCopy(virBitmapPtr src)
 {
     virBitmapPtr dst = virBitmapNew(src->nbits);

-    if (virBitmapCopy(dst, src) != 0) {
-        virBitmapFree(dst);
-        return NULL;
-    }
+    memcpy(dst->map, src->map, src->map_len * sizeof(src->map[0]));

     return dst;
 }
-- 
2.26.2




[Index of Archives]     [Virt Tools]     [Libvirt Users]     [Lib OS Info]     [Fedora Users]     [Fedora Desktop]     [Fedora SELinux]     [Big List of Linux Books]     [Yosemite News]     [KDE Users]     [Fedora Tools]

  Powered by Linux