diff mbox series

[net-next,03/10] raw: preserve const qualifier in raw_sk()

Message ID 20230317155539.2552954-4-edumazet@google.com (mailing list archive)
State Accepted
Commit 0a2db4630b72486ec2f207ae433c2156b7fd3837
Delegated to: Netdev Maintainers
Headers show
Series net: better const qualifier awareness | expand

Checks

Context Check Description
netdev/series_format success Posting correctly formatted
netdev/tree_selection success Clearly marked for net-next, async
netdev/fixes_present success Fixes tag not required for -next series
netdev/header_inline success No static functions without inline keyword in header files
netdev/build_32bit success Errors and warnings before: 30 this patch: 30
netdev/cc_maintainers success CCed 5 of 5 maintainers
netdev/build_clang success Errors and warnings before: 18 this patch: 18
netdev/verify_signedoff success Signed-off-by tag matches author and committer
netdev/deprecated_api success None detected
netdev/check_selftest success No net selftest shell script
netdev/verify_fixes success No Fixes tag
netdev/build_allmodconfig_warn success Errors and warnings before: 30 this patch: 30
netdev/checkpatch success total: 0 errors, 0 warnings, 0 checks, 11 lines checked
netdev/kdoc success Errors and warnings before: 0 this patch: 0
netdev/source_inline success Was 0 now: 0

Commit Message

Eric Dumazet March 17, 2023, 3:55 p.m. UTC
We can change raw_sk() to propagate const qualifier of its argument,
thanks to container_of_const()

Signed-off-by: Eric Dumazet <edumazet@google.com>
---
 include/net/raw.h | 5 +----
 1 file changed, 1 insertion(+), 4 deletions(-)

Comments

Simon Horman March 17, 2023, 4:33 p.m. UTC | #1
On Fri, Mar 17, 2023 at 03:55:32PM +0000, Eric Dumazet wrote:
> We can change raw_sk() to propagate const qualifier of its argument,
> thanks to container_of_const()
> 
> Signed-off-by: Eric Dumazet <edumazet@google.com>

Reviewed-by: Simon Horman <simon.horman@corigine.com>
diff mbox series

Patch

diff --git a/include/net/raw.h b/include/net/raw.h
index 7ad15830cf38460f1fae3a187986d74faef6dd1d..c215af02f7589ee5e77a7c3f89cb216fab638c4c 100644
--- a/include/net/raw.h
+++ b/include/net/raw.h
@@ -83,10 +83,7 @@  struct raw_sock {
 	u32		   ipmr_table;
 };
 
-static inline struct raw_sock *raw_sk(const struct sock *sk)
-{
-	return (struct raw_sock *)sk;
-}
+#define raw_sk(ptr) container_of_const(ptr, struct raw_sock, inet.sk)
 
 static inline bool raw_sk_bound_dev_eq(struct net *net, int bound_dev_if,
 				       int dif, int sdif)