[libvirt] [PATCH 2/3] esx: Add esxVI_checkArgList macro

Matthias Bolte matthias.bolte at googlemail.com
Tue Jul 3 13:48:59 UTC 2018


2018-07-03 4:20 GMT+02:00 Marcos Paulo de Souza <marcos.souza.org at gmail.com>:
> This macro avoids code duplication when checking for arrays of objects.
>
> Signed-off-by: Marcos Paulo de Souza <marcos.souza.org at 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




More information about the libvir-list mailing list