Message ID | 20230317155539.2552954-3-edumazet@google.com (mailing list archive) |
---|---|
State | Accepted |
Commit | 68ac9a8b6e65c7cbbe96541353dab1b3f8de2043 |
Delegated to: | Netdev Maintainers |
Headers | show |
Series | net: better const qualifier awareness | expand |
On Fri, Mar 17, 2023 at 03:55:31PM +0000, Eric Dumazet wrote: > We can change pkt_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>
diff --git a/net/packet/internal.h b/net/packet/internal.h index 680703dbce5e04fc26d0fdeab1c1c911b71a8729..e793e99646f1c60f61a8dc5e765f8f544de83972 100644 --- a/net/packet/internal.h +++ b/net/packet/internal.h @@ -133,10 +133,7 @@ struct packet_sock { atomic_t tp_drops ____cacheline_aligned_in_smp; }; -static inline struct packet_sock *pkt_sk(struct sock *sk) -{ - return (struct packet_sock *)sk; -} +#define pkt_sk(ptr) container_of_const(ptr, struct packet_sock, sk) enum packet_sock_flags { PACKET_SOCK_ORIGDEV,
We can change pkt_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> --- net/packet/internal.h | 5 +---- 1 file changed, 1 insertion(+), 4 deletions(-)