On Tue, Jul 03, 2018 at 11:31:36AM +0200, Michal Prívozník wrote:
On 07/03/2018 04:20 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(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")); \
Actually, this is one of the few places where VIR_ERR_INTERNAL_ERROR is
not misused and makes sense. The only way how this error can be reported
is if there's a bug in our code, not because of some input user made.
There are also other occurrences of this pattern. coccinelle helped to
find other. I used the following spatch:
@@
identifier ptr;
@@
- (!ptr || *ptr)
+ (esxVI_checkArgList(ptr))
Mind putting them here too? Otherwise the patch looks good.
No problem. I will take a look into coccinele and resend the patch once all
other places are covered. Thanks for pushing the other patches and fixing the
code style.
Michal
--
Thanks,
Marcos