kernel-janitors.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Fengguang Wu <fengguang.wu@intel.com>
To: kernel-janitors@vger.kernel.org
Subject: [next:akpm 16/51] drivers/thermal/cpu_cooling.c:461:6-17: ERROR: iterator variable bound on line 460
Date: Fri, 03 Aug 2012 11:30:18 +0000	[thread overview]
Message-ID: <20120803113018.GA18316@localhost> (raw)

[-- 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++;
 	}

                 reply	other threads:[~2012-08-03 11:30 UTC|newest]

Thread overview: [no followups] expand[flat|nested]  mbox.gz  Atom feed

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=20120803113018.GA18316@localhost \
    --to=fengguang.wu@intel.com \
    --cc=kernel-janitors@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;
as well as URLs for NNTP newsgroup(s).