kernel-janitors.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [next:akpm 16/51] drivers/thermal/cpu_cooling.c:461:6-17: ERROR: iterator variable bound on line 460
@ 2012-08-03 11:30 Fengguang Wu
  0 siblings, 0 replies; only message in thread
From: Fengguang Wu @ 2012-08-03 11:30 UTC (permalink / raw)
  To: kernel-janitors

[-- Attachment #1: Type: text/plain, Size: 1214 bytes --]

Hi Amit,

There are new coccinelle warnings show up in

tree:   git://git.kernel.org/pub/scm/linux/kernel/git/next/linux-next.git akpm
head:   6a015080d00181e3a650d51e078ea14be82abfc4
commit: 24c8a66b8a75ed71806695fc232fb9499a7f672d [16/51] thermal: add generic cpufreq cooling implementation

All coccinelle warnings:

+ drivers/thermal/cpu_cooling.c:461:6-17: ERROR: iterator variable bound on line 460 cannot be NULL
  drivers/thermal/cpu_cooling.c:323:6-20: ERROR: iterator variable bound on line 322 cannot be NULL
  drivers/thermal/cpu_cooling.c:300:6-20: ERROR: iterator variable bound on line 299 cannot be NULL
  drivers/thermal/cpu_cooling.c:346:6-20: ERROR: iterator variable bound on line 345 cannot be NULL

vim +461 drivers/thermal/cpu_cooling.c
   458	
   459		mutex_lock(&cooling_cpufreq_lock);
   460		list_for_each_entry(cpufreq_dev, &cooling_cpufreq_list, node) {
 > 461			if (cpufreq_dev && cpufreq_dev->cool_dev == cdev)
   462				break;
   463			cpufreq_dev_count++;
   464		}

Please fold the attached patch if you agree with the warnings.

---
0-DAY kernel build testing backend         Open Source Technology Centre
Fengguang Wu <wfg@linux.intel.com>                     Intel Corporation

[-- Attachment #2: itnull:cpu_cooling.patch --]
[-- Type: text/x-diff, Size: 1756 bytes --]

Generated by: iterators/itnull.cocci

 Many iterators have the property that the first argument is always bound
 to a real list element, never NULL.

Semantic patch information:
 False positives arise for some iterators that do not have this property,
 or in cases when the loop cursor is reassigned.  The latter should only
 happen when the matched code is on the way to a loop exit (break, goto,
 or return).

--- a/drivers/thermal/cpu_cooling.c
+++ b/drivers/thermal/cpu_cooling.c
@@ -297,7 +297,7 @@ static int cpufreq_get_max_state(struct
 
 	mutex_lock(&cooling_cpufreq_lock);
 	list_for_each_entry(cpufreq_device, &cooling_cpufreq_list, node) {
-		if (cpufreq_device && cpufreq_device->cool_dev == cdev) {
+		if (cpufreq_device->cool_dev == cdev) {
 			*state = cpufreq_device->tab_size;
 			ret = 0;
 			break;
@@ -320,7 +320,7 @@ static int cpufreq_get_cur_state(struct
 
 	mutex_lock(&cooling_cpufreq_lock);
 	list_for_each_entry(cpufreq_device, &cooling_cpufreq_list, node) {
-		if (cpufreq_device && cpufreq_device->cool_dev == cdev) {
+		if (cpufreq_device->cool_dev == cdev) {
 			*state = cpufreq_device->cpufreq_state;
 			ret = 0;
 			break;
@@ -343,7 +343,7 @@ static int cpufreq_set_cur_state(struct
 
 	mutex_lock(&cooling_cpufreq_lock);
 	list_for_each_entry(cpufreq_device, &cooling_cpufreq_list, node) {
-		if (cpufreq_device && cpufreq_device->cool_dev == cdev) {
+		if (cpufreq_device->cool_dev == cdev) {
 			ret = 0;
 			break;
 		}
@@ -458,7 +458,7 @@ void cpufreq_cooling_unregister(struct t
 
 	mutex_lock(&cooling_cpufreq_lock);
 	list_for_each_entry(cpufreq_dev, &cooling_cpufreq_list, node) {
-		if (cpufreq_dev && cpufreq_dev->cool_dev == cdev)
+		if (cpufreq_dev->cool_dev == cdev)
 			break;
 		cpufreq_dev_count++;
 	}

^ permalink raw reply	[flat|nested] only message in thread

only message in thread, other threads:[~2012-08-03 11:30 UTC | newest]

Thread overview: (only message) (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2012-08-03 11:30 [next:akpm 16/51] drivers/thermal/cpu_cooling.c:461:6-17: ERROR: iterator variable bound on line 460 Fengguang Wu

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).