Commit 3e9e40e7 authored by Jarno Rajahalme's avatar Jarno Rajahalme Committed by David S. Miller

virtio_net: Simplify call sites for virtio_net_hdr_{from, to}_skb().

No point storing the return value of virtio_net_hdr_to_skb() or
virtio_net_hdr_from_skb() to a variable when the value is used only
once as a boolean in an immediately following if statement.
Signed-off-by: default avatarJarno Rajahalme <jarno@ovn.org>
Signed-off-by: default avatarDavid S. Miller <davem@davemloft.net>
parent ab677ff4
...@@ -821,9 +821,8 @@ static ssize_t macvtap_put_user(struct macvtap_queue *q, ...@@ -821,9 +821,8 @@ static ssize_t macvtap_put_user(struct macvtap_queue *q,
if (iov_iter_count(iter) < vnet_hdr_len) if (iov_iter_count(iter) < vnet_hdr_len)
return -EINVAL; return -EINVAL;
ret = virtio_net_hdr_from_skb(skb, &vnet_hdr, if (virtio_net_hdr_from_skb(skb, &vnet_hdr,
macvtap_is_little_endian(q)); macvtap_is_little_endian(q)))
if (ret)
BUG(); BUG();
if (copy_to_iter(&vnet_hdr, sizeof(vnet_hdr), iter) != if (copy_to_iter(&vnet_hdr, sizeof(vnet_hdr), iter) !=
......
...@@ -1252,8 +1252,7 @@ static ssize_t tun_get_user(struct tun_struct *tun, struct tun_file *tfile, ...@@ -1252,8 +1252,7 @@ static ssize_t tun_get_user(struct tun_struct *tun, struct tun_file *tfile,
return -EFAULT; return -EFAULT;
} }
err = virtio_net_hdr_to_skb(skb, &gso, tun_is_little_endian(tun)); if (virtio_net_hdr_to_skb(skb, &gso, tun_is_little_endian(tun))) {
if (err) {
this_cpu_inc(tun->pcpu_stats->rx_frame_errors); this_cpu_inc(tun->pcpu_stats->rx_frame_errors);
kfree_skb(skb); kfree_skb(skb);
return -EINVAL; return -EINVAL;
...@@ -1367,9 +1366,8 @@ static ssize_t tun_put_user(struct tun_struct *tun, ...@@ -1367,9 +1366,8 @@ static ssize_t tun_put_user(struct tun_struct *tun,
if (iov_iter_count(iter) < vnet_hdr_sz) if (iov_iter_count(iter) < vnet_hdr_sz)
return -EINVAL; return -EINVAL;
ret = virtio_net_hdr_from_skb(skb, &gso, if (virtio_net_hdr_from_skb(skb, &gso,
tun_is_little_endian(tun)); tun_is_little_endian(tun))) {
if (ret) {
struct skb_shared_info *sinfo = skb_shinfo(skb); struct skb_shared_info *sinfo = skb_shinfo(skb);
pr_err("unexpected GSO type: " pr_err("unexpected GSO type: "
"0x%x, gso_size %d, hdr_len %d\n", "0x%x, gso_size %d, hdr_len %d\n",
......
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