lkml.org 
[lkml]   [2011]   [Feb]   [25]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
 
Messages in this thread
/
From
Date
SubjectRe: [GIT PULL] Regulator fixes for 2.6.38
On Fri, Feb 25, 2011 at 1:33 PM, Liam Girdwood <lrg@slimlogic.co.uk> wrote:
>
> Jesper Juhl (1):
> regulator, mc13xxx: Remove pointless test for unsigned less than zero

So I absolutely detest patches like this.

It's not AT ALL pointless to write

BUG_ON(x < 0 || x > XYZ);

because tests like that make it obvious that there are no sign issues,
without anybody ever having to worry about the sign. So it makes the
code more readable, and the intention more obvious. There is no
downside.

If it's an unsigned variable, the compiler can optimize away the test
against zero. In fact, it can do so even if it's signed (assuming XYZ
is a positive compile-time constant integer) and turn it into an
unsigned comparison.

So I did the pull, but I want to raise my objection to patches like
this. They are doubly wrong during the late -rc stage, but they are
wrong even otherwise.

If you have a compiler that warns about the test, you have a compiler
that is pure and utter shit. It's that simple.

Linus


\
 
 \ /
  Last update: 2011-02-25 23:13    [W:0.038 / U:0.136 seconds]
©2003-2020 Jasper Spaans|hosted at Digital Ocean and TransIP|Read the blog|Advertise on this site