Commit 81d54ec8 authored by Gerrit Renker's avatar Gerrit Renker Committed by David S. Miller

udp: remove redundant variable

The variable 'copied' is used in udp_recvmsg() to emphasize that the passed
'len' is adjusted to fit the actual datagram length. But the same can be
done by adjusting 'len' directly. This patch thus removes the indirection.
Signed-off-by: default avatarGerrit Renker <gerrit@erg.abdn.ac.uk>
Signed-off-by: default avatarDavid S. Miller <davem@davemloft.net>
parent 55d95590
...@@ -1117,7 +1117,7 @@ int udp_recvmsg(struct kiocb *iocb, struct sock *sk, struct msghdr *msg, ...@@ -1117,7 +1117,7 @@ int udp_recvmsg(struct kiocb *iocb, struct sock *sk, struct msghdr *msg,
struct inet_sock *inet = inet_sk(sk); struct inet_sock *inet = inet_sk(sk);
struct sockaddr_in *sin = (struct sockaddr_in *)msg->msg_name; struct sockaddr_in *sin = (struct sockaddr_in *)msg->msg_name;
struct sk_buff *skb; struct sk_buff *skb;
unsigned int ulen, copied; unsigned int ulen;
int peeked; int peeked;
int err; int err;
int is_udplite = IS_UDPLITE(sk); int is_udplite = IS_UDPLITE(sk);
...@@ -1138,10 +1138,9 @@ int udp_recvmsg(struct kiocb *iocb, struct sock *sk, struct msghdr *msg, ...@@ -1138,10 +1138,9 @@ int udp_recvmsg(struct kiocb *iocb, struct sock *sk, struct msghdr *msg,
goto out; goto out;
ulen = skb->len - sizeof(struct udphdr); ulen = skb->len - sizeof(struct udphdr);
copied = len; if (len > ulen)
if (copied > ulen) len = ulen;
copied = ulen; else if (len < ulen)
else if (copied < ulen)
msg->msg_flags |= MSG_TRUNC; msg->msg_flags |= MSG_TRUNC;
/* /*
...@@ -1150,14 +1149,14 @@ int udp_recvmsg(struct kiocb *iocb, struct sock *sk, struct msghdr *msg, ...@@ -1150,14 +1149,14 @@ int udp_recvmsg(struct kiocb *iocb, struct sock *sk, struct msghdr *msg,
* coverage checksum (UDP-Lite), do it before the copy. * coverage checksum (UDP-Lite), do it before the copy.
*/ */
if (copied < ulen || UDP_SKB_CB(skb)->partial_cov) { if (len < ulen || UDP_SKB_CB(skb)->partial_cov) {
if (udp_lib_checksum_complete(skb)) if (udp_lib_checksum_complete(skb))
goto csum_copy_err; goto csum_copy_err;
} }
if (skb_csum_unnecessary(skb)) if (skb_csum_unnecessary(skb))
err = skb_copy_datagram_iovec(skb, sizeof(struct udphdr), err = skb_copy_datagram_iovec(skb, sizeof(struct udphdr),
msg->msg_iov, copied); msg->msg_iov, len);
else { else {
err = skb_copy_and_csum_datagram_iovec(skb, err = skb_copy_and_csum_datagram_iovec(skb,
sizeof(struct udphdr), sizeof(struct udphdr),
...@@ -1186,7 +1185,7 @@ int udp_recvmsg(struct kiocb *iocb, struct sock *sk, struct msghdr *msg, ...@@ -1186,7 +1185,7 @@ int udp_recvmsg(struct kiocb *iocb, struct sock *sk, struct msghdr *msg,
if (inet->cmsg_flags) if (inet->cmsg_flags)
ip_cmsg_recv(msg, skb); ip_cmsg_recv(msg, skb);
err = copied; err = len;
if (flags & MSG_TRUNC) if (flags & MSG_TRUNC)
err = ulen; err = ulen;
......
...@@ -322,7 +322,7 @@ int udpv6_recvmsg(struct kiocb *iocb, struct sock *sk, ...@@ -322,7 +322,7 @@ int udpv6_recvmsg(struct kiocb *iocb, struct sock *sk,
struct ipv6_pinfo *np = inet6_sk(sk); struct ipv6_pinfo *np = inet6_sk(sk);
struct inet_sock *inet = inet_sk(sk); struct inet_sock *inet = inet_sk(sk);
struct sk_buff *skb; struct sk_buff *skb;
unsigned int ulen, copied; unsigned int ulen;
int peeked; int peeked;
int err; int err;
int is_udplite = IS_UDPLITE(sk); int is_udplite = IS_UDPLITE(sk);
...@@ -341,10 +341,9 @@ int udpv6_recvmsg(struct kiocb *iocb, struct sock *sk, ...@@ -341,10 +341,9 @@ int udpv6_recvmsg(struct kiocb *iocb, struct sock *sk,
goto out; goto out;
ulen = skb->len - sizeof(struct udphdr); ulen = skb->len - sizeof(struct udphdr);
copied = len; if (len > ulen)
if (copied > ulen) len = ulen;
copied = ulen; else if (len < ulen)
else if (copied < ulen)
msg->msg_flags |= MSG_TRUNC; msg->msg_flags |= MSG_TRUNC;
is_udp4 = (skb->protocol == htons(ETH_P_IP)); is_udp4 = (skb->protocol == htons(ETH_P_IP));
...@@ -355,14 +354,14 @@ int udpv6_recvmsg(struct kiocb *iocb, struct sock *sk, ...@@ -355,14 +354,14 @@ int udpv6_recvmsg(struct kiocb *iocb, struct sock *sk,
* coverage checksum (UDP-Lite), do it before the copy. * coverage checksum (UDP-Lite), do it before the copy.
*/ */
if (copied < ulen || UDP_SKB_CB(skb)->partial_cov) { if (len < ulen || UDP_SKB_CB(skb)->partial_cov) {
if (udp_lib_checksum_complete(skb)) if (udp_lib_checksum_complete(skb))
goto csum_copy_err; goto csum_copy_err;
} }
if (skb_csum_unnecessary(skb)) if (skb_csum_unnecessary(skb))
err = skb_copy_datagram_iovec(skb, sizeof(struct udphdr), err = skb_copy_datagram_iovec(skb, sizeof(struct udphdr),
msg->msg_iov, copied ); msg->msg_iov,len);
else { else {
err = skb_copy_and_csum_datagram_iovec(skb, sizeof(struct udphdr), msg->msg_iov); err = skb_copy_and_csum_datagram_iovec(skb, sizeof(struct udphdr), msg->msg_iov);
if (err == -EINVAL) if (err == -EINVAL)
...@@ -411,7 +410,7 @@ int udpv6_recvmsg(struct kiocb *iocb, struct sock *sk, ...@@ -411,7 +410,7 @@ int udpv6_recvmsg(struct kiocb *iocb, struct sock *sk,
datagram_recv_ctl(sk, msg, skb); datagram_recv_ctl(sk, msg, skb);
} }
err = copied; err = len;
if (flags & MSG_TRUNC) if (flags & MSG_TRUNC)
err = ulen; err = ulen;
......
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