From mboxrd@z Thu Jan 1 00:00:00 1970 From: Matt Fleming Subject: Re: [PATCHv3 1/5] efi/runtime-wrappers: detect FW irq flag corruption Date: Mon, 25 Apr 2016 15:24:35 +0100 Message-ID: <20160425142435.GB2829@codeblueprint.co.uk> References: <1461591994-14918-1-git-send-email-mark.rutland@arm.com> <1461591994-14918-2-git-send-email-mark.rutland@arm.com> <571E25B1.8070305@arm.com> <20160425141557.GA2829@codeblueprint.co.uk> Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii Return-path: Content-Disposition: inline In-Reply-To: Sender: linux-efi-owner-u79uwXL29TY76Z2rM5mHXA@public.gmane.org To: Ard Biesheuvel Cc: Robin Murphy , Mark Rutland , "linux-efi-u79uwXL29TY76Z2rM5mHXA@public.gmane.org" , Russell King - ARM Linux , Catalin Marinas , Will Deacon , "linux-kernel-u79uwXL29TY76Z2rM5mHXA@public.gmane.org" , Leif Lindholm , "mingo-H+wXaHxf7aLQT0dZR+AlfA@public.gmane.org" , "hpa-YMNOUZJC4hwAvxtiuMwx3w@public.gmane.org" , "tglx-hfZtesqFncYOwBW4kG4KsQ@public.gmane.org" , "linux-arm-kernel-IAPFreCvJWM7uuMidbF8XUB+6BGkLq7r@public.gmane.org" List-Id: linux-efi@vger.kernel.org On Mon, 25 Apr, at 04:18:41PM, Ard Biesheuvel wrote: > On 25 April 2016 at 16:15, Matt Fleming wrote: > > On Mon, 25 Apr, at 03:12:01PM, Robin Murphy wrote: > >> >+static void efi_call_virt_check_flags(unsigned long flags, const char *call) > >> >+{ > >> >+ unsigned long cur_flags; > >> >+ bool mismatch; > >> >+ > >> >+ local_save_flags(cur_flags); > >> >+ > >> >+ mismatch = !!((cur_flags ^ flags) & ARCH_EFI_IRQ_FLAGS_MASK); > >> > >> nit: the assignment itself is already a conversion to bool, so the > >> excitement is redundant here. > > > > This was intentional. I asked Mark to make this change so that it's > > explicit for the developer that we're performing the type conversion. > > But replacing an implicit boolean cast with an explicit one makes > little sense, no? Don't we simply want '!= 0' here if you need a > boolean expression? Aha but '!!' is fewer characters to type!! I'm not that bothered as long as we don't stuff an int into a bool without giving the programmer some idea we're doing that. It's not about the compiler getting it wrong, more about a developer introducing a bug when they change the code in the future. Unless anyone objects, I'll fix this up to use '!= 0' when I apply it.