Skip to contentSkip to conversation

pfuze: Fix unsigned variable for less-than-zero comparison

PATCH New Peng Fan 2 participants 4 messages Jan 4, 2016 – Jan 7, 2016

lore
Share & tools
lore

Peng Fan

author
#0 lore raw

PATCH 1/1 pfuze: Fix unsigned variable for less-than-zero comparison

From: "Ye.Li" <[email protected]>

According to the Coverity result, a unsigned int variable is used fo less- than-zero comparison, the result is never true. Need to fix the variable type to signed int.

Cc Przemyslaw Marczak <[email protected]>
Cc Stefano Babic <[email protected]>
---
 board/freescale/common/pfuze.c | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)
board/freescale/common/pfuze.c +2 -1
index 783c46d..69afa83 100644
@@ -13,7 +13,8 @@
 int pfuze_mode_init(struct pmic *p, u32 mode)
 {
 	unsigned char offset, i, switch_num;
-	u32 id, ret;
+	u32 id;
+	int ret;
 
 	pmic_reg_read(p, PFUZE100_DEVICEID, &id);
 	id = id & 0xf;
Signature · 1 line
2.6.2
#1 lore raw

PATCH 1/1 pfuze: Fix unsigned variable for less-than-zero comparison

Hi Peng,

Quoted 2 lines · Peng Fan

From: "Ye.Li" <[email protected]>

it is enough to have Ye in the Signed-off instead of the commit message.

Quoted 18 lines

According to the Coverity result, a unsigned int variable is used fo less- than-zero comparison, the result is never true. Need to fix the variable type to signed int.

Cc Przemyslaw Marczak <[email protected]>
Cc Stefano Babic <[email protected]>
---
 board/freescale/common/pfuze.c | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)
board/freescale/common/pfuze.c +0 -0
index 783c46d..69afa83 100644

board/freescale/common/pfuze.c line 20

Quoted 9 lines
board/freescale/common/pfuze.c +2 -1
@@ -13,7 +13,8 @@
 int pfuze_mode_init(struct pmic *p, u32 mode)
 {
 	unsigned char offset, i, switch_num;
-	u32 id, ret;
+	u32 id;
+	int ret;
 
 	pmic_reg_read(p, PFUZE100_DEVICEID, &id);
 	id = id & 0xf;

Apart of that:

Best regards,
Stefano Babic

Signature · 5 lines
=====================================================================
DENX Software Engineering GmbH,      Managing Director: Wolfgang Denk
HRB 165235 Munich, Office: Kirchenstr.5, D-82194 Groebenzell, Germany
Phone: +49-8142-66989-53 Fax: +49-8142-66989-80 Email: sbabic at denx.de
=====================================================================
author
#2 lore raw

PATCH 1/1 pfuze: Fix unsigned variable for less-than-zero comparison

Hi Stefano,

Quoted 7 lines · Stefano Babic

Hi Peng,

Quoted 2 lines · Peng Fan

From: "Ye.Li" <[email protected]>

it is enough to have Ye in the Signed-off instead of the commit message.

Since author is not me, but patch sent out from me. I think git add that automatically. "git am" will not add this in commit message.

Regards,
Peng.

Quoted 43 lines
Quoted 19 lines

According to the Coverity result, a unsigned int variable is used fo less- than-zero comparison, the result is never true. Need to fix the variable type to signed int.

Cc Przemyslaw Marczak <[email protected]>
Cc Stefano Babic <[email protected]>
---
 board/freescale/common/pfuze.c | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)
board/freescale/common/pfuze.c +0 -0
index 783c46d..69afa83 100644

board/freescale/common/pfuze.c line 20

Quoted 9 lines
board/freescale/common/pfuze.c +2 -1
@@ -13,7 +13,8 @@
 int pfuze_mode_init(struct pmic *p, u32 mode)
 {
 	unsigned char offset, i, switch_num;
-	u32 id, ret;
+	u32 id;
+	int ret;
 
 	pmic_reg_read(p, PFUZE100_DEVICEID, &id);
 	id = id & 0xf;

Apart of that:

Best regards,
Stefano Babic

Signature · 5 lines
=====================================================================
DENX Software Engineering GmbH,      Managing Director: Wolfgang Denk
HRB 165235 Munich, Office: Kirchenstr.5, D-82194 Groebenzell, Germany
Phone: +49-8142-66989-53 Fax: +49-8142-66989-80 Email: sbabic at denx.de
=====================================================================
#3 lore raw

PATCH 1/1 pfuze: Fix unsigned variable for less-than-zero comparison

In reply to Peng Fan
Quoted 20 lines · Peng Fan

From: "Ye.Li" <[email protected]>

According to the Coverity result, a unsigned int variable is used fo less- than-zero comparison, the result is never true. Need to fix the variable type to signed int.

Cc Przemyslaw Marczak <[email protected]>
Cc Stefano Babic <[email protected]>
---
 board/freescale/common/pfuze.c | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)
board/freescale/common/pfuze.c +0 -0
index 783c46d..69afa83 100644

board/freescale/common/pfuze.c line 20

Quoted 9 lines
board/freescale/common/pfuze.c +2 -1
@@ -13,7 +13,8 @@
 int pfuze_mode_init(struct pmic *p, u32 mode)
 {
 	unsigned char offset, i, switch_num;
-	u32 id, ret;
+	u32 id;
+	int ret;
 
 	pmic_reg_read(p, PFUZE100_DEVICEID, &id);
 	id = id & 0xf;

Applied (fix) to u-boot-imx, thanks !

Best regards,
Stefano Babic

Signature · 5 lines
=====================================================================
DENX Software Engineering GmbH,      Managing Director: Wolfgang Denk
HRB 165235 Munich, Office: Kirchenstr.5, D-82194 Groebenzell, Germany
Phone: +49-8142-66989-53 Fax: +49-8142-66989-80 Email: sbabic at denx.de
=====================================================================