Skip to content

Commit

Permalink
net: core: eliminate dev_alloc_name{,_ns} code duplication
Browse files Browse the repository at this point in the history
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 <[email protected]>
Signed-off-by: David S. Miller <[email protected]>
  • Loading branch information
Villemoes authored and davem330 committed Nov 14, 2017
1 parent 2c88b85 commit c46d764
Showing 1 changed file with 2 additions and 10 deletions.
12 changes: 2 additions & 10 deletions net/core/dev.c
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand All @@ -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);

Expand Down

0 comments on commit c46d764

Please sign in to comment.