summaryrefslogtreecommitdiffstats
path: root/net/core
diff options
context:
space:
mode:
authorRasmus Villemoes <linux@rasmusvillemoes.dk>2017-11-13 00:15:06 +0100
committerDavid S. Miller <davem@davemloft.net>2017-11-14 08:38:46 +0100
commitc46d7642e915106b0301bc4d53a79e8e806c2eb9 (patch)
treef6054f8f61a21598c67496aadd37f9de37899052 /net/core
parentnet: core: move dev_alloc_name_ns a little higher (diff)
downloadlinux-c46d7642e915106b0301bc4d53a79e8e806c2eb9.tar.xz
linux-c46d7642e915106b0301bc4d53a79e8e806c2eb9.zip
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: Rasmus Villemoes <linux@rasmusvillemoes.dk> Signed-off-by: David S. Miller <davem@davemloft.net>
Diffstat (limited to 'net/core')
-rw-r--r--net/core/dev.c12
1 files changed, 2 insertions, 10 deletions
diff --git a/net/core/dev.c b/net/core/dev.c
index 4545685d2fa7..7580c2046c95 100644
--- a/net/core/dev.c
+++ b/net/core/dev.c
@@ -1114,6 +1114,7 @@ static int dev_alloc_name_ns(struct net *net,
char buf[IFNAMSIZ];
int ret;
+ BUG_ON(!net);
ret = __dev_alloc_name(net, name, buf);
if (ret >= 0)
strlcpy(dev->name, buf, IFNAMSIZ);
@@ -1136,16 +1137,7 @@ static int dev_alloc_name_ns(struct net *net,
int dev_alloc_name(struct net_device *dev, const char *name)
{
- char buf[IFNAMSIZ];
- 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;
+ return dev_alloc_name_ns(dev_net(dev), dev, name);
}
EXPORT_SYMBOL(dev_alloc_name);