diff mbox series

[net-next,07/10] smc: preserve const qualifier in smc_sk()

Message ID 20230317155539.2552954-8-edumazet@google.com (mailing list archive)
State Accepted
Commit 407db475d505d5aa4c2352b80e429a02f5ccd1e4
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: 18 this patch: 18
netdev/cc_maintainers warning 1 maintainers not CCed: linux-s390@vger.kernel.org
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: 18 this patch: 18
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 smc_sk() to propagate its argument const qualifier,
thanks to container_of_const().

Signed-off-by: Eric Dumazet <edumazet@google.com>
Cc: Karsten Graul <kgraul@linux.ibm.com>
Cc: Wenjia Zhang <wenjia@linux.ibm.com>
Cc: Jan Karcher <jaka@linux.ibm.com>
---
 net/smc/smc.h | 5 +----
 1 file changed, 1 insertion(+), 4 deletions(-)

Comments

Simon Horman March 17, 2023, 5:01 p.m. UTC | #1
On Fri, Mar 17, 2023 at 03:55:36PM +0000, Eric Dumazet wrote:
> We can change smc_sk() to propagate its argument const qualifier,
> thanks to container_of_const().
> 
> Signed-off-by: Eric Dumazet <edumazet@google.com>
> Cc: Karsten Graul <kgraul@linux.ibm.com>
> Cc: Wenjia Zhang <wenjia@linux.ibm.com>
> Cc: Jan Karcher <jaka@linux.ibm.com>

Reviewed-by: Simon Horman <simon.horman@corigine.com>
Wenjia Zhang March 17, 2023, 8:05 p.m. UTC | #2
On 17.03.23 16:55, Eric Dumazet wrote:
> We can change smc_sk() to propagate its argument const qualifier,
> thanks to container_of_const().
> 
> Signed-off-by: Eric Dumazet <edumazet@google.com>
> Cc: Karsten Graul <kgraul@linux.ibm.com>
> Cc: Wenjia Zhang <wenjia@linux.ibm.com>
> Cc: Jan Karcher <jaka@linux.ibm.com>

Reviewed-by: Wenjia Zhang <wenjia@linux.ibm.com>

> ---
>   net/smc/smc.h | 5 +----
>   1 file changed, 1 insertion(+), 4 deletions(-)
> 
> diff --git a/net/smc/smc.h b/net/smc/smc.h
> index 5ed765ea0c731a7f0095cd6a99a0e42d227eaca9..2eeea4cdc7187eed2a3b12888d8f647382f6f2ac 100644
> --- a/net/smc/smc.h
> +++ b/net/smc/smc.h
> @@ -283,10 +283,7 @@ struct smc_sock {				/* smc sock container */
>   						 * */
>   };
>   
> -static inline struct smc_sock *smc_sk(const struct sock *sk)
> -{
> -	return (struct smc_sock *)sk;
> -}
> +#define smc_sk(ptr) container_of_const(ptr, struct smc_sock, sk)
>   
>   static inline void smc_init_saved_callbacks(struct smc_sock *smc)
>   {
diff mbox series

Patch

diff --git a/net/smc/smc.h b/net/smc/smc.h
index 5ed765ea0c731a7f0095cd6a99a0e42d227eaca9..2eeea4cdc7187eed2a3b12888d8f647382f6f2ac 100644
--- a/net/smc/smc.h
+++ b/net/smc/smc.h
@@ -283,10 +283,7 @@  struct smc_sock {				/* smc sock container */
 						 * */
 };
 
-static inline struct smc_sock *smc_sk(const struct sock *sk)
-{
-	return (struct smc_sock *)sk;
-}
+#define smc_sk(ptr) container_of_const(ptr, struct smc_sock, sk)
 
 static inline void smc_init_saved_callbacks(struct smc_sock *smc)
 {