Skip to contentSkip to conversation

cpufreq: fix sign check of an unsigned variable in cpufreq-cpu0

PATCH In review Guennadi Liakhovetski 3 participants 3 messages Feb 25, 2013 CPU frequency scaling framework

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 cpufreq: fix sign check of an unsigned variable in cpufreq-cpu0

A "< 0" test for an unsigned variable is meaningless, change the variable to signed.

---

stable?

 drivers/cpufreq/cpufreq-cpu0.c |    3 ++-
 1 files changed, 2 insertions(+), 1 deletions(-)
drivers/cpufreq/cpufreq-cpu0.c +2 -1
index 52bf36d..e7bad3c 100644
@@ -44,7 +44,8 @@ static int cpu0_set_target(struct cpufreq_policy *policy,
 {
 	struct cpufreq_freqs freqs;
 	struct opp *opp;
-	unsigned long freq_Hz, volt = 0, volt_old = 0, tol = 0;
+	unsigned long volt = 0, volt_old = 0, tol = 0;
+	long freq_Hz;
 	unsigned int index, cpu;
 	int ret;
 
Signature · 1 line
1.7.2.5
maintainer Acked-by on v1 1/1
#1 lore raw
Quoted 16 lines · Guennadi Liakhovetski

A "< 0" test for an unsigned variable is meaningless, change the variable to signed.

---

stable?

 drivers/cpufreq/cpufreq-cpu0.c |    3 ++-
 1 files changed, 2 insertions(+), 1 deletions(-)
drivers/cpufreq/cpufreq-cpu0.c +0 -0
index 52bf36d..e7bad3c 100644

drivers/cpufreq/cpufreq-cpu0.c static int cpu0_set_target(struct cpufreq_policy *policy, · line 48

Quoted 6 lines
drivers/cpufreq/cpufreq-cpu0.c +2 -1
@@ -44,7 +44,8 @@ static int cpu0_set_target(struct cpufreq_policy *policy,
 {
        struct cpufreq_freqs freqs;
        struct opp *opp;
-       unsigned long freq_Hz, volt = 0, volt_old = 0, tol = 0;
+       unsigned long volt = 0, volt_old = 0, tol = 0;
+       long freq_Hz;

The disease is spread across a bigger region though.

@Mike: clk_round_rate returns long and __clk_round_rate returns unsigned long and clk_ops->round_rate returns long again.. Don't you see something strange here?

#2 lore raw

Quoting Viresh Kumar (2013-02-25 04:09:47)

Quoted 27 lines
Quoted 16 lines · Guennadi Liakhovetski

A "< 0" test for an unsigned variable is meaningless, change the variable to signed.

---

stable?

 drivers/cpufreq/cpufreq-cpu0.c |    3 ++-
 1 files changed, 2 insertions(+), 1 deletions(-)
drivers/cpufreq/cpufreq-cpu0.c +0 -0
index 52bf36d..e7bad3c 100644

drivers/cpufreq/cpufreq-cpu0.c static int cpu0_set_target(struct cpufreq_policy *policy, · line 48

Quoted 6 lines
drivers/cpufreq/cpufreq-cpu0.c +2 -1
@@ -44,7 +44,8 @@ static int cpu0_set_target(struct cpufreq_policy *policy,
 {
        struct cpufreq_freqs freqs;
        struct opp *opp;
-       unsigned long freq_Hz, volt = 0, volt_old = 0, tol = 0;
+       unsigned long volt = 0, volt_old = 0, tol = 0;
+       long freq_Hz;
Quoted 5 lines

The disease is spread across a bigger region though.

@Mike: clk_round_rate returns long and __clk_round_rate returns unsigned long and clk_ops->round_rate returns long again.. Don't you see something strange here?

Yes, this is in my todo list. I have a branch with some relevant changes but I haven't posted it yet.

Regards,
Mike