From: Eric Dumazet Date: Fri, 17 Mar 2023 15:55:30 +0000 (+0000) Subject: udp: preserve const qualifier in udp_sk() X-Git-Url: http://git.maquefel.me/?a=commitdiff_plain;h=94c540fbfc80ef95ec398fc77da1920de2946edb;p=linux.git 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 Cc: Willem de Bruijn Reviewed-by: Simon Horman Signed-off-by: David S. Miller --- diff --git a/include/linux/udp.h b/include/linux/udp.h index a2892e151644e..43c1fb2d2c21a 100644 --- a/include/linux/udp.h +++ b/include/linux/udp.h @@ -97,10 +97,7 @@ struct udp_sock { #define UDP_MAX_SEGMENTS (1 << 6UL) -static inline struct udp_sock *udp_sk(const struct sock *sk) -{ - return (struct udp_sock *)sk; -} +#define udp_sk(ptr) container_of_const(ptr, struct udp_sock, inet.sk) static inline void udp_set_no_check6_tx(struct sock *sk, bool val) {