[libvirt] [PATCH] maint: Fix incorrect parenthesis placement causing true/false assignment

Pavel Hrdina phrdina at redhat.com
Tue Sep 5 09:46:02 UTC 2017


On Tue, Sep 05, 2017 at 11:02:46AM +0200, Martin Kletzander wrote:
> On Tue, Sep 05, 2017 at 10:17:36AM +0200, Erik Skultety wrote:
> > There were a few places in our code where the following pattern in 'if'
> > condition occurred:
> > 
> > if ((foo = bar() < 0))
> >    do something;
> > 
> > This patch adjusts the conditions to the expected format:
> > 
> > if ((foo = bar()) < 0)
> >    do something;
> > 
> 
> I'd forbid this short ugly notation.  Whoever is lazy to write:
> 
>  ...
>  foo = bar();
>  if (foo < 0)
>  ...
> 
> is free to object until I send this e-mail.
> 
> > Resolves: https://bugzilla.redhat.com/show_bug.cgi?id=1488192
> > 
> > Signed-off-by: Erik Skultety <eskultet at redhat.com>
> > ---
> > 
> > This can be especially "fun" if you try to assign multiple RNG devices to a
> > domain and then try to hot-unplug any of them but the first. Anyhow I used the
> > regex below to find these, I haven't spent much time tuning in, so in case
> > you can come up with a better one that yields more results like these I'm all
> > ears :).
> > 
> > [[:alnum:]_]+ = [[:print:]]+[^)]) < 0))

It would be maybe worth creating a syntax-check rule for it.

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/20170905/c177a446/attachment-0001.sig>


More information about the libvir-list mailing list