From: Julia Lawall <julia@diku.dk>
To: Greg Kroah-Hartman <gregkh@suse.de>
Cc: kernel-janitors@vger.kernel.org, devel@driverdev.osuosl.org,
linux-kernel@vger.kernel.org
Subject: [PATCH 6/8] drivers/staging/comedi/drivers: Fix unsigned return type
Date: Sun, 05 Sep 2010 19:00:24 +0000 [thread overview]
Message-ID: <1283713226-8429-7-git-send-email-julia@diku.dk> (raw)
In-Reply-To: <1283713226-8429-1-git-send-email-julia@diku.dk>
In each case, the function has an unsigned return type, but returns a
negative constant to indicate an error condition. For move_block_from_dma,
there is only one call and the return value is dropped, so it need not be
unsigned. For labpc_eeprom_write, there is only one call and the result is
stored in a signed variable, so again the unsigned return type is not
necessary.
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/staging/comedi/drivers/adl_pci9118.c | 2 +-
drivers/staging/comedi/drivers/ni_labpc.c | 6 +++---
2 files changed, 4 insertions(+), 4 deletions(-)
diff --git a/drivers/staging/comedi/drivers/adl_pci9118.c b/drivers/staging/comedi/drivers/adl_pci9118.c
index a2bd4e6..cb2843d 100644
--- a/drivers/staging/comedi/drivers/adl_pci9118.c
+++ b/drivers/staging/comedi/drivers/adl_pci9118.c
@@ -634,7 +634,7 @@ static unsigned int defragment_dma_buffer(struct comedi_device *dev,
/*
=======================================
*/
-static unsigned int move_block_from_dma(struct comedi_device *dev,
+static int move_block_from_dma(struct comedi_device *dev,
struct comedi_subdevice *s,
short *dma_buffer,
unsigned int num_samples)
diff --git a/drivers/staging/comedi/drivers/ni_labpc.c b/drivers/staging/comedi/drivers/ni_labpc.c
index 3acf7e6..19f79e8 100644
--- a/drivers/staging/comedi/drivers/ni_labpc.c
+++ b/drivers/staging/comedi/drivers/ni_labpc.c
@@ -250,7 +250,7 @@ static unsigned int labpc_serial_in(struct comedi_device *dev);
static unsigned int labpc_eeprom_read(struct comedi_device *dev,
unsigned int address);
static unsigned int labpc_eeprom_read_status(struct comedi_device *dev);
-static unsigned int labpc_eeprom_write(struct comedi_device *dev,
+static int labpc_eeprom_write(struct comedi_device *dev,
unsigned int address,
unsigned int value);
static void write_caldac(struct comedi_device *dev, unsigned int channel,
@@ -1986,8 +1986,8 @@ static unsigned int labpc_eeprom_read(struct comedi_device *dev,
return value;
}
-static unsigned int labpc_eeprom_write(struct comedi_device *dev,
- unsigned int address, unsigned int value)
+static int labpc_eeprom_write(struct comedi_device *dev,
+ unsigned int address, unsigned int value)
{
const int write_enable_instruction = 0x6;
const int write_instruction = 0x2;
next prev parent reply other threads:[~2010-09-05 19:00 UTC|newest]
Thread overview: 11+ messages / expand[flat|nested] mbox.gz Atom feed top
2010-09-05 18:59 [PATCH 0/8] Fix unsigned return type Julia Lawall
2010-09-05 19:00 ` [PATCH 1/8] drivers/video/matrox/matroxfb_maven.c: " Julia Lawall
2010-09-05 19:00 ` [PATCH 2/8] arch/x86/kernel/cpu/cpufreq: " Julia Lawall
2010-09-05 19:00 ` [PATCH 3/8] net/9p/trans_fd.c: " Julia Lawall
2010-09-07 1:39 ` David Miller
2010-09-05 19:00 ` [PATCH 4/8] drivers/i2c/busses/i2c-pasemi.c: " Julia Lawall
2010-09-06 16:30 ` [PATCH 4/8] drivers/i2c/busses/i2c-pasemi.c: Fix unsigned Olof Johansson
2010-09-05 19:00 ` [PATCH 5/8] drivers/atm/firestream.c: Fix unsigned return type Julia Lawall
2010-09-07 1:40 ` David Miller
2010-09-05 19:00 ` Julia Lawall [this message]
2010-09-05 19:00 ` [PATCH 8/8] drivers/net/wireless/iwlwifi/iwl-agn.c: Fix return value from an unsigned function Julia Lawall
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=1283713226-8429-7-git-send-email-julia@diku.dk \
--to=julia@diku.dk \
--cc=devel@driverdev.osuosl.org \
--cc=gregkh@suse.de \
--cc=kernel-janitors@vger.kernel.org \
--cc=linux-kernel@vger.kernel.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox