Skip to contentSkip to conversation

ipv6: fix array index in ip6_mc_add_src()

PATCH Superseded [email protected] 2 participants 5 messages Apr 1, 2012 – Apr 3, 2012

Subsystems (3)

v1 of 2 Superseded Latest is v2 →

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 ipv6: fix array index in ip6_mc_add_src()

From: RongQing.Li <[email protected]>

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

---
 net/ipv6/mcast.c |    2 +-
 1 files changed, 1 insertions(+), 1 deletions(-)
net/ipv6/mcast.c +1 -1
index 16c33e3..c6378de 100644
@@ -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;
 
Signature · 1 line
1.7.1
maintainer
#1 lore raw

From: [email protected]
Date: Sun, 1 Apr 2012 16:45:26 +0800

Quoted 5 lines

From: RongQing.Li <[email protected]>

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

That's not all you are doing:

net/ipv6/mcast.c static int ip6_mc_add_src(struct inet6_dev *idev, const struct in6_addr *pmca, · line 2047

Quoted 2 lines
net/ipv6/mcast.c +1 -1
-			(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.

#2 lore raw

2012/4/2 David Miller <[email protected]>:

Quoted 9 lines

From: [email protected]
Date: Sun,  1 Apr 2012 16:45:26 +0800

Quoted 5 lines

From: RongQing.Li <[email protected]>

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

Quoted 8 lines

That's not all you are doing:

Quoted 2 lines

-                     (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

maintainer
#3 lore raw

From: RongQing Li <[email protected]>
Date: Mon, 2 Apr 2012 18:16:14 +0800

Quoted 15 lines

2012/4/2 David Miller <[email protected]>:

Quoted 14 lines

From: [email protected]
Date: Sun,  1 Apr 2012 16:45:26 +0800

Quoted 5 lines

From: RongQing.Li <[email protected]>

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

That's not all you are doing:

Quoted 2 lines

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

Quoted 7 lines
Quoted 3 lines

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.

#4 lore raw

OK, I see, thanks

BR

-Roy

2012/4/3, David Miller <[email protected]>:

Quoted 31 lines

From: RongQing Li <[email protected]>
Date: Mon, 2 Apr 2012 18:16:14 +0800

Quoted 15 lines

2012/4/2 David Miller <[email protected]>:

Quoted 14 lines

From: [email protected]
Date: Sun, 1 Apr 2012 16:45:26 +0800

Quoted 5 lines

From: RongQing.Li <[email protected]>

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

That's not all you are doing:

Quoted 2 lines
net/ipv6/mcast.c +1 -1
-                     (void) ip6_mc_del1_src(pmc, sfmode, &psfsrc[i]);
+                     ip6_mc_del1_src(pmc, sfmode, &psfsrc[j]);
Quoted 7 lines
Quoted 3 lines

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.