diff mbox

net: remove an unneeded check

Message ID 20130729191519.GA11874@elgon.mountain
State Accepted, archived
Delegated to: David Miller
Headers show

Commit Message

Dan Carpenter July 29, 2013, 7:15 p.m. UTC
"ifa->ifa_label" is an array inside the in_ifaddr struct.  It can never
be NULL so we can remove this check.

Signed-off-by: Dan Carpenter <dan.carpenter@oracle.com>

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

Comments

Jiri Pirko July 29, 2013, 9:17 p.m. UTC | #1
Mon, Jul 29, 2013 at 09:15:19PM CEST, dan.carpenter@oracle.com wrote:
>"ifa->ifa_label" is an array inside the in_ifaddr struct.  It can never
>be NULL so we can remove this check.
>
>Signed-off-by: Dan Carpenter <dan.carpenter@oracle.com>
Reviewed-by: Jiri Pirko <jiri@resnulli.us>
--
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 July 31, 2013, 2:24 a.m. UTC | #2
From: Dan Carpenter <dan.carpenter@oracle.com>
Date: Mon, 29 Jul 2013 22:15:19 +0300

> "ifa->ifa_label" is an array inside the in_ifaddr struct.  It can never
> be NULL so we can remove this check.
> 
> Signed-off-by: Dan Carpenter <dan.carpenter@oracle.com>

Yeah this has been like this forever, applied to net-next, thanks
Dan.
--
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
Rustad, Mark D Aug. 5, 2013, 6:18 p.m. UTC | #3
On Jul 29, 2013, at 12:15 PM, Dan Carpenter <dan.carpenter@oracle.com> wrote:

> "ifa->ifa_label" is an array inside the in_ifaddr struct.  It can never
> be NULL so we can remove this check.
> 
> Signed-off-by: Dan Carpenter <dan.carpenter@oracle.com>
> 
> diff --git a/net/ipv4/devinet.c b/net/ipv4/devinet.c
> index 8d48c39..1b7f7ae 100644
> --- a/net/ipv4/devinet.c
> +++ b/net/ipv4/devinet.c
> @@ -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]?

> -			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 =
Dan Carpenter Aug. 6, 2013, 12:04 p.m. UTC | #4
On Mon, Aug 05, 2013 at 06:18:01PM +0000, Rustad, Mark D wrote:
> On Jul 29, 2013, at 12:15 PM, Dan Carpenter <dan.carpenter@oracle.com> wrote:
> 
> > "ifa->ifa_label" is an array inside the in_ifaddr struct.  It can never
> > be NULL so we can remove this check.
> > 
> > Signed-off-by: Dan Carpenter <dan.carpenter@oracle.com>
> > 
> > diff --git a/net/ipv4/devinet.c b/net/ipv4/devinet.c
> > index 8d48c39..1b7f7ae 100644
> > --- a/net/ipv4/devinet.c
> > +++ b/net/ipv4/devinet.c
> > @@ -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

--
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
diff mbox

Patch

diff --git a/net/ipv4/devinet.c b/net/ipv4/devinet.c
index 8d48c39..1b7f7ae 100644
--- a/net/ipv4/devinet.c
+++ b/net/ipv4/devinet.c
@@ -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 =