All of lore.kernel.org
 help / color / mirror / Atom feed
From: Thomas Gleixner <tglx@linutronix.de>
To: Rasmus Villemoes <rasmus.villemoes@prevas.dk>
Cc: Kees Cook <keescook@chromium.org>, linux-kernel@vger.kernel.org
Subject: Re: [PATCH] genirq: Make - vs ?: precedence explicit
Date: Tue, 28 Nov 2017 14:43:51 +0100 (CET)	[thread overview]
Message-ID: <alpine.DEB.2.20.1711281442060.1723@nanos> (raw)
In-Reply-To: <a3b338a1-95c5-1e7e-9b5c-d924a760078e@prevas.dk>

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

      reply	other threads:[~2017-11-28 13:43 UTC|newest]

Thread overview: 4+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2017-11-22 20:56 Kees Cook
2017-11-23 19:13 ` [tip:irq/urgent] genirq/matrix: Make - vs ?: Precedence explicit tip-bot for Kees Cook
2017-11-28 12:19 ` [PATCH] genirq: Make - vs ?: precedence explicit Rasmus Villemoes
2017-11-28 13:43   ` Thomas Gleixner [this message]

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=alpine.DEB.2.20.1711281442060.1723@nanos \
    --to=tglx@linutronix.de \
    --cc=keescook@chromium.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=rasmus.villemoes@prevas.dk \
    --subject='Re: [PATCH] genirq: Make - vs ?: precedence explicit' \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.