[PATCH net-next v2 2/2] pppox: convert pppox_sk() to use container_of()

Qingfang Deng
2026-04-10T05:50:15Z

Use container_of() macro instead of direct pointer casting to get the
pppox_sock from a sock pointer.

Signed-off-by: Qingfang Deng <qingfang.deng@linux.dev>
---
Changes in v2:
Do not remove the comment, as the struct is allocated from sk_alloc and
still require sock to be the first member.

Link to v1: https://lore.kernel.org/r/20260408015138.280687-2-qingfang.deng@linux.dev

include/linux/if_pppox.h | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/include/linux/if_pppox.h b/include/linux/if_pppox.h
index 636772693f9a..594d6dc3f4c9 100644
--- a/include/linux/if_pppox.h
+++ b/include/linux/if_pppox.h
@@ -54,7 +54,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