[libvirt PATCH 13/19] util: cgroup: wrap BACKEND_CALL macro in a block

Ján Tomko jtomko at redhat.com
Mon Aug 3 16:56:50 UTC 2020


VIR_CGROUP_BACKEND_CALL is exclusively used at the end
of a function, but it declares a variable.

Wrap it in a do..while block.

Signed-off-by: Ján Tomko <jtomko at redhat.com>
---
 src/util/vircgroupbackend.h | 26 ++++++++++++++------------
 1 file changed, 14 insertions(+), 12 deletions(-)

diff --git a/src/util/vircgroupbackend.h b/src/util/vircgroupbackend.h
index e12a2e8b9d..bcbe435d78 100644
--- a/src/util/vircgroupbackend.h
+++ b/src/util/vircgroupbackend.h
@@ -452,15 +452,17 @@ virCgroupBackendForController(virCgroupPtr group,
                               unsigned int controller);
 
 #define VIR_CGROUP_BACKEND_CALL(group, controller, func, ret, ...) \
-    virCgroupBackendPtr backend = virCgroupBackendForController(group, controller); \
-    if (!backend) { \
-        virReportError(VIR_ERR_INTERNAL_ERROR, \
-                       _("failed to get cgroup backend for '%s'"), #func); \
-        return ret; \
-    } \
-    if (!backend->func) { \
-        virReportError(VIR_ERR_OPERATION_UNSUPPORTED, \
-                       _("operation '%s' not supported"), #func); \
-        return ret; \
-    } \
-    return backend->func(group, ##__VA_ARGS__);
+    do { \
+        virCgroupBackendPtr backend = virCgroupBackendForController(group, controller); \
+        if (!backend) { \
+            virReportError(VIR_ERR_INTERNAL_ERROR, \
+                           _("failed to get cgroup backend for '%s'"), #func); \
+            return ret; \
+        } \
+        if (!backend->func) { \
+            virReportError(VIR_ERR_OPERATION_UNSUPPORTED, \
+                           _("operation '%s' not supported"), #func); \
+            return ret; \
+        } \
+        return backend->func(group, ##__VA_ARGS__); \
+    } while (0)
-- 
2.26.2




More information about the libvir-list mailing list