[PATCH 1/3][Yakkety][SRU] virtio_net: Simplify call sites for virtio_net_hdr_{from, to}_skb().
Jay Vosburgh
jay.vosburgh at canonical.com
Wed Apr 19 23:41:45 UTC 2017
From: Jarno Rajahalme <jarno at ovn.org>
BugLink: https://bugs.launchpad.net/bugs/1683947
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: Jarno Rajahalme <jarno at ovn.org>
Signed-off-by: David S. Miller <davem at davemloft.net>
(cherry picked from 3e9e40e74753346218e8285cf1ecff9ef3a624c6)
Signed-off-by: Jay Vosburgh <jay.vosburgh at canonical.com>
---
drivers/net/macvtap.c | 5 ++---
drivers/net/tun.c | 8 +++-----
2 files changed, 5 insertions(+), 8 deletions(-)
diff --git a/drivers/net/macvtap.c b/drivers/net/macvtap.c
index 070e3290aa6e..5da9861ad79c 100644
--- a/drivers/net/macvtap.c
+++ b/drivers/net/macvtap.c
@@ -821,9 +821,8 @@ static ssize_t macvtap_put_user(struct macvtap_queue *q,
if (iov_iter_count(iter) < vnet_hdr_len)
return -EINVAL;
- ret = virtio_net_hdr_from_skb(skb, &vnet_hdr,
- macvtap_is_little_endian(q));
- if (ret)
+ if (virtio_net_hdr_from_skb(skb, &vnet_hdr,
+ macvtap_is_little_endian(q)))
BUG();
if (copy_to_iter(&vnet_hdr, sizeof(vnet_hdr), iter) !=
diff --git a/drivers/net/tun.c b/drivers/net/tun.c
index 6f9df375c5d4..57f9e0ffa6ff 100644
--- a/drivers/net/tun.c
+++ b/drivers/net/tun.c
@@ -1266,8 +1266,7 @@ static ssize_t tun_get_user(struct tun_struct *tun, struct tun_file *tfile,
return -EFAULT;
}
- err = virtio_net_hdr_to_skb(skb, &gso, tun_is_little_endian(tun));
- if (err) {
+ if (virtio_net_hdr_to_skb(skb, &gso, tun_is_little_endian(tun))) {
this_cpu_inc(tun->pcpu_stats->rx_frame_errors);
kfree_skb(skb);
return -EINVAL;
@@ -1381,9 +1380,8 @@ static ssize_t tun_put_user(struct tun_struct *tun,
if (iov_iter_count(iter) < vnet_hdr_sz)
return -EINVAL;
- ret = virtio_net_hdr_from_skb(skb, &gso,
- tun_is_little_endian(tun));
- if (ret) {
+ if (virtio_net_hdr_from_skb(skb, &gso,
+ tun_is_little_endian(tun))) {
struct skb_shared_info *sinfo = skb_shinfo(skb);
pr_err("unexpected GSO type: "
"0x%x, gso_size %d, hdr_len %d\n",
--
2.7.4
More information about the kernel-team
mailing list