From: Julia Lawall <julia@diku.dk>
To: Dave Jones <davej@redhat.com>
Cc: kernel-janitors@vger.kernel.org,
Thomas Gleixner <tglx@linutronix.de>,
Ingo Molnar <mingo@redhat.com>, "H. Peter Anvin" <hpa@zytor.com>,
x86@kernel.org, cpufreq@vger.kernel.org,
linux-kernel@vger.kernel.org
Subject: [PATCH 2/8] arch/x86/kernel/cpu/cpufreq: Fix unsigned return type
Date: Sun, 05 Sep 2010 19:00:20 +0000 [thread overview]
Message-ID: <1283713226-8429-3-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. Each function is only
called once. For nforce2_detect_chipset, the result is only compared to 0,
and for longrun_determine_freqs, the result is stored in a variable of type
(signed) int. Thus, for both functions, 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>
---
arch/x86/kernel/cpu/cpufreq/cpufreq-nforce2.c | 2 +-
arch/x86/kernel/cpu/cpufreq/longrun.c | 2 +-
2 files changed, 2 insertions(+), 2 deletions(-)
diff --git a/arch/x86/kernel/cpu/cpufreq/cpufreq-nforce2.c b/arch/x86/kernel/cpu/cpufreq/cpufreq-nforce2.c
index 733093d..141abeb 100644
--- a/arch/x86/kernel/cpu/cpufreq/cpufreq-nforce2.c
+++ b/arch/x86/kernel/cpu/cpufreq/cpufreq-nforce2.c
@@ -393,7 +393,7 @@ static struct cpufreq_driver nforce2_driver = {
* Detects nForce2 A2 and C1 stepping
*
*/
-static unsigned int nforce2_detect_chipset(void)
+static int nforce2_detect_chipset(void)
{
nforce2_dev = pci_get_subsys(PCI_VENDOR_ID_NVIDIA,
PCI_DEVICE_ID_NVIDIA_NFORCE2,
diff --git a/arch/x86/kernel/cpu/cpufreq/longrun.c b/arch/x86/kernel/cpu/cpufreq/longrun.c
index fc09f14..77945bf 100644
--- a/arch/x86/kernel/cpu/cpufreq/longrun.c
+++ b/arch/x86/kernel/cpu/cpufreq/longrun.c
@@ -165,7 +165,7 @@ static unsigned int longrun_get(unsigned int cpu)
* TMTA rules:
* performance_pctg = (target_freq - low_freq)/(high_freq - low_freq)
*/
-static unsigned int __cpuinit longrun_determine_freqs(unsigned int *low_freq,
+static int __cpuinit longrun_determine_freqs(unsigned int *low_freq,
unsigned int *high_freq)
{
u32 msr_lo, msr_hi;
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 ` Julia Lawall [this message]
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 ` [PATCH 6/8] drivers/staging/comedi/drivers: " Julia Lawall
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-3-git-send-email-julia@diku.dk \
--to=julia@diku.dk \
--cc=cpufreq@vger.kernel.org \
--cc=davej@redhat.com \
--cc=hpa@zytor.com \
--cc=kernel-janitors@vger.kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=mingo@redhat.com \
--cc=tglx@linutronix.de \
--cc=x86@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