net/tun:Remove unused variables in read & write

Signed-off-by: zhangshuai39 <zhangshuai39@xiaomi.com>
This commit is contained in:
zhangshuai39 2024-07-26 18:13:34 +08:00 committed by archer
parent 155517b5fc
commit a1f9a6624e
1 changed files with 13 additions and 17 deletions

View File

@ -969,9 +969,8 @@ static ssize_t tun_write(FAR struct file *filep, FAR const char *buffer,
size_t buflen)
{
FAR struct tun_device_s *priv = filep->f_priv;
ssize_t nwritten = 0;
uint8_t llhdrlen;
int ret;
ssize_t ret;
if (priv == NULL || buflen > CONFIG_NET_TUN_PKTSIZE)
{
@ -989,7 +988,7 @@ static ssize_t tun_write(FAR struct file *filep, FAR const char *buffer,
ret = nxmutex_lock(&priv->lock);
if (ret < 0)
{
return nwritten == 0 ? (ssize_t)ret : nwritten;
return ret;
}
/* Check if there are free space to write */
@ -1002,7 +1001,6 @@ static ssize_t tun_write(FAR struct file *filep, FAR const char *buffer,
priv->dev.d_buf = NULL;
if (ret < 0)
{
nwritten = (nwritten == 0) ? ret : nwritten;
net_unlock();
break;
}
@ -1011,7 +1009,6 @@ static ssize_t tun_write(FAR struct file *filep, FAR const char *buffer,
buflen, -llhdrlen, false);
if (ret < 0)
{
nwritten = (nwritten == 0) ? ret : nwritten;
net_unlock();
break;
}
@ -1021,7 +1018,7 @@ static ssize_t tun_write(FAR struct file *filep, FAR const char *buffer,
tun_net_receive(priv);
net_unlock();
nwritten = buflen;
ret = buflen;
break;
}
@ -1029,7 +1026,7 @@ static ssize_t tun_write(FAR struct file *filep, FAR const char *buffer,
if ((filep->f_oflags & O_NONBLOCK) != 0)
{
nwritten = -EAGAIN;
ret = -EAGAIN;
break;
}
@ -1039,7 +1036,7 @@ static ssize_t tun_write(FAR struct file *filep, FAR const char *buffer,
}
nxmutex_unlock(&priv->lock);
return nwritten;
return ret;
}
/****************************************************************************
@ -1050,9 +1047,8 @@ static ssize_t tun_read(FAR struct file *filep, FAR char *buffer,
size_t buflen)
{
FAR struct tun_device_s *priv = filep->f_priv;
ssize_t nread = 0;
uint8_t llhdrlen;
int ret;
ssize_t ret;
if (priv == NULL)
{
@ -1070,7 +1066,7 @@ static ssize_t tun_read(FAR struct file *filep, FAR char *buffer,
ret = nxmutex_lock(&priv->lock);
if (ret < 0)
{
return nread == 0 ? (ssize_t)ret : nread;
return ret;
}
/* Check if there are data to read in write buffer */
@ -1079,13 +1075,13 @@ static ssize_t tun_read(FAR struct file *filep, FAR char *buffer,
{
if (buflen < priv->write_d_len)
{
nread = -EINVAL;
ret = -EINVAL;
break;
}
iob_copyout((FAR uint8_t *)buffer, priv->write_buf,
priv->write_d_len, -llhdrlen);
nread = priv->write_d_len;
ret = priv->write_d_len;
iob_free_chain(priv->write_buf);
priv->write_buf = NULL;
@ -1102,13 +1098,13 @@ static ssize_t tun_read(FAR struct file *filep, FAR char *buffer,
{
if (buflen < priv->read_d_len)
{
nread = -EINVAL;
ret = -EINVAL;
break;
}
iob_copyout((FAR uint8_t *)buffer, priv->read_buf,
priv->read_d_len, -llhdrlen);
nread = priv->read_d_len;
ret = priv->read_d_len;
iob_free_chain(priv->read_buf);
priv->read_buf = NULL;
@ -1124,7 +1120,7 @@ static ssize_t tun_read(FAR struct file *filep, FAR char *buffer,
if ((filep->f_oflags & O_NONBLOCK) != 0)
{
nread = -EAGAIN;
ret = -EAGAIN;
break;
}
@ -1134,7 +1130,7 @@ static ssize_t tun_read(FAR struct file *filep, FAR char *buffer,
}
nxmutex_unlock(&priv->lock);
return nread;
return ret;
}
/****************************************************************************