drivers/net/tun.c: Fixed custom tun devname formatting.

This commit is contained in:
Dmitriy Linikov 2018-08-14 07:13:41 -06:00 committed by Gregory Nutt
parent cbdcb2deed
commit b6151ce997

View File

@ -1231,6 +1231,13 @@ static int tun_dev_init(FAR struct tun_device_s *priv, FAR struct file *filep,
tun_ifdown(&priv->dev);
/* Assign d_ifname if specified. */
if (devfmt)
{
strncpy(priv->dev.d_ifname, devfmt, IFNAMSIZ);
}
/* Register the device with the OS so that socket IOCTLs can be performed */
ret = netdev_register(&priv->dev, NET_LL_TUN);
@ -1242,13 +1249,6 @@ static int tun_dev_init(FAR struct tun_device_s *priv, FAR struct file *filep,
return ret;
}
/* Assign d_ifname if specified. This must be done after registration */
if (devfmt)
{
strncpy(priv->dev.d_ifname, devfmt, IFNAMSIZ);
}
priv->filep = filep; /* Set link to file */
filep->f_priv = priv; /* Set link to TUN device */