Message ID | 5698C61A.90504@users.sourceforge.net |
---|---|
State | Rejected, archived |
Delegated to: | David Miller |
Headers | show |
On Fri, Jan 15, 2016 at 11:12:42AM +0100, SF Markus Elfring wrote: > From: Markus Elfring <elfring@users.sourceforge.net> > Date: Fri, 15 Jan 2016 10:40:24 +0100 > > Omit explicit initialisation at the beginning for four local variables > which are redefined before their first use. > > Signed-off-by: Markus Elfring <elfring@users.sourceforge.net> > --- > drivers/net/ethernet/freescale/gianfar_ethtool.c | 6 +++--- > 1 file changed, 3 insertions(+), 3 deletions(-) > > diff --git a/drivers/net/ethernet/freescale/gianfar_ethtool.c b/drivers/net/ethernet/freescale/gianfar_ethtool.c > index 825b051..8302f7d 100644 > --- a/drivers/net/ethernet/freescale/gianfar_ethtool.c > +++ b/drivers/net/ethernet/freescale/gianfar_ethtool.c > @@ -768,12 +768,12 @@ static void ethflow_to_filer_rules (struct gfar_private *priv, u64 ethflow) > static int gfar_ethflow_to_filer_table(struct gfar_private *priv, u64 ethflow, > u64 class) > { > - unsigned int last_rule_idx = priv->cur_filer_idx; > + unsigned int last_rule_idx; This is a write only variable. We can just remove it. regards, dan carpenter
>> +++ b/drivers/net/ethernet/freescale/gianfar_ethtool.c >> @@ -768,12 +768,12 @@ static void ethflow_to_filer_rules (struct gfar_private *priv, u64 ethflow) >> static int gfar_ethflow_to_filer_table(struct gfar_private *priv, u64 ethflow, >> u64 class) >> { >> - unsigned int last_rule_idx = priv->cur_filer_idx; >> + unsigned int last_rule_idx; > > This is a write only variable. We can just remove it. Can a static source code analysis tool like the software "http://smatch.sourceforge.net/" detect that such a variable is not read by this function implementation so far? https://git.kernel.org/cgit/linux/kernel/git/next/linux-next.git/tree/drivers/net/ethernet/freescale/gianfar_ethtool.c?id=b75ec3af27bf011a760e2f44eb25a99b6fbb0fb3#n850 Does this place indicate an unwanted value assignment as a leftover, or are there any other actions missing? Regards, Markus
On Fri, Jan 15, 2016 at 12:34:33PM +0100, SF Markus Elfring wrote: > >> +++ b/drivers/net/ethernet/freescale/gianfar_ethtool.c > >> @@ -768,12 +768,12 @@ static void ethflow_to_filer_rules (struct gfar_private *priv, u64 ethflow) > >> static int gfar_ethflow_to_filer_table(struct gfar_private *priv, u64 ethflow, > >> u64 class) > >> { > >> - unsigned int last_rule_idx = priv->cur_filer_idx; > >> + unsigned int last_rule_idx; > > > > This is a write only variable. We can just remove it. > > Can a static source code analysis tool like the software "http://smatch.sourceforge.net/" > detect that such a variable is not read by this function implementation so far? Yeah. That's a good idea. I will do that. > https://git.kernel.org/cgit/linux/kernel/git/next/linux-next.git/tree/drivers/net/ethernet/freescale/gianfar_ethtool.c?id=b75ec3af27bf011a760e2f44eb25a99b6fbb0fb3#n850 > > Does this place indicate an unwanted value assignment as a leftover, > or are there any other actions missing? I think it's just an extra variable and you can just delete it. regards, dan carpenter
From: SF Markus Elfring <elfring@users.sourceforge.net> Date: Fri, 15 Jan 2016 12:34:33 +0100 >>> +++ b/drivers/net/ethernet/freescale/gianfar_ethtool.c >>> @@ -768,12 +768,12 @@ static void ethflow_to_filer_rules (struct gfar_private *priv, u64 ethflow) >>> static int gfar_ethflow_to_filer_table(struct gfar_private *priv, u64 ethflow, >>> u64 class) >>> { >>> - unsigned int last_rule_idx = priv->cur_filer_idx; >>> + unsigned int last_rule_idx; >> >> This is a write only variable. We can just remove it. > > Can a static source code analysis tool like the software "http://smatch.sourceforge.net/" > detect that such a variable is not read by this function implementation so far? No, but a human can. And a human should fully analyze any change he writes based upon static analysis tool results. I am going to be honest, and say that I am completely ignoring most of your static checker patches. You don't put enough care and consideration into them, and I really don't have time to waste on looking at something like that.
>>> This is a write only variable. We can just remove it. >> >> Can a static source code analysis tool like the software "http://smatch.sourceforge.net/" >> detect that such a variable is not read by this function implementation so far? > > No, I imagine that there are a few tools available which can point such update candidates out. There are various software development challenges to consider. > but a human can. Some software developers and source code reviewers are struggling with mentioned implementation details as usual. Do they also wonder how the discussed variable assignment was left over in a specific function? > I am going to be honest, and say that I am completely ignoring most of > your static checker patches. I am curious if you would reconsider the affected source code places once more when you will be notified about related issues by other tools or persons. > You don't put enough care and consideration into them, Would you like to explain this impression a bit more? > and I really don't have time to waste on looking at something like that. Thanks for your feedback. Various open issues are competing for our attention as usual. Regards, Markus
diff --git a/drivers/net/ethernet/freescale/gianfar_ethtool.c b/drivers/net/ethernet/freescale/gianfar_ethtool.c index 825b051..8302f7d 100644 --- a/drivers/net/ethernet/freescale/gianfar_ethtool.c +++ b/drivers/net/ethernet/freescale/gianfar_ethtool.c @@ -768,12 +768,12 @@ static void ethflow_to_filer_rules (struct gfar_private *priv, u64 ethflow) static int gfar_ethflow_to_filer_table(struct gfar_private *priv, u64 ethflow, u64 class) { - unsigned int last_rule_idx = priv->cur_filer_idx; + unsigned int last_rule_idx; unsigned int cmp_rqfpr; unsigned int *local_rqfpr; unsigned int *local_rqfcr; - int i = 0x0, k = 0x0; - int j = MAX_FILER_IDX, l = 0x0; + int i, k, l; + int j = MAX_FILER_IDX; int ret = 1; local_rqfpr = kmalloc_array(MAX_FILER_IDX + 1, sizeof(unsigned int),