Commit c46d7642 authored by Rasmus Villemoes's avatar Rasmus Villemoes Committed by David S. Miller

net: core: eliminate dev_alloc_name{,_ns} code duplication

dev_alloc_name contained a BUG_ON(), which I moved to dev_alloc_name_ns;
the only other caller of that already has the same BUG_ON.
Signed-off-by: default avatarRasmus Villemoes <linux@rasmusvillemoes.dk>
Signed-off-by: default avatarDavid S. Miller <davem@davemloft.net>
parent 2c88b855
...@@ -1114,6 +1114,7 @@ static int dev_alloc_name_ns(struct net *net, ...@@ -1114,6 +1114,7 @@ static int dev_alloc_name_ns(struct net *net,
char buf[IFNAMSIZ]; char buf[IFNAMSIZ];
int ret; int ret;
BUG_ON(!net);
ret = __dev_alloc_name(net, name, buf); ret = __dev_alloc_name(net, name, buf);
if (ret >= 0) if (ret >= 0)
strlcpy(dev->name, buf, IFNAMSIZ); strlcpy(dev->name, buf, IFNAMSIZ);
...@@ -1136,16 +1137,7 @@ static int dev_alloc_name_ns(struct net *net, ...@@ -1136,16 +1137,7 @@ static int dev_alloc_name_ns(struct net *net,
int dev_alloc_name(struct net_device *dev, const char *name) int dev_alloc_name(struct net_device *dev, const char *name)
{ {
char buf[IFNAMSIZ]; return dev_alloc_name_ns(dev_net(dev), dev, name);
struct net *net;
int ret;
BUG_ON(!dev_net(dev));
net = dev_net(dev);
ret = __dev_alloc_name(net, name, buf);
if (ret >= 0)
strlcpy(dev->name, buf, IFNAMSIZ);
return ret;
} }
EXPORT_SYMBOL(dev_alloc_name); EXPORT_SYMBOL(dev_alloc_name);
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment