clk: __clk_set_parent: set uninitialized variable
PATCH v2 1/1 clk: __clk_set_parent: set uninitialized variable
This patch fixes the following warning:
drivers/clk/clk.c: In function '__clk_set_parent':
drivers/clk/clk.c:1083:5: warning: 'i' may be used uninitialized in this function [-Wuninitialized]
which has been introduced with commit:
commit 7975059db572eb47f0fb272a62afeae272a4b209
Author: Rajendra Nayak <[email protected]>
Date: Wed Jun 6 14:41:31 2012 +0530
clk: Allow late cache allocation for clk->parentsThis patch applies to linux-3.5-rc5
---
Hello,
here an updated version. Changes since v1:
- Set i to clk->num_parents as Uwe pointed out.
regards, Marc
drivers/clk/clk.c | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-)
drivers/clk/clk.c +4 -2
@@ -1068,13 +1068,15 @@ static int __clk_set_parent(struct clk *clk, struct clk *parent) old_parent = clk->parent;/* find index of new parent clock using cached parent ptrs */ -if (clk->parents) +if (clk->parents) {for (i =0 ; i < clk->num_parents; i++)if (clk->parents[i] == parent)break ; -else + }else { + i = clk->num_parents clk->parents = kzalloc((sizeof(struct clk*) * clk->num_parents),GFP_KERNEL ); + }/* * find index of new parent clock using string name comparison
Signature · 1 line
1.7.10
PATCH v2 1/1 clk: __clk_set_parent: set uninitialized variable
Quoted 15 lines · Marc Kleine-Budde
This patch fixes the following warning:
drivers/clk/clk.c: In function '__clk_set_parent':
drivers/clk/clk.c:1083:5: warning: 'i' may be used uninitialized in this function [-Wuninitialized]which has been introduced with commit:
commit 7975059db572eb47f0fb272a62afeae272a4b209 Author: Rajendra Nayak<[email protected]> Date: Wed Jun 6 14:41:31 2012 +0530 clk: Allow late cache allocation for clk->parentsThis patch applies to linux-3.5-rc5
Quoted 7 lines
Cc Rajendra Nayak<[email protected]>Signed-off-by Marc Kleine-Budde<[email protected]>---
Hello,here an updated version. Changes since v1:
- Set i toclk->num_parentsas Uwe pointed out.
I started looking at how to avoid this initing of i to clk->parents (which is correct for the logic used below, but somehow seems error prone if someone happens to change the logic without noticing the init part)
This is what I came up with, not tested at all, but worth considering if Mike dislikes the idea of initing i to clk->parents.
drivers/clk/clk.c +0 -0
@@ -1067,26 +1067,23 @@ static int __clk_set_parent(struct clk *clk,
struct clk *parent)
old_parent = clk->parent;
- /* find index of new parent clock using cached parent ptrs */
- if (clk->parents)
- for (i = 0; i < clk->num_parents; i++)
- if (clk->parents[i] == parent)
- break;
- else
+ if (!clk->parents)
clk->parents = kzalloc((sizeof(struct clk*) *
clk->num_parents),
GFP_KERNEL);
-
/*
- * find index of new parent clock using string name comparison
- * also try to cache the parent to avoid future calls to
__clk_lookup
+ * find index of new parent clock using cached parent ptrs,
+ * or if not yet cached, use string name comparison and cache
+ * them now to avoid future calls to __clk_lookup.
*/- if (i == clk->num_parents)
- for (i = 0; i < clk->num_parents; i++)
- if (!strcmp(clk->parent_names[i], parent->name)) {
- if (clk->parents)
- clk->parents[i] =__clk_lookup(parent->name);
- break;
- }
+ for (i = 0; i < clk->num_parents; i++) {
+ if (clk->parents && clk->parents[i] == parent)
+ break;
+ else if (!strcmp(clk->parent_names[i], parent->name)) {
+ if (clk->parents)
+ clk->parents[i] =__clk_lookup(parent->name);
+ break;
+ }
+ }
if (i == clk->num_parents) {
pr_debug("%s: clock %s is not a possible parent of
clock %s\n",
regards,
Rajendra
Quoted 28 lines
regards, Marc
drivers/clk/clk.c | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-)drivers/clk/clk.c +4
-2@@ -1068,13 +1068,15 @@ static int __clk_set_parent(struct clk *clk, struct clk *parent) old_parent = clk->parent;/* find index of new parent clock using cached parent ptrs */ -if (clk->parents) +if (clk->parents) {for (i =0 ; i< clk->num_parents; i++)if (clk->parents[i] == parent)break ; -else + }else { + i = clk->num_parents clk->parents = kzalloc((sizeof(struct clk*) * clk->num_parents),GFP_KERNEL ); + }/* * find index of new parent clock using string name comparison
PATCH v2 1/1 clk: __clk_set_parent: set uninitialized variable
Quoted 8 lines · Rajendra Nayak
I started looking at how to avoid this initing of i to
clk->parents(which is correct for the logic used below, but somehow seems error prone if someone happens to change the logic without noticing the init part)
This is what I came up with, not tested at all, but worth considering if Mike dislikes the idea of initing i toclk->parents.
s/clk->parents/clk->num_parents
PATCH v2 1/1 clk: __clk_set_parent: set uninitialized variable
In reply to Rajendra NayakQuoted 27 lines · Rajendra Nayak
Quoted 17 lines · Marc Kleine-Budde
This patch fixes the following warning:
? ? ?drivers/clk/clk.c: In function '
__clk_set_parent':
? ? ?drivers/clk/clk.c:1083:5: warning: 'i' may be used uninitialized in this function [-Wuninitialized]which has been introduced with commit:
? ? ?commit
7975059db572eb47f0fb272a62afeae272a4b209? ? ?Author: Rajendra Nayak<[email protected]>
? ? ?Date: ? Wed Jun 6 14:41:31 2012 +0530? ? ? ? ?clk: Allow late cache allocation for
clk->parentsThis patch applies to linux-3.5-rc5
Quoted 7 lines
Cc Rajendra Nayak<[email protected]>Signed-off-by Marc Kleine-Budde<[email protected]>---
Hello,here an updated version. Changes since v1:
- Set i toclk->num_parentsas Uwe pointed out.
Quoted 9 lines
I started looking at how to avoid this initing of i to
clk->parents(which is correct for the logic used below, but somehow seems error prone if someone happens to change the logic without noticing the init part)
This is what I came up with, not tested at all, but worth considering if Mike dislikes the idea of initing i toclk->parents.
Hi Rajendra and Marc,
I prefer the code flow in Rajendra's change. It seems more readable and has a negative diffstat ;-)
$ git diff --stat drivers/clk/clk.c | 28 +++++++++++++--------------- 1 file changed, 13 insertions(+), 15 deletions(-)
Rajendra, can you test and send a proper patch for the same? Thanks Marc for sending your two previous patches. I don't think that I will Cc this one to stable since it falls under the category of "theoretical but not yet observed" bugs.
Thanks again,
Mike
Quoted 93 lines
drivers/clk/clk.c +1
-6@@ -1067,26 +1067,23 @@ static int __clk_set_parent(struct clk *clk, struct clk *parent) ? ? ? ? old_parent = clk->parent; - ? ? ? /* find index of new parent clock using cached parent ptrs */ - ? ? ? if (clk->parents) - ? ? ? ? ? ? ? for (i = 0; i < clk->num_parents; i++) - ? ? ? ? ? ? ? ? ? ? ? if (clk->parents[i] == parent) - ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? break; - ? ? ? else + ? ? ? if (!clk->parents)? ? ? ? ? ? ? ?
clk->parents=kzalloc((sizeof(struct clk*) * clk->num_parents), ? ? GFP_KERNEL);
-
? ? ? ? /*
- ? ? ? ?* find index of new parent clock using string name comparison
- ? ? ? ?* also try to cache the parent to avoid future calls to__clk_lookup
+ ? ? ? ?* find index of new parent clock using cached parent ptrs,
+ ? ? ? ?* or if not yet cached, use string name comparison and cache
+ ? ? ? ?* them now to avoid future calls to__clk_lookup.
? ? ? ? ?*/
- ? ? ? if (i ==clk->num_parents)
- ? ? ? ? ? ? ? for (i = 0; i <clk->num_parents; i++)
- ? ? ? ? ? ? ? ? ? ? ? if (!strcmp(clk->parent_names[i],parent->name)) {
- ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? if (clk->parents)
- ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? clk->parents[i] =__clk_lookup(parent->name);
- ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? break;
- ? ? ? ? ? ? ? ? ? ? ? }
+ ? ? ? for (i = 0; i <clk->num_parents; i++) {
+ ? ? ? ? ? ? ? if (clk->parents&& clk->parents[i] == parent)
+ ? ? ? ? ? ? ? ? ? ? ? break;
+ ? ? ? ? ? ? ? else if (!strcmp(clk->parent_names[i],parent->name)) {
+ ? ? ? ? ? ? ? ? ? ? ? if (clk->parents)
+ ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? clk->parents[i] =__clk_lookup(parent->name);
+ ? ? ? ? ? ? ? ? ? ? ? break;
+ ? ? ? ? ? ? ? }
+ ? ? ? }? ? ? ? if (i ==
clk->num_parents) {
? ? ? ? ? ? ? ? pr_debug("%s: clock %s is not a possible parent of clock %s\n",regards,
RajendraQuoted 26 lines
regards, Marc
?
drivers/clk/clk.c| ? ?6 ++++--
? 1 file changed, 4 insertions(+), 2 deletions(-)drivers/clk/clk.c +0
-0@@ -1068,13 +1068,15 @@ static int __clk_set_parent(struct clk *clk, struct clk *parent) ? ? ? ? old_parent = clk->parent;? ? ? ? /* find index of new parent clock using cached parent ptrs */
- ? ? ? if (clk->parents)
+ ? ? ? if (clk->parents) {
? ? ? ? ? ? ? ? for (i = 0; i< ?clk->num_parents; i++)
? ? ? ? ? ? ? ? ? ? ? ? if (clk->parents[i] == parent)
? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? break;
- ? ? ? else
+ ? ? ? } else {
+ ? ? ? ? ? ? ? i =clk->num_parents
? ? ? ? ? ? ? ?clk->parents= kzalloc((sizeof(struct clk*) *clk->num_parents),Quoted 5 lines
GFP_KERNEL);
+ ? ? ? }? ? ? ? /*
? ? ? ? ?* find index of new parent clock using string name comparison_______________________________________________
linux-arm-kernel mailing list
linux-arm-kernel at lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-arm-kernel
PATCH v2 1/1 clk: __clk_set_parent: set uninitialized variable
Quoted 10 lines · Mike
Hi Rajendra and Marc,
I prefer the code flow in Rajendra's change. It seems more readable and has a negative diffstat;-)
$ git diff --stat drivers/clk/clk.c | 28 +++++++++++++--------------- 1 file changed, 13 insertions(+), 15 deletions(-)Rajendra, can you test and send a proper patch for the same?
Sure, will do.
PATCH v2 1/1 clk: __clk_set_parent: set uninitialized variable
In reply to Turquette, MikeHello,
Quoted 43 lines · Mike
Quoted 27 lines · Rajendra Nayak
Quoted 17 lines · Marc Kleine-Budde
This patch fixes the following warning:
? ? ?drivers/clk/clk.c: In function '
__clk_set_parent':
? ? ?drivers/clk/clk.c:1083:5: warning: 'i' may be used uninitialized in this function [-Wuninitialized]which has been introduced with commit:
? ? ?commit
7975059db572eb47f0fb272a62afeae272a4b209? ? ?Author: Rajendra Nayak<[email protected]>
? ? ?Date: ? Wed Jun 6 14:41:31 2012 +0530? ? ? ? ?clk: Allow late cache allocation for
clk->parentsThis patch applies to linux-3.5-rc5
Quoted 7 lines
Cc Rajendra Nayak<[email protected]>Signed-off-by Marc Kleine-Budde<[email protected]>---
Hello,here an updated version. Changes since v1:
- Set i toclk->num_parentsas Uwe pointed out.Quoted 9 lines
I started looking at how to avoid this initing of i to
clk->parents(which is correct for the logic used below, but somehow seems error prone if someone happens to change the logic without noticing the init part)
This is what I came up with, not tested at all, but worth considering if Mike dislikes the idea of initing i toclk->parents.Hi Rajendra and Marc,
I prefer the code flow in Rajendra's change. It seems more readable and has a negative diffstat ;-)
Quoted 8 lines
$ git diff --stat drivers/clk/clk.c | 28 +++++++++++++--------------- 1 file changed, 13 insertions(+), 15 deletions(-)Rajendra, can you test and send a proper patch for the same? Thanks Marc for sending your two previous patches. I don't think that I will Cc this one to stable since it falls under the category of "theoretical but not yet observed" bugs.
Maybe it's not observed yet only because 7975059db572eb47f0fb272a62afeae272a4b209 isn't deeply tested yet? Don't know, just a guess.
Best regards
Uwe
Signature · 2 lines
Pengutronix e.K. | Uwe Kleine-K?nig | Industrial Linux Solutions | http://www.pengutronix.de/ |
PATCH v2 1/1 clk: __clk_set_parent: set uninitialized variable
Quoted 50 lines · Uwe Kleine-K?nig
Hello,
Quoted 47 lines · Mike
Quoted 27 lines · Rajendra Nayak
Quoted 17 lines · Marc Kleine-Budde
This patch fixes the following warning:
? ? ?drivers/clk/clk.c: In function '
__clk_set_parent':
? ? ?drivers/clk/clk.c:1083:5: warning: 'i' may be used uninitialized in this function [-Wuninitialized]which has been introduced with commit:
? ? ?commit
7975059db572eb47f0fb272a62afeae272a4b209? ? ?Author: Rajendra Nayak<[email protected]>
? ? ?Date: ? Wed Jun 6 14:41:31 2012 +0530? ? ? ? ?clk: Allow late cache allocation for
clk->parentsThis patch applies to linux-3.5-rc5
Quoted 7 lines
Cc Rajendra Nayak<[email protected]>Signed-off-by Marc Kleine-Budde<[email protected]>---
Hello,here an updated version. Changes since v1:
- Set i toclk->num_parentsas Uwe pointed out.Quoted 9 lines
I started looking at how to avoid this initing of i to
clk->parents(which is correct for the logic used below, but somehow seems error prone if someone happens to change the logic without noticing the init part)
This is what I came up with, not tested at all, but worth considering if Mike dislikes the idea of initing i toclk->parents.Hi Rajendra and Marc,
I prefer the code flow in Rajendra's change. It seems more readable and has a negative diffstat ;-)
$ git diff --stat drivers/clk/clk.c | 28 +++++++++++++--------------- 1 file changed, 13 insertions(+), 15 deletions(-)
Quoted 8 lines
Quoted 4 lines
Rajendra, can you test and send a proper patch for the same? Thanks Marc for sending your two previous patches. I don't think that I will Cc this one to stable since it falls under the category of "theoretical but not yet observed" bugs.
Maybe it's not observed yet only because
7975059db572eb47f0fb272a62afeae272a4b209isn't deeply tested yet? Don't know, just a guess.
Fair enough. I Cc'd stable on that patch and copied you on the fixes request to Linus for 3.5-rc6.
Thanks,
Mike
Quoted 6 lines
Best regards
UweSignature · 2 lines
Pengutronix e.K. | Uwe Kleine-K?nig | Industrial Linux Solutions | http://www.pengutronix.de/ |