提交 e651f03a 编写于 作者: G Gerrit Renker 提交者: David S. Miller

inet6: Conversion from u8 to int

This replaces assignments of the type "int on LHS" = "u8 on RHS" with
simpler code. The LHS can express all of the unsigned right hand side
values, hence the assigned value can not be negative.
Signed-off-by: NGerrit Renker <gerrit@erg.abdn.ac.uk>
Signed-off-by: NDavid S. Miller <davem@davemloft.net>
上级 9ec04da7
...@@ -323,7 +323,7 @@ void icmpv6_send(struct sk_buff *skb, u8 type, u8 code, __u32 info, ...@@ -323,7 +323,7 @@ void icmpv6_send(struct sk_buff *skb, u8 type, u8 code, __u32 info,
int iif = 0; int iif = 0;
int addr_type = 0; int addr_type = 0;
int len; int len;
int hlimit, tclass; int hlimit;
int err = 0; int err = 0;
if ((u8 *)hdr < skb->head || if ((u8 *)hdr < skb->head ||
...@@ -469,10 +469,6 @@ void icmpv6_send(struct sk_buff *skb, u8 type, u8 code, __u32 info, ...@@ -469,10 +469,6 @@ void icmpv6_send(struct sk_buff *skb, u8 type, u8 code, __u32 info,
if (hlimit < 0) if (hlimit < 0)
hlimit = ip6_dst_hoplimit(dst); hlimit = ip6_dst_hoplimit(dst);
tclass = np->tclass;
if (tclass < 0)
tclass = 0;
msg.skb = skb; msg.skb = skb;
msg.offset = skb_network_offset(skb); msg.offset = skb_network_offset(skb);
msg.type = type; msg.type = type;
...@@ -488,8 +484,8 @@ void icmpv6_send(struct sk_buff *skb, u8 type, u8 code, __u32 info, ...@@ -488,8 +484,8 @@ void icmpv6_send(struct sk_buff *skb, u8 type, u8 code, __u32 info,
err = ip6_append_data(sk, icmpv6_getfrag, &msg, err = ip6_append_data(sk, icmpv6_getfrag, &msg,
len + sizeof(struct icmp6hdr), len + sizeof(struct icmp6hdr),
sizeof(struct icmp6hdr), sizeof(struct icmp6hdr), hlimit,
hlimit, tclass, NULL, &fl, (struct rt6_info*)dst, np->tclass, NULL, &fl, (struct rt6_info*)dst,
MSG_DONTWAIT); MSG_DONTWAIT);
if (err) { if (err) {
ip6_flush_pending_frames(sk); ip6_flush_pending_frames(sk);
...@@ -522,7 +518,6 @@ static void icmpv6_echo_reply(struct sk_buff *skb) ...@@ -522,7 +518,6 @@ static void icmpv6_echo_reply(struct sk_buff *skb)
struct dst_entry *dst; struct dst_entry *dst;
int err = 0; int err = 0;
int hlimit; int hlimit;
int tclass;
saddr = &ipv6_hdr(skb)->daddr; saddr = &ipv6_hdr(skb)->daddr;
...@@ -562,10 +557,6 @@ static void icmpv6_echo_reply(struct sk_buff *skb) ...@@ -562,10 +557,6 @@ static void icmpv6_echo_reply(struct sk_buff *skb)
if (hlimit < 0) if (hlimit < 0)
hlimit = ip6_dst_hoplimit(dst); hlimit = ip6_dst_hoplimit(dst);
tclass = np->tclass;
if (tclass < 0)
tclass = 0;
idev = in6_dev_get(skb->dev); idev = in6_dev_get(skb->dev);
msg.skb = skb; msg.skb = skb;
...@@ -573,7 +564,7 @@ static void icmpv6_echo_reply(struct sk_buff *skb) ...@@ -573,7 +564,7 @@ static void icmpv6_echo_reply(struct sk_buff *skb)
msg.type = ICMPV6_ECHO_REPLY; msg.type = ICMPV6_ECHO_REPLY;
err = ip6_append_data(sk, icmpv6_getfrag, &msg, skb->len + sizeof(struct icmp6hdr), err = ip6_append_data(sk, icmpv6_getfrag, &msg, skb->len + sizeof(struct icmp6hdr),
sizeof(struct icmp6hdr), hlimit, tclass, NULL, &fl, sizeof(struct icmp6hdr), hlimit, np->tclass, NULL, &fl,
(struct rt6_info*)dst, MSG_DONTWAIT); (struct rt6_info*)dst, MSG_DONTWAIT);
if (err) { if (err) {
......
...@@ -194,7 +194,8 @@ int ip6_xmit(struct sock *sk, struct sk_buff *skb, struct flowi *fl, ...@@ -194,7 +194,8 @@ int ip6_xmit(struct sock *sk, struct sk_buff *skb, struct flowi *fl,
struct ipv6hdr *hdr; struct ipv6hdr *hdr;
u8 proto = fl->proto; u8 proto = fl->proto;
int seg_len = skb->len; int seg_len = skb->len;
int hlimit, tclass; int hlimit = -1;
int tclass = 0;
u32 mtu; u32 mtu;
if (opt) { if (opt) {
...@@ -237,19 +238,13 @@ int ip6_xmit(struct sock *sk, struct sk_buff *skb, struct flowi *fl, ...@@ -237,19 +238,13 @@ int ip6_xmit(struct sock *sk, struct sk_buff *skb, struct flowi *fl,
/* /*
* Fill in the IPv6 header * Fill in the IPv6 header
*/ */
if (np) {
hlimit = -1; tclass = np->tclass;
if (np)
hlimit = np->hop_limit; hlimit = np->hop_limit;
}
if (hlimit < 0) if (hlimit < 0)
hlimit = ip6_dst_hoplimit(dst); hlimit = ip6_dst_hoplimit(dst);
tclass = -1;
if (np)
tclass = np->tclass;
if (tclass < 0)
tclass = 0;
*(__be32 *)hdr = htonl(0x60000000 | (tclass << 20)) | fl->fl6_flowlabel; *(__be32 *)hdr = htonl(0x60000000 | (tclass << 20)) | fl->fl6_flowlabel;
hdr->payload_len = htons(seg_len); hdr->payload_len = htons(seg_len);
......
...@@ -1037,8 +1037,6 @@ static int do_ipv6_getsockopt(struct sock *sk, int level, int optname, ...@@ -1037,8 +1037,6 @@ static int do_ipv6_getsockopt(struct sock *sk, int level, int optname,
case IPV6_TCLASS: case IPV6_TCLASS:
val = np->tclass; val = np->tclass;
if (val < 0)
val = 0;
break; break;
case IPV6_RECVTCLASS: case IPV6_RECVTCLASS:
......
...@@ -877,11 +877,8 @@ static int rawv6_sendmsg(struct kiocb *iocb, struct sock *sk, ...@@ -877,11 +877,8 @@ static int rawv6_sendmsg(struct kiocb *iocb, struct sock *sk,
hlimit = ip6_dst_hoplimit(dst); hlimit = ip6_dst_hoplimit(dst);
} }
if (tclass < 0) { if (tclass < 0)
tclass = np->tclass; tclass = np->tclass;
if (tclass < 0)
tclass = 0;
}
if (msg->msg_flags&MSG_CONFIRM) if (msg->msg_flags&MSG_CONFIRM)
goto do_confirm; goto do_confirm;
......
...@@ -946,11 +946,8 @@ int udpv6_sendmsg(struct kiocb *iocb, struct sock *sk, ...@@ -946,11 +946,8 @@ int udpv6_sendmsg(struct kiocb *iocb, struct sock *sk,
hlimit = ip6_dst_hoplimit(dst); hlimit = ip6_dst_hoplimit(dst);
} }
if (tclass < 0) { if (tclass < 0)
tclass = np->tclass; tclass = np->tclass;
if (tclass < 0)
tclass = 0;
}
if (msg->msg_flags&MSG_CONFIRM) if (msg->msg_flags&MSG_CONFIRM)
goto do_confirm; goto do_confirm;
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册