[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <ZBIT4BKzACzHZxBy@corigine.com>
Date: Wed, 15 Mar 2023 19:52:16 +0100
From: Simon Horman <simon.horman@...igine.com>
To: Eric Dumazet <edumazet@...gle.com>
Cc: "David S . Miller" <davem@...emloft.net>,
Jakub Kicinski <kuba@...nel.org>,
Paolo Abeni <pabeni@...hat.com>,
David Ahern <dsahern@...nel.org>, netdev@...r.kernel.org,
eric.dumazet@...il.com
Subject: Re: [PATCH net-next 1/8] inet: preserve const qualifier in inet_sk()
On Wed, Mar 15, 2023 at 03:42:38PM +0000, Eric Dumazet wrote:
> We can change inet_sk() to propagate const qualifier of its argument.
>
> This should avoid some potential errors caused by accidental
> (const -> not_const) promotion.
>
> Signed-off-by: Eric Dumazet <edumazet@...gle.com>
Thanks Eric,
very nice to see this kind of change.
Reviewed-by: Simon Horman <simon.horman@...igine.com>
...
> diff --git a/include/net/inet_sock.h b/include/net/inet_sock.h
> index 51857117ac0995cee20c1e62752c470d2a473fa8..6eb8235be67f8b8265cd86782aed2b489e8850ee 100644
> --- a/include/net/inet_sock.h
> +++ b/include/net/inet_sock.h
> @@ -305,10 +305,11 @@ static inline struct sock *skb_to_full_sk(const struct sk_buff *skb)
> return sk_to_full_sk(skb->sk);
> }
>
> -static inline struct inet_sock *inet_sk(const struct sock *sk)
> -{
> - return (struct inet_sock *)sk;
> -}
> +#define inet_sk(sk) \
> + _Generic(sk, \
nit: checkpatch tells me that
There are spaces before tabs (before the '\') on the line above,
and this macro uses spaces for indentation.
> + const struct sock * : ((const struct inet_sock *)(sk)), \
> + struct sock * : ((struct inet_sock *)(sk)) \
> + )
>
> static inline void __inet_sk_copy_descendant(struct sock *sk_to,
> const struct sock *sk_from,
...
Powered by blists - more mailing lists