public inbox for kernel-janitors@vger.kernel.org
 help / color / mirror / Atom feed
* question about
@ 2010-05-28 11:46 Dan Carpenter
  2010-05-28 13:42 ` Haojian Zhuang
  0 siblings, 1 reply; 2+ messages in thread
From: Dan Carpenter @ 2010-05-28 11:46 UTC (permalink / raw)
  To: kernel-janitors

Hi,

I was going through some Smatch stuff and it complains about something
in drivers/leds/leds-88pm860x.c  Could you take a look at it?  I'm not
sure what was intended there.

drivers/leds/leds-88pm860x.c +228 __check_device(6) warn: unsigned 'p->flags' is never less than zero.
   222  static int __check_device(struct pm860x_led_pdata *pdata, char *name)
   223  {
   224          struct pm860x_led_pdata *p = pdata;
   225          int ret = -EINVAL;
   226
   227          while (p && p->id) {
   228                  if ((p->id != PM8606_ID_LED) || (p->flags < 0))
                                                         ^^^^^^^^^^^^

	p->flags is an unsigned int so this condition is never true.

   229                          break;
   230
   231                  if (!strncmp(name, pm860x_led_name[p->flags],
   232                          MFD_NAME_SIZE)) {
   233                          ret = (int)p->flags;
   234                          break;
   235                  }
   236                  p++;
   237          }
   238          return ret;
   239  }

regards,
dan carpenter

^ permalink raw reply	[flat|nested] 2+ messages in thread

* RE: question about
  2010-05-28 11:46 question about Dan Carpenter
@ 2010-05-28 13:42 ` Haojian Zhuang
  0 siblings, 0 replies; 2+ messages in thread
From: Haojian Zhuang @ 2010-05-28 13:42 UTC (permalink / raw)
  To: kernel-janitors

[-- Attachment #1: Type: text/plain, Size: 1436 bytes --]

Thanks for your good catch. We needn't this checking at here. Now I format this patch.

Best Regards
Haojian

-----Original Message-----
From: Dan Carpenter [mailto:error27@gmail.com] 
Sent: 2010年5月28日 7:46 PM
To: Haojian Zhuang
Cc: kernel-janitors@vger.kernel.org
Subject: question about

Hi,

I was going through some Smatch stuff and it complains about something
in drivers/leds/leds-88pm860x.c  Could you take a look at it?  I'm not
sure what was intended there.

drivers/leds/leds-88pm860x.c +228 __check_device(6) warn: unsigned 'p->flags' is never less than zero.
   222  static int __check_device(struct pm860x_led_pdata *pdata, char *name)
   223  {
   224          struct pm860x_led_pdata *p = pdata;
   225          int ret = -EINVAL;
   226
   227          while (p && p->id) {
   228                  if ((p->id != PM8606_ID_LED) || (p->flags < 0))
                                                         ^^^^^^^^^^^^

	p->flags is an unsigned int so this condition is never true.

   229                          break;
   230
   231                  if (!strncmp(name, pm860x_led_name[p->flags],
   232                          MFD_NAME_SIZE)) {
   233                          ret = (int)p->flags;
   234                          break;
   235                  }
   236                  p++;
   237          }
   238          return ret;
   239  }

regards,
dan carpenter

[-- Attachment #2: 0001-leds-remove-redundant-checking.patch --]
[-- Type: application/octet-stream, Size: 922 bytes --]

From 59b2a1391d531bf06143ad5fc7b86490fead5065 Mon Sep 17 00:00:00 2001
From: Haojian Zhuang <haojian.zhuang@marvell.com>
Date: Fri, 28 May 2010 21:36:47 +0800
Subject: [PATCH] leds: remove redundant checking

flags variable is declared as unsigned. So we needn't to check whether it's
negative value.

Signed-off-by: Haojian Zhuang <haojian.zhuang@marvell.com>
---
 drivers/leds/leds-88pm860x.c |    2 +-
 1 files changed, 1 insertions(+), 1 deletions(-)

diff --git a/drivers/leds/leds-88pm860x.c b/drivers/leds/leds-88pm860x.c
index da146da..5decc1c 100644
--- a/drivers/leds/leds-88pm860x.c
+++ b/drivers/leds/leds-88pm860x.c
@@ -160,7 +160,7 @@ static int __check_device(struct pm860x_led_pdata *pdata, char *name)
 	int ret = -EINVAL;
 
 	while (p && p->id) {
-		if ((p->id != PM8606_ID_LED) || (p->flags < 0))
+		if (p->id != PM8606_ID_LED)
 			break;
 
 		if (!strncmp(name, pm860x_led_name[p->flags],
-- 
1.5.6.5


^ permalink raw reply related	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2010-05-28 13:42 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2010-05-28 11:46 question about Dan Carpenter
2010-05-28 13:42 ` Haojian Zhuang

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox