Skip to contentSkip to conversation

net: remove an unneeded check

PATCH In review Dan Carpenter 4 participants 5 messages Jul 29, 2013 – Aug 6, 2013

Subsystems (4)
lore
Share & tools
lore
#0 lore raw

PATCH 1/1 net: remove an unneeded check

"ifa->ifa_label" is an array inside the in_ifaddr struct. It can never be NULL so we can remove this check.

net/ipv4/devinet.c +1 -4
index 8d48c39..1b7f7ae 100644
@@ -1124,10 +1124,7 @@ static int inet_gifconf(struct net_device *dev, char __user *buf, int len)
 		if (len < (int) sizeof(ifr))
 			break;
 		memset(&ifr, 0, sizeof(struct ifreq));
-		if (ifa->ifa_label)
-			strcpy(ifr.ifr_name, ifa->ifa_label);
-		else
-			strcpy(ifr.ifr_name, dev->name);
+		strcpy(ifr.ifr_name, ifa->ifa_label);
 
 		(*(struct sockaddr_in *)&ifr.ifr_addr).sin_family = AF_INET;
 		(*(struct sockaddr_in *)&ifr.ifr_addr).sin_addr.s_addr 
#3 lore raw
In reply to Dan Carpenter
Quoted 10 lines · Dan Carpenter

"ifa->ifa_label" is an array inside the in_ifaddr struct. It can never be NULL so we can remove this check.

net/ipv4/devinet.c +0 -0
index 8d48c39..1b7f7ae 100644

net/ipv4/devinet.c static int inet_gifconf(struct net_device *dev, char __user *buf, int len) · line 1127

Quoted 4 lines
net/ipv4/devinet.c +0 -1
@@ -1124,10 +1124,7 @@ static int inet_gifconf(struct net_device *dev, char __user *buf, int len)
 		if (len < (int) sizeof(ifr))
 			break;
 		memset(&ifr, 0, sizeof(struct ifreq));
-		if (ifa->ifa_label)

Is there any possibility that this was meant to check ifa->ifa_label[0]?

Quoted 7 lines
net/ipv4/devinet.c +1 -3
-			strcpy(ifr.ifr_name, ifa->ifa_label);
-		else
-			strcpy(ifr.ifr_name, dev->name);
+		strcpy(ifr.ifr_name, ifa->ifa_label);
 
 		(*(struct sockaddr_in *)&ifr.ifr_addr).sin_family = AF_INET;
 		(*(struct sockaddr_in *)&ifr.ifr_addr).sin_addr.s_addr 
Signature · 1 line
Mark Rustad, Networking Division, Intel Corporation
#4 lore raw
Quoted 7 lines · Mark D
Quoted 5 lines · Dan Carpenter

"ifa->ifa_label" is an array inside the in_ifaddr struct. It can never be NULL so we can remove this check.

Quoted 11 lines

net/ipv4/devinet.c static int inet_gifconf(struct net_device *dev, char __user *buf, int len) · line 1127

Quoted 9 lines
net/ipv4/devinet.c +0 -1
index 8d48c39..1b7f7ae 100644
@@ -1124,10 +1124,7 @@ static int inet_gifconf(struct net_device *dev, char __user *buf, int len)
 		if (len < (int) sizeof(ifr))
 			break;
 		memset(&ifr, 0, sizeof(struct ifreq));
-		if (ifa->ifa_label)

Is there any possibility that this was meant to check ifa->ifa_label[0]?

It has been this way for almost 16 years and no one has complained. I should have put that into the changelog though, you are right.

regards,
dan carpenter