From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1753997AbdK1MTz (ORCPT ); Tue, 28 Nov 2017 07:19:55 -0500 Received: from mail01.prevas.se ([62.95.78.3]:2416 "EHLO mail01.prevas.se" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1753760AbdK1MTx (ORCPT ); Tue, 28 Nov 2017 07:19:53 -0500 X-IronPort-AV: E=Sophos;i="5.44,468,1505772000"; d="scan'208";a="2880373" Subject: Re: [PATCH] genirq: Make - vs ?: precedence explicit To: Kees Cook , Thomas Gleixner CC: References: <20171122205645.GA27125@beast> From: Rasmus Villemoes Message-ID: Date: Tue, 28 Nov 2017 13:19:50 +0100 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:52.0) Gecko/20100101 Thunderbird/52.1.1 MIME-Version: 1.0 In-Reply-To: <20171122205645.GA27125@beast> Content-Type: text/plain; charset="utf-8" Content-Language: en-US Content-Transfer-Encoding: 7bit X-Originating-IP: [172.16.8.31] Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org 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 > Signed-off-by: Kees Cook > --- > 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); Rasmus