lkml.org 
[lkml]   [2017]   [Nov]   [28]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
 
Messages in this thread
/
Date
From
SubjectRe: [PATCH] genirq: Make - vs ?: precedence explicit
On Tue, 28 Nov 2017, Rasmus Villemoes wrote:
> On 2017-11-22 21:56, Kees Cook wrote:
> > Noticed with a Clang build. This improves the readability of the ?:
> > expression, as it has lower precedence than the - expression. Show
> > explicitly that - is evaluated first.
> >
> > Cc: Thomas Gleixner <tglx@linutronix.de>
> > Signed-off-by: Kees Cook <keescook@chromium.org>
> > ---
> > kernel/irq/matrix.c | 2 +-
> > 1 file changed, 1 insertion(+), 1 deletion(-)
> >
> > diff --git a/kernel/irq/matrix.c b/kernel/irq/matrix.c
> > index a3cbbc8191c5..7df2480005f8 100644
> > --- a/kernel/irq/matrix.c
> > +++ b/kernel/irq/matrix.c
> > @@ -384,7 +384,7 @@ unsigned int irq_matrix_available(struct irq_matrix *m, bool cpudown)
> > {
> > struct cpumap *cm = this_cpu_ptr(m->maps);
> >
> > - return m->global_available - cpudown ? cm->available : 0;
> > + return (m->global_available - cpudown) ? cm->available : 0;
> > }
>
> I see that this got applied, and that doesn't change the semantics of
> the code. But surely the code is and was buggy, right? From the kernel
> doc, I'm pretty sure the idea is to subtract cm->available if cpudown is
> true, otherwise subtract 0, i.e.
>
> return m->global_available - (cpudown ? cm->available : 0);

Yes, you are right. I completely misread it when I merged that patch. Good
catch!

Thanks,

tglx

\
 
 \ /
  Last update: 2017-11-28 14:44    [W:0.522 / U:0.028 seconds]
©2003-2020 Jasper Spaans|hosted at Digital Ocean and TransIP|Read the blog|Advertise on this site