]> git.kernelconcepts.de Git - karo-tx-linux.git/commit
drivers/rtc/rtc-spear.c: fix several error checks
authorLars-Peter Clausen <lars@metafoo.de>
Fri, 28 Sep 2012 00:20:34 +0000 (10:20 +1000)
committerStephen Rothwell <sfr@canb.auug.org.au>
Thu, 4 Oct 2012 05:03:54 +0000 (15:03 +1000)
commite228036f044c170c0d60c3fd37617593d75cba74
treecf36e971b3323771675fd1babbe1f70ab3defef6
parenta3497ad75b07544740dc5dd9778e9b39420d9293
drivers/rtc/rtc-spear.c: fix several error checks

There are several comparisons of a unsigned int to less than zero int
spear RTC driver.  Such a check will always be true.  In all these cases a
signed int is assigned to the unsigned variable, which is checked, before.
 So the right fix is to make the checked variable signed as well.  In one
case the check can be dropped completely, because all it does it returns
'err' if 'err' is less than zero, otherwise it returns 0.  Since in this
particular case 'err' is always either 0 or less this is the same as just
returning 'err'.

The issue has been found using the following coccinelle semantic patch:

//<smpl>
@@
type T;
unsigned T i;
@@
(
*i < 0
|
*i >= 0
)
//</smpl>

Signed-off-by: Lars-Peter Clausen <lars@metafoo.de>
Cc: Viresh Kumar <viresh.kumar@st.com>
Cc: Alessandro Zummo <a.zummo@towertech.it>
Signed-off-by: Andrew Morton <akpm@linux-foundation.org>
drivers/rtc/rtc-spear.c