[PATCH 9/9] domain_conf: rewrite variable setting to ternary operator
Kristina Hanicova
khanicov at redhat.com
Wed Jul 20 14:12:21 UTC 2022
On Wed, Jul 20, 2022 at 3:41 PM Peter Krempa <pkrempa at redhat.com> wrote:
> On Wed, Jul 20, 2022 at 15:11:12 +0200, Kristina Hanicova wrote:
> > Signed-off-by: Kristina Hanicova <khanicov at redhat.com>
> > ---
> > src/conf/domain_conf.c | 8 ++------
> > 1 file changed, 2 insertions(+), 6 deletions(-)
> >
> > diff --git a/src/conf/domain_conf.c b/src/conf/domain_conf.c
> > index e52f39c809..b600bfec31 100644
> > --- a/src/conf/domain_conf.c
> > +++ b/src/conf/domain_conf.c
> > @@ -4206,12 +4206,8 @@ virDomainObjGetOneDefState(virDomainObj *vm,
> > if (virDomainObjUpdateModificationImpact(vm, &flags) < 0)
> > return NULL;
> >
> > - if (live) {
> > - if (flags & VIR_DOMAIN_AFFECT_LIVE)
> > - *live = true;
> > - else
> > - *live = false;
> > - }
> > + if (live)
> > + *live = (flags & VIR_DOMAIN_AFFECT_LIVE) ? true : false;
> >
>
> https://libvirt.org/coding-style.html#conditional-expressions
>
> We suggest that new code avoids ternary operators.
>
> I'd prefer if this patch is dropped.
>
>
I think that it is reasonably used in this case and makes the code much
more readable. Also its simple enough, no nesting or spanning more lines....
Kristina
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://listman.redhat.com/archives/libvir-list/attachments/20220720/3e53e22a/attachment.htm>
More information about the libvir-list
mailing list