[RFC REPOST 1/7] conf: extract appid validation to virDomainDefResourceAppidValidate

Pavel Hrdina phrdina at redhat.com
Fri Sep 10 13:21:22 UTC 2021


On Fri, Sep 10, 2021 at 01:49:24PM +0200, Michal Prívozník wrote:
> On 9/9/21 6:13 PM, Pavel Hrdina wrote:
> > This will be needed by future patches adding appid API to allow changing
> > it for running VMs.
> > 
> > Signed-off-by: Pavel Hrdina <phrdina at redhat.com>
> > ---
> >  src/conf/domain_validate.c | 42 +++++++++++++++++++++++---------------
> >  src/conf/domain_validate.h |  2 ++
> >  src/libvirt_private.syms   |  1 +
> >  3 files changed, 28 insertions(+), 17 deletions(-)
> > 
> > diff --git a/src/conf/domain_validate.c b/src/conf/domain_validate.c
> > index 1bc62c364d..3ab864bbeb 100644
> > --- a/src/conf/domain_validate.c
> > +++ b/src/conf/domain_validate.c
> 
> 
> > +    if (def->resource->appid)
> > +        return virDomainDefResourceAppidValidate(def->resource->appid);
> >  
> 
> I'd write this as:
> 
>   if (def->resource->appid &&
>       virDomainDefResourceAppidValidate() < 0)
>       return -1;
> 
> so that this line doesn't have to be changed when something new is added
> to this function. Moreover, you can have
> virDomainDefResourceAppidValidate() to be NOP if appid == NULL and write
> this check as:
> 
>   if (virDomainDefResourceAppidValidate() < 0)
>     return -1;

True, I'll fix that. Thanks.

Pavel
-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 833 bytes
Desc: not available
URL: <http://listman.redhat.com/archives/libvir-list/attachments/20210910/417f52a1/attachment-0001.sig>


More information about the libvir-list mailing list