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

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



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@xxxxxxxxx>
> > ---
> >  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

--
libvir-list mailing list
libvir-list@xxxxxxxxxx
https://www.redhat.com/mailman/listinfo/libvir-list




[Index of Archives]     [Virt Tools]     [Libvirt Users]     [Lib OS Info]     [Fedora Users]     [Fedora Desktop]     [Fedora SELinux]     [Big List of Linux Books]     [Yosemite News]     [KDE Users]     [Fedora Tools]

  Powered by Linux