[PATCH net-next 2/2] pppox: convert pppox_sk() to use container_of()
Qingfang Deng <[email protected]> Wed, 8 Apr 2026 09:51:34 +0800
| Newsgroups | org.kernel.vger.linux-ppp,org.kernel.vger.linux-kernel,org.kernel.vger.netdev |
|---|---|
| Message-ID | <[email protected]> |
Use container_of() macro instead of direct pointer casting to get the pppox_sock from a sock pointer. This improves type safety and removes the requirement that sk must be the first struct member. Signed-off-by: Qingfang Deng <[email protected]> --- include/linux/if_pppox.h | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/include/linux/if_pppox.h b/include/linux/if_pppox.h index 636772693f9a..4f8d9e02cd7f 100644 --- a/include/linux/if_pppox.h +++ b/include/linux/if_pppox.h @@ -38,7 +38,6 @@ struct pptp_opt { #include <net/sock.h> struct pppox_sock { - /* struct sock must be the first member of pppox_sock */ struct sock sk; struct ppp_channel chan; struct pppox_sock __rcu *next; /* for hash table */ @@ -54,7 +53,7 @@ struct pppox_sock { static inline struct pppox_sock *pppox_sk(struct sock *sk) { - return (struct pppox_sock *)sk; + return container_of(sk, struct pppox_sock, sk); } struct module; -- 2.43.0