[PATCH 4/8] drivers/i2c/busses/i2c-pasemi.c: Fix unsigned return type

Subsystems: i2c subsystem, i2c subsystem host drivers, linux for powerpc (32-bit and 64-bit), the rest

STALE5846d

2 messages, 2 authors, 2010-09-06 · open the first message on its own page

[PATCH 4/8] drivers/i2c/busses/i2c-pasemi.c: Fix unsigned return type

From: Julia Lawall <hidden>
Date: 2010-09-05 19:00:33

The function has an unsigned return type, but returns a negative constant
to indicate an error condition.  The result of calling the function is
always stored in a variable of type (signed) int, and thus unsigned can be
dropped from the return type.

A sematic match that finds this problem is as follows:
(http://coccinelle.lip6.fr/)

// <smpl>
@exists@
identifier f;
constant C;
@@

 unsigned f(...)
 { <+...
*  return -C;
 ...+> }
// </smpl>

Signed-off-by: Julia Lawall <redacted>

---
 drivers/i2c/busses/i2c-pasemi.c |    2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/drivers/i2c/busses/i2c-pasemi.c b/drivers/i2c/busses/i2c-pasemi.c
index 4174101..837b8c1 100644
--- a/drivers/i2c/busses/i2c-pasemi.c
+++ b/drivers/i2c/busses/i2c-pasemi.c
@@ -88,7 +88,7 @@ static void pasemi_smb_clear(struct pasemi_smbus *smbus)
 	reg_write(smbus, REG_SMSTA, status);
 }
 
-static unsigned int pasemi_smb_waitready(struct pasemi_smbus *smbus)
+static int pasemi_smb_waitready(struct pasemi_smbus *smbus)
 {
 	int timeout = 10;
 	unsigned int status;

Re: [PATCH 4/8] drivers/i2c/busses/i2c-pasemi.c: Fix unsigned return type

From: Olof Johansson <hidden>
Date: 2010-09-06 16:30:51

On Sun, Sep 05, 2010 at 09:00:22PM +0200, Julia Lawall wrote:
The function has an unsigned return type, but returns a negative constant
to indicate an error condition.  The result of calling the function is
always stored in a variable of type (signed) int, and thus unsigned can be
dropped from the return type.

A sematic match that finds this problem is as follows:
(http://coccinelle.lip6.fr/)

// <smpl>
@exists@
identifier f;
constant C;
@@

 unsigned f(...)
 { <+...
*  return -C;
 ...+> }
// </smpl>

Signed-off-by: Julia Lawall <redacted>
Acked-by: Olof Johansson <redacted>
Keyboard shortcuts
hback out one level
jnext message in thread
kprevious message in thread
ldrill in
Escclose help / fold thread tree
?toggle this help