* [PATCH 4/8] drivers/i2c/busses/i2c-pasemi.c: Fix unsigned return type
[not found] <1283713226-8429-1-git-send-email-julia@diku.dk>
@ 2010-09-05 19:00 ` Julia Lawall
2010-09-06 16:30 ` Olof Johansson
0 siblings, 1 reply; 2+ messages in thread
From: Julia Lawall @ 2010-09-05 19:00 UTC (permalink / raw)
To: Olof Johansson
Cc: kernel-janitors, linux-kernel, linux-i2c,
Ben Dooks (embedded platforms), Jean Delvare (PC drivers, core),
linuxppc-dev
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 <julia@diku.dk>
---
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;
^ permalink raw reply related [flat|nested] 2+ messages in thread
* Re: [PATCH 4/8] drivers/i2c/busses/i2c-pasemi.c: Fix unsigned return type
2010-09-05 19:00 ` [PATCH 4/8] drivers/i2c/busses/i2c-pasemi.c: Fix unsigned return type Julia Lawall
@ 2010-09-06 16:30 ` Olof Johansson
0 siblings, 0 replies; 2+ messages in thread
From: Olof Johansson @ 2010-09-06 16:30 UTC (permalink / raw)
To: Julia Lawall
Cc: kernel-janitors, linux-kernel, linux-i2c,
Ben Dooks (embedded platforms), Jean Delvare (PC drivers, core),
linuxppc-dev
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 <julia@diku.dk>
Acked-by: Olof Johansson <olof@lixom.net>
^ permalink raw reply [flat|nested] 2+ messages in thread
end of thread, other threads:[~2010-09-06 16:30 UTC | newest]
Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
[not found] <1283713226-8429-1-git-send-email-julia@diku.dk>
2010-09-05 19:00 ` [PATCH 4/8] drivers/i2c/busses/i2c-pasemi.c: Fix unsigned return type Julia Lawall
2010-09-06 16:30 ` Olof Johansson
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).