
On 07/04/2018 04:31 AM, Marcos Paulo de Souza wrote:
This macro avoids code duplication when checking for arrays of objects.
Signed-off-by: Marcos Paulo de Souza <marcos.souza.org@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) \
There needs to be a space between # and define (just line in context lines above). There has to be one space for every level of nesting.
+ 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 {
Michal