Skip to contentSkip to conversation

sched: fix uninitialized variable usage

PATCH In review Lin Ming 2 participants 3 messages Nov 30, 2010

lore
Share & tools
lore

Lin Ming

author
#0 lore raw

PATCH 1/1 sched: fix uninitialized variable usage

linux-2.6/kernel/sched.c: In function ‘sched_destroy_group’:
linux-2.6/kernel/sched.c:8101: warning: ‘i’ is used uninitialized in this function

This is caused by commit 3d4b47b(Implement on-demand (active) cfs_rq list)

---
 kernel/sched.c |    3 +--
 1 files changed, 1 insertions(+), 2 deletions(-)
kernel/sched.c +1 -2
index 717bf7d..c3af198 100644
@@ -8088,7 +8088,6 @@ static inline void unregister_fair_sched_group(struct task_group *tg, int cpu)
 {
 	struct rq *rq = cpu_rq(cpu);
 	unsigned long flags;
-	int i;
 
 	/*
 	* Only empty task groups can be destroyed; so we can speculatively
@@ -8098,7 +8097,7 @@ static inline void unregister_fair_sched_group(struct task_group *tg, int cpu)
 		return;
 
 	raw_spin_lock_irqsave(&rq->lock, flags);
-	list_del_leaf_cfs_rq(tg->cfs_rq[i]);
+	list_del_leaf_cfs_rq(tg->cfs_rq[cpu]);
 	raw_spin_unlock_irqrestore(&rq->lock, flags);
 }
 #else /* !CONFG_FAIR_GROUP_SCHED */
#1 lore raw
Quoted 10 lines · Lin Ming

linux-2.6/kernel/sched.c: In function ‘sched_destroy_group’:
linux-2.6/kernel/sched.c:8101: warning: ‘i’ is used uninitialized in this function

This is caused by commit 3d4b47b(Implement on-demand (active) cfs_rq list)

---
 kernel/sched.c |    3 +--

 1 files changed, 1 insertions(+), 2 deletions(-)

Thanks for the catch!

http://lkml.org/lkml/2010/11/29/566 -- should already address this

- Paul

Quoted 24 lines
kernel/sched.c +1 -2
index 717bf7d..c3af198 100644
@@ -8088,7 +8088,6 @@ static inline void unregister_fair_sched_group(struct task_group *tg, int cpu)
  {
        struct rq *rq = cpu_rq(cpu);
        unsigned long flags;
-       int i;
 
        /*
        * Only empty task groups can be destroyed; so we can speculatively
@@ -8098,7 +8097,7 @@ static inline void unregister_fair_sched_group(struct task_group *tg, int cpu)
                return;
 
        raw_spin_lock_irqsave(&rq->lock, flags);
-       list_del_leaf_cfs_rq(tg->cfs_rq[i]);
+       list_del_leaf_cfs_rq(tg->cfs_rq[cpu]);
        raw_spin_unlock_irqrestore(&rq->lock, flags);
  }
  #else /* !CONFG_FAIR_GROUP_SCHED */
author
#2 lore raw
Quoted 12 lines · Paul Turner
Quoted 10 lines · Lin Ming

linux-2.6/kernel/sched.c: In function ‘sched_destroy_group’:
linux-2.6/kernel/sched.c:8101: warning: ‘i’ is used uninitialized in this function

This is caused by commit 3d4b47b(Implement on-demand (active) cfs_rq list)

---
 kernel/sched.c |    3 +--
 1 files changed, 1 insertions(+), 2 deletions(-)
Quoted 3 lines

Thanks for the catch!

http://lkml.org/lkml/2010/11/29/566 -- should already address this

OK :)

Thanks.

Quoted 28 lines

- Paul

Quoted 24 lines
kernel/sched.c +1 -2
index 717bf7d..c3af198 100644
@@ -8088,7 +8088,6 @@ static inline void unregister_fair_sched_group(struct task_group *tg, int cpu)
 {
       struct rq *rq = cpu_rq(cpu);
       unsigned long flags;
-       int i;
 
       /*
       * Only empty task groups can be destroyed; so we can speculatively
@@ -8098,7 +8097,7 @@ static inline void unregister_fair_sched_group(struct task_group *tg, int cpu)
               return;
 
       raw_spin_lock_irqsave(&rq->lock, flags);
-       list_del_leaf_cfs_rq(tg->cfs_rq[i]);
+       list_del_leaf_cfs_rq(tg->cfs_rq[cpu]);
       raw_spin_unlock_irqrestore(&rq->lock, flags);
 }
 #else /* !CONFG_FAIR_GROUP_SCHED */