]> git.ipfire.org Git - thirdparty/libvirt.git/commitdiff
virNetworkObjNew: Remove impossible error handling
authorPeter Krempa <pkrempa@redhat.com>
Fri, 23 Jul 2021 08:46:40 +0000 (10:46 +0200)
committerPeter Krempa <pkrempa@redhat.com>
Mon, 26 Jul 2021 11:27:30 +0000 (13:27 +0200)
'obj->classIdMap' is a bitmap with size of '16', thus the first 3 bits
are guaranteed to be available. Use 'virBitmapSetBit' instead of
'virBitmapSetBitExpand' since we don't need any expansion and ignore
errors as they are impossible.

Signed-off-by: Peter Krempa <pkrempa@redhat.com>
Reviewed-by: Tim Wiederhake <twiederh@redhat.com>
src/conf/virnetworkobj.c

index ea021892c7ca793f11112904609d20813bf36742..2a2d94dc9877340bbc476ec3d9a86e0ac8c273ee 100644 (file)
@@ -112,21 +112,16 @@ virNetworkObjNew(void)
 
     obj->classIdMap = virBitmapNew(INIT_CLASS_ID_BITMAP_SIZE);
 
-    /* The first three class IDs are already taken */
-    if (virBitmapSetBitExpand(obj->classIdMap, 0) < 0 ||
-        virBitmapSetBitExpand(obj->classIdMap, 1) < 0 ||
-        virBitmapSetBitExpand(obj->classIdMap, 2) < 0)
-        goto error;
+    /* The first three class IDs are already taken. */
+    ignore_value(virBitmapSetBit(obj->classIdMap, 0));
+    ignore_value(virBitmapSetBit(obj->classIdMap, 1));
+    ignore_value(virBitmapSetBit(obj->classIdMap, 2));
 
     obj->ports = virHashNew(virNetworkObjPortFree);
 
     virObjectLock(obj);
 
     return obj;
-
- error:
-    virObjectUnref(obj);
-    return NULL;
 }