2018-07-03 4:20 GMT+02:00 Marcos Paulo de Souza <marcos.souza.org(a)gmail.com>:
This macro avoids code duplication when checking for arrays of
objects.
Signed-off-by: Marcos Paulo de Souza <marcos.souza.org(a)gmail.com>
---
src/esx/esx_vi.c | 189 ++++++++++++-----------------------------------
1 file changed, 46 insertions(+), 143 deletions(-)
diff --git a/src/esx/esx_vi.c b/src/esx/esx_vi.c
index 25fbdc7e44..212300dbff 100644
--- a/src/esx/esx_vi.c
+++ b/src/esx/esx_vi.c
@@ -41,6 +41,16 @@
VIR_LOG_INIT("esx.esx_vi");
+#define esxVI_checkArgList(val) \
+ do { \
+ if (!val || *val) { \
+ virReportError(VIR_ERR_INVALID_ARG, "%s", _("Invalid
argument")); \
+ return -1; \
+ } \
+ } while (0)
As this is a macro I suggest naming it ESX_VI_CHECK_ARG_LIST instead
of esxVI_checkArgList. Because at the moment the ESX code makes a
clear distinction between macros and functions in their spelling. I'd
like to keep it that way, even if the rest of the code base is no
consistent about this.
--
Matthias Bolte
http://photron.blogspot.com