Patchwork ipv6: fix array index in ip6_mc_add_src()

login
register
mail settings
Submitter roy.qing.li@gmail.com
Date April 1, 2012, 8:45 a.m.
Message ID <1333269926-24681-1-git-send-email-roy.qing.li@gmail.com>
Download mbox | patch
Permalink /patch/149908/
State Changes Requested
Delegated to: David Miller
Headers show

Comments

roy.qing.li@gmail.com - April 1, 2012, 8:45 a.m.
From: RongQing.Li <roy.qing.li@gmail.com>

Convert array index from the loop bound to the loop index.

Signed-off-by: RongQing.Li <roy.qing.li@gmail.com> 
---
 net/ipv6/mcast.c |    2 +-
 1 files changed, 1 insertions(+), 1 deletions(-)
David Miller - April 1, 2012, 7:13 p.m.
From: roy.qing.li@gmail.com
Date: Sun,  1 Apr 2012 16:45:26 +0800

> From: RongQing.Li <roy.qing.li@gmail.com>
> 
> Convert array index from the loop bound to the loop index.
> 
> Signed-off-by: RongQing.Li <roy.qing.li@gmail.com> 

That's not all you are doing:

> -			(void) ip6_mc_del1_src(pmc, sfmode, &psfsrc[i]);
> +			ip6_mc_del1_src(pmc, sfmode, &psfsrc[j]);

You absolutely MUST mention and explain this (void) removal.
It's probably there to elide an unchecked return value
warning from the compiler.
--
To unsubscribe from this list: send the line "unsubscribe netdev" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
roy.qing.li@gmail.com - April 2, 2012, 10:16 a.m.
2012/4/2 David Miller <davem@davemloft.net>:
> From: roy.qing.li@gmail.com
> Date: Sun,  1 Apr 2012 16:45:26 +0800
>
>> From: RongQing.Li <roy.qing.li@gmail.com>
>>
>> Convert array index from the loop bound to the loop index.
>>
>> Signed-off-by: RongQing.Li <roy.qing.li@gmail.com>
>
> That's not all you are doing:
>
>> -                     (void) ip6_mc_del1_src(pmc, sfmode, &psfsrc[i]);
>> +                     ip6_mc_del1_src(pmc, sfmode, &psfsrc[j]);
>
> You absolutely MUST mention and explain this (void) removal.
> It's probably there to elide an unchecked return value
> warning from the compiler.

since ip6_mc_del1_src() does not use __must_check likely attribute.
I try to compile with several gcc warning options, but do not
find which options can report the unchecked return value.

Maybe other tools will complain the unchecked return value.

So I will keep the void.

-R
--
To unsubscribe from this list: send the line "unsubscribe netdev" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
David Miller - April 2, 2012, 8:19 p.m.
From: RongQing Li <roy.qing.li@gmail.com>
Date: Mon, 2 Apr 2012 18:16:14 +0800

> 2012/4/2 David Miller <davem@davemloft.net>:
>> From: roy.qing.li@gmail.com
>> Date: Sun,  1 Apr 2012 16:45:26 +0800
>>
>>> From: RongQing.Li <roy.qing.li@gmail.com>
>>>
>>> Convert array index from the loop bound to the loop index.
>>>
>>> Signed-off-by: RongQing.Li <roy.qing.li@gmail.com>
>>
>> That's not all you are doing:
>>
>>> -                     (void) ip6_mc_del1_src(pmc, sfmode, &psfsrc[i]);
>>> +                     ip6_mc_del1_src(pmc, sfmode, &psfsrc[j]);
>>
>> You absolutely MUST mention and explain this (void) removal.
>> It's probably there to elide an unchecked return value
>> warning from the compiler.
> 
> since ip6_mc_del1_src() does not use __must_check likely attribute.
> I try to compile with several gcc warning options, but do not
> find which options can report the unchecked return value.

I said "probably", I didn't check myself.

The issue I had was that you didn't mention the void removal in the
commit message.
--
To unsubscribe from this list: send the line "unsubscribe netdev" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
roy.qing.li@gmail.com - April 3, 2012, 12:58 a.m.
OK, I see, thanks

BR

-Roy

2012/4/3, David Miller <davem@davemloft.net>:
> From: RongQing Li <roy.qing.li@gmail.com>
> Date: Mon, 2 Apr 2012 18:16:14 +0800
>
>> 2012/4/2 David Miller <davem@davemloft.net>:
>>> From: roy.qing.li@gmail.com
>>> Date: Sun,  1 Apr 2012 16:45:26 +0800
>>>
>>>> From: RongQing.Li <roy.qing.li@gmail.com>
>>>>
>>>> Convert array index from the loop bound to the loop index.
>>>>
>>>> Signed-off-by: RongQing.Li <roy.qing.li@gmail.com>
>>>
>>> That's not all you are doing:
>>>
>>>> -                     (void) ip6_mc_del1_src(pmc, sfmode, &psfsrc[i]);
>>>> +                     ip6_mc_del1_src(pmc, sfmode, &psfsrc[j]);
>>>
>>> You absolutely MUST mention and explain this (void) removal.
>>> It's probably there to elide an unchecked return value
>>> warning from the compiler.
>>
>> since ip6_mc_del1_src() does not use __must_check likely attribute.
>> I try to compile with several gcc warning options, but do not
>> find which options can report the unchecked return value.
>
> I said "probably", I didn't check myself.
>
> The issue I had was that you didn't mention the void removal in the
> commit message.
>
--
To unsubscribe from this list: send the line "unsubscribe netdev" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html

Patch

diff --git a/net/ipv6/mcast.c b/net/ipv6/mcast.c
index 16c33e3..c6378de 100644
--- a/net/ipv6/mcast.c
+++ b/net/ipv6/mcast.c
@@ -2044,7 +2044,7 @@  static int ip6_mc_add_src(struct inet6_dev *idev, const struct in6_addr *pmca,
 		if (!delta)
 			pmc->mca_sfcount[sfmode]--;
 		for (j=0; j<i; j++)
-			(void) ip6_mc_del1_src(pmc, sfmode, &psfsrc[i]);
+			ip6_mc_del1_src(pmc, sfmode, &psfsrc[j]);
 	} else if (isexclude != (pmc->mca_sfcount[MCAST_EXCLUDE] != 0)) {
 		struct ip6_sf_list *psf;