lkml.org 
[lkml]   [2017]   [Apr]   [27]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
 
Messages in this thread
/
Date
From
SubjectRe: xen_exit_mmap() questions

* Boris Ostrovsky <boris.ostrovsky@oracle.com> wrote:

> > xen_mc_issue() does:
> >
> > if ((paravirt_get_lazy_mode() & mode) == 0)
> > xen_mc_flush();
> >
> > I assume the load_cr3() is intended to deal with the case where we're
> > in lazy mode, but we'll still be in lazy mode, right? Or does it
> > serve some other purpose?
>
> Of course. I can't read (I ignored the "== 0" part).

Ha, ob'sidenote: the preferred form to write this is:

if (!(paravirt_get_lazy_mode() & mode))
xen_mc_flush();

... exactly due to the readability problem you ran into: a 'pre' negation is much
easier to read, plus '==' tends to trigger 'equal to' attributes in the brain,
which is the opposite of negation. So it's very easy to mis-read such syntactic
constructs even if they are technically correct.

I think '== 0' should be forbidden in all cases where the purpose is a logic
operation and should be used strictly only in cases where we do explicit integer
arithmetics.

(Bools and '== false' are suboptimal for similar reasons.)

... but I digress!

Ingo

\
 
 \ /
  Last update: 2017-04-27 08:27    [W:0.059 / U:0.380 seconds]
©2003-2020 Jasper Spaans|hosted at Digital Ocean and TransIP|Read the blog|Advertise on this site