Skip to content

Commit f01be98

Browse files
thejhzx2c4
authored andcommitted
socket: remove bogus __be32 annotation
The endpoint->src_if4 has nothing to do with fixed-endian numbers; remove the bogus annotation. This was introduced in https://git.zx2c4.com/wireguard-monolithic-historical/commit?id=14e7d0a499a676ec55176c0de2f9fcbd34074a82 in the historical WireGuard repo because the old code used to zero-initialize multiple members as follows: endpoint->src4.s_addr = endpoint->src_if4 = fl.saddr = 0; Because fl.saddr is fixed-endian and an assignment returns a value with the type of its left operand, this meant that sparse detected an assignment between values of different endianness. Since then, this assignment was already split up into separate statements; just the cast survived. Signed-off-by: Jann Horn <jannh@google.com> Signed-off-by: Jason A. Donenfeld <Jason@zx2c4.com>
1 parent 2730072 commit f01be98

File tree

1 file changed

+2
-2
lines changed

1 file changed

+2
-2
lines changed

src/socket.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -53,7 +53,7 @@ static int send4(struct wg_device *wg, struct sk_buff *skb,
5353
if (unlikely(!inet_confirm_addr(sock_net(sock), NULL, 0,
5454
fl.saddr, RT_SCOPE_HOST))) {
5555
endpoint->src4.s_addr = 0;
56-
*(__force __be32 *)&endpoint->src_if4 = 0;
56+
endpoint->src_if4 = 0;
5757
fl.saddr = 0;
5858
if (cache)
5959
dst_cache_reset(cache);
@@ -63,7 +63,7 @@ static int send4(struct wg_device *wg, struct sk_buff *skb,
6363
PTR_ERR(rt) == -EINVAL) || (!IS_ERR(rt) &&
6464
rt->dst.dev->ifindex != endpoint->src_if4)))) {
6565
endpoint->src4.s_addr = 0;
66-
*(__force __be32 *)&endpoint->src_if4 = 0;
66+
endpoint->src_if4 = 0;
6767
fl.saddr = 0;
6868
if (cache)
6969
dst_cache_reset(cache);

0 commit comments

Comments
 (0)