LKML Archive on lore.kernel.org
help / color / mirror / Atom feed
* [PATCH] cpuset: sparse warnings in cpuset.c
@ 2008-02-03 6:20 Harvey Harrison
2008-02-03 7:28 ` Paul Jackson
0 siblings, 1 reply; 6+ messages in thread
From: Harvey Harrison @ 2008-02-03 6:20 UTC (permalink / raw)
To: Andrew Morton; +Cc: LKML
No need to redeclare p, we have finished with it at this point,
so reuse it in the for loop.
kernel/cpuset.c:824:23: warning: symbol 'p' shadows an earlier one
kernel/cpuset.c:746:21: originally declared here
kernel/cpuset.c:1272:52: warning: Using plain integer as NULL pointer
Signed-off-by: Harvey Harrison <harvey.harrison@gmail.com>
---
kernel/cpuset.c | 5 +++--
1 files changed, 3 insertions(+), 2 deletions(-)
diff --git a/kernel/cpuset.c b/kernel/cpuset.c
index cfaf641..fdbac43 100644
--- a/kernel/cpuset.c
+++ b/kernel/cpuset.c
@@ -821,7 +821,7 @@ static int update_cpumask(struct cpuset *cs, char *buf)
cgroup_iter_end(cgrp, &it);
if (heap.size) {
for (i = 0; i < heap.size; i++) {
- struct task_struct *p = heap.ptrs[i];
+ p = heap.ptrs[i];
if (i == 0) {
latest_time = p->start_time;
latest_task = p;
@@ -1269,7 +1269,8 @@ static ssize_t cpuset_common_file_write(struct cgroup *cont,
return -E2BIG;
/* +1 for nul-terminator */
- if ((buffer = kmalloc(nbytes + 1, GFP_KERNEL)) == 0)
+ buffer = kmalloc(nbytes + 1, GFP_KERNEL);
+ if (!buffer)
return -ENOMEM;
if (copy_from_user(buffer, userbuf, nbytes)) {
--
1.5.4.rc5.1138.g2602
^ permalink raw reply [flat|nested] 6+ messages in thread
* Re: [PATCH] cpuset: sparse warnings in cpuset.c
2008-02-03 6:20 [PATCH] cpuset: sparse warnings in cpuset.c Harvey Harrison
@ 2008-02-03 7:28 ` Paul Jackson
2008-02-03 7:42 ` Harvey Harrison
0 siblings, 1 reply; 6+ messages in thread
From: Paul Jackson @ 2008-02-03 7:28 UTC (permalink / raw)
To: Harvey Harrison; +Cc: akpm, linux-kernel
Harvey wrote:
> No need to redeclare p, we have finished with it at this point,
> so reuse it in the for loop.
Good catch, however I disagree with the fix. It makes the code more
brittle.
It's not a good idea to reuse a variable for some other purpose just
because you "know" the original use is dead. Things don't necessarily
stay dead; code moves around.
Could you prepare a revised version of this patch, that instead of
dropping that declaration of 'p', rather renames it to 'q' ?
Thanks.
--
I won't rest till it's the best ...
Programmer, Linux Scalability
Paul Jackson <pj@sgi.com> 1.940.382.4214
^ permalink raw reply [flat|nested] 6+ messages in thread
* Re: [PATCH] cpuset: sparse warnings in cpuset.c
2008-02-03 7:28 ` Paul Jackson
@ 2008-02-03 7:42 ` Harvey Harrison
2008-02-03 7:57 ` Paul Jackson
2008-02-23 8:04 ` Andrew Morton
0 siblings, 2 replies; 6+ messages in thread
From: Harvey Harrison @ 2008-02-03 7:42 UTC (permalink / raw)
To: Paul Jackson; +Cc: akpm, linux-kernel
Don't redeclare p, use a new variable q.
kernel/cpuset.c:824:23: warning: symbol 'p' shadows an earlier one
kernel/cpuset.c:746:21: originally declared here
kernel/cpuset.c:1272:52: warning: Using plain integer as NULL pointer
Signed-off-by: Harvey Harrison <harvey.harrison@gmail.com>
---
Paul, used a variable q instead as per your request.
kernel/cpuset.c | 13 +++++++------
1 files changed, 7 insertions(+), 6 deletions(-)
diff --git a/kernel/cpuset.c b/kernel/cpuset.c
index cfaf641..ce0cfff 100644
--- a/kernel/cpuset.c
+++ b/kernel/cpuset.c
@@ -821,13 +821,13 @@ static int update_cpumask(struct cpuset *cs, char *buf)
cgroup_iter_end(cgrp, &it);
if (heap.size) {
for (i = 0; i < heap.size; i++) {
- struct task_struct *p = heap.ptrs[i];
+ struct task_struct *q = heap.ptrs[i];
if (i == 0) {
- latest_time = p->start_time;
- latest_task = p;
+ latest_time = q->start_time;
+ latest_task = q;
}
- set_cpus_allowed(p, cs->cpus_allowed);
- put_task_struct(p);
+ set_cpus_allowed(q, cs->cpus_allowed);
+ put_task_struct(q);
}
/*
* If we had to process any tasks at all, scan again
@@ -1269,7 +1269,8 @@ static ssize_t cpuset_common_file_write(struct cgroup *cont,
return -E2BIG;
/* +1 for nul-terminator */
- if ((buffer = kmalloc(nbytes + 1, GFP_KERNEL)) == 0)
+ buffer = kmalloc(nbytes + 1, GFP_KERNEL);
+ if (!buffer)
return -ENOMEM;
if (copy_from_user(buffer, userbuf, nbytes)) {
--
1.5.4.rc5.1138.g2602
^ permalink raw reply [flat|nested] 6+ messages in thread
* Re: [PATCH] cpuset: sparse warnings in cpuset.c
2008-02-03 7:42 ` Harvey Harrison
@ 2008-02-03 7:57 ` Paul Jackson
2008-02-23 8:04 ` Andrew Morton
1 sibling, 0 replies; 6+ messages in thread
From: Paul Jackson @ 2008-02-03 7:57 UTC (permalink / raw)
To: Harvey Harrison; +Cc: akpm, linux-kernel
Harvey wrote:
> Don't redeclare p, use a new variable q.
You dah man! Thanks.
Acked-by: Paul Jackson <pj@sgi.com>
--
I won't rest till it's the best ...
Programmer, Linux Scalability
Paul Jackson <pj@sgi.com> 1.940.382.4214
^ permalink raw reply [flat|nested] 6+ messages in thread
* Re: [PATCH] cpuset: sparse warnings in cpuset.c
2008-02-03 7:42 ` Harvey Harrison
2008-02-03 7:57 ` Paul Jackson
@ 2008-02-23 8:04 ` Andrew Morton
2008-02-23 13:08 ` Paul Jackson
1 sibling, 1 reply; 6+ messages in thread
From: Andrew Morton @ 2008-02-23 8:04 UTC (permalink / raw)
To: Harvey Harrison; +Cc: Paul Jackson, linux-kernel
On Sat, 02 Feb 2008 23:42:23 -0800 Harvey Harrison <harvey.harrison@gmail.com> wrote:
^^^^^^ I suck.
> Don't redeclare p, use a new variable q.
>
> kernel/cpuset.c:824:23: warning: symbol 'p' shadows an earlier one
> kernel/cpuset.c:746:21: originally declared here
> kernel/cpuset.c:1272:52: warning: Using plain integer as NULL pointer
>
> Signed-off-by: Harvey Harrison <harvey.harrison@gmail.com>
> ---
> Paul, used a variable q instead as per your request.
>
> kernel/cpuset.c | 13 +++++++------
> 1 files changed, 7 insertions(+), 6 deletions(-)
>
> diff --git a/kernel/cpuset.c b/kernel/cpuset.c
> index cfaf641..ce0cfff 100644
> --- a/kernel/cpuset.c
> +++ b/kernel/cpuset.c
> @@ -821,13 +821,13 @@ static int update_cpumask(struct cpuset *cs, char *buf)
> cgroup_iter_end(cgrp, &it);
> if (heap.size) {
> for (i = 0; i < heap.size; i++) {
> - struct task_struct *p = heap.ptrs[i];
> + struct task_struct *q = heap.ptrs[i];
> if (i == 0) {
> - latest_time = p->start_time;
> - latest_task = p;
> + latest_time = q->start_time;
> + latest_task = q;
> }
> - set_cpus_allowed(p, cs->cpus_allowed);
> - put_task_struct(p);
> + set_cpus_allowed(q, cs->cpus_allowed);
> + put_task_struct(q);
> }
> /*
> * If we had to process any tasks at all, scan again
Sorry, the above code doesn't seem to exist any more.
^ permalink raw reply [flat|nested] 6+ messages in thread
* Re: [PATCH] cpuset: sparse warnings in cpuset.c
2008-02-23 8:04 ` Andrew Morton
@ 2008-02-23 13:08 ` Paul Jackson
0 siblings, 0 replies; 6+ messages in thread
From: Paul Jackson @ 2008-02-23 13:08 UTC (permalink / raw)
To: Andrew Morton; +Cc: harvey.harrison, linux-kernel
akpm wrote:
> ^^^^^^ I suck.
Yeah, right ... and Dolly Parton is flat chested ;).
> Sorry, the above code doesn't seem to exist any more.
It moved from cpuset.c to cgroup.c. I just sent a reincarnated patch:
[PATCH] cgroup: fix sparse warning of shadow symbol in cgroup.c
--
I won't rest till it's the best ...
Programmer, Linux Scalability
Paul Jackson <pj@sgi.com> 1.940.382.4214
^ permalink raw reply [flat|nested] 6+ messages in thread
end of thread, other threads:[~2008-02-23 13:08 UTC | newest]
Thread overview: 6+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2008-02-03 6:20 [PATCH] cpuset: sparse warnings in cpuset.c Harvey Harrison
2008-02-03 7:28 ` Paul Jackson
2008-02-03 7:42 ` Harvey Harrison
2008-02-03 7:57 ` Paul Jackson
2008-02-23 8:04 ` Andrew Morton
2008-02-23 13:08 ` Paul Jackson
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).