From mboxrd@z Thu Jan 1 00:00:00 1970 From: Ricardo Neri Subject: Re: [PATCH v4 01/17] x86/mpx: Do not use SIB index if index points to R/ESP Date: Thu, 23 Feb 2017 18:41:44 -0800 Message-ID: <1487904104.115017.6.camel@ranerica-desktop> References: <20170223063706.71554-1-ricardo.neri-calderon@linux.intel.com> <20170223063706.71554-2-ricardo.neri-calderon@linux.intel.com> <20170223072432.GX6515@twins.programming.kicks-ass.net> <1487888232.115017.4.camel@ranerica-desktop> <1487903602.14159.50.camel@perches.com> Mime-Version: 1.0 Content-Transfer-Encoding: 7bit Return-path: In-Reply-To: <1487903602.14159.50.camel@perches.com> Sender: linux-msdos-owner@vger.kernel.org List-ID: Content-Type: text/plain; charset="us-ascii" To: Joe Perches Cc: Peter Zijlstra , Ingo Molnar , Thomas Gleixner , "H. Peter Anvin" , Andy Lutomirski , Borislav Petkov , Andrew Morton , Brian Gerst , Chris Metcalf , Dave Hansen , Paolo Bonzini , Liang Z Li , Masami Hiramatsu , Huang Rui , Jiri Slaby , Jonathan Corbet , "Michael S. Tsirkin" , Paul Gortmaker , Vlastimil Babka , Chen Yucong , Alexandre Julliard <> On Thu, 2017-02-23 at 18:33 -0800, Joe Perches wrote: > On Thu, 2017-02-23 at 14:17 -0800, Ricardo Neri wrote: > > On Thu, 2017-02-23 at 08:24 +0100, Peter Zijlstra wrote: > > > On Wed, Feb 22, 2017 at 10:36:50PM -0800, Ricardo Neri wrote: > > > > + /* > > > > + * A negative offset generally means a error, except > > > > + * -EDOM, which means that the contents of the register > > > > + * should not be used as index. > > > > + */ > > > > if (indx_offset < 0) > > > > - goto out_err; > > > > + if (indx_offset == -EDOM) > > > > + indx = 0; > > > > + else > > > > + goto out_err; > > > > + else > > > > + indx = regs_get_register(regs, indx_offset); > > > > > > Kernel coding style requires more brackets than are strictly required by > > > C, any block longer than 1 line needs then. Also, if one leg of a > > > conditional needs them, then they should be on both legs. > > > > > > Your code has many such instances, please change them all. > > > > Will do. Sorry for the noise. These instances escaped the checkpatch > > script. > > Also, this code would read better with the inner test > reversed or done first > > if (indx_offset < 0) { > if (indx_offset != -EDOM) > goto out_err; > indx = 0; > } else { > indx = regs_get_register(etc...) > } > > or > if (indx_offset == -EDOM) > indx = 0; > else if (indx_offset < 0) > goto err; > else > indx = regs_get_register(etc...) > > The compiler should generate the same code in any > case, but either could improve reader understanding. I agree! I will change it with your clever solution. Thanks and BR, Ricardo