[libvirt] [PATCH -v2 1/2] esx_util.h: Add ESX_VI_CHECK_ARG_LIST macro

Marcos Paulo de Souza marcos.souza.org at gmail.com
Wed Jul 4 02:31:22 UTC 2018


This macro avoids code duplication when checking for arrays of objects.

Signed-off-by: Marcos Paulo de Souza <marcos.souza.org at gmail.com>
---

 Changes from v1:
 * Change VIR_ERR_INVALID_ARG to VIR_ERR_INTERNAL_ERROR (Michal)
 * Change esxVI_checkArgList to ESX_VI_CHECK_ARG_LIST (Matthias)

 src/esx/esx_util.h | 8 ++++++++
 1 file changed, 8 insertions(+)

diff --git a/src/esx/esx_util.h b/src/esx/esx_util.h
index c6f14bb2d9..63602bf3cb 100644
--- a/src/esx/esx_util.h
+++ b/src/esx/esx_util.h
@@ -26,6 +26,14 @@
 # include "internal.h"
 # include "viruri.h"
 
+#define ESX_VI_CHECK_ARG_LIST(val) \
+    do { \
+        if (!val || *val) { \
+            virReportError(VIR_ERR_INTERNAL_ERROR, "%s", _("Invalid argument")); \
+            return -1; \
+        } \
+    } while (0)
+
 typedef struct _esxUtil_ParsedUri esxUtil_ParsedUri;
 
 struct _esxUtil_ParsedUri {
-- 
2.17.1




More information about the libvir-list mailing list