Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

udp: preserve const qualifier in udp_sk()

We can change udp_sk() to propagate const qualifier of its argument,
thanks to container_of_const()

This should avoid some potential errors caused by accidental
(const -> not_const) promotion.

Signed-off-by: Eric Dumazet <edumazet@google.com>
Cc: Willem de Bruijn <willemb@google.com>
Reviewed-by: Simon Horman <simon.horman@corigine.com>
Signed-off-by: David S. Miller <davem@davemloft.net>

authored by

Eric Dumazet and committed by
David S. Miller
94c540fb 39a86d05

+1 -4
+1 -4
include/linux/udp.h
··· 97 97 98 98 #define UDP_MAX_SEGMENTS (1 << 6UL) 99 99 100 - static inline struct udp_sock *udp_sk(const struct sock *sk) 101 - { 102 - return (struct udp_sock *)sk; 103 - } 100 + #define udp_sk(ptr) container_of_const(ptr, struct udp_sock, inet.sk) 104 101 105 102 static inline void udp_set_no_check6_tx(struct sock *sk, bool val) 106 103 {