net/tls: fix const assignment warning
Subsystems (3)
PATCH 1/1 net/tls: fix const assignment warning
Building with some experimental patches, I came across a warning in the tls code:
include/linux/compiler.h:215:30: warning: assignment discards 'const' qualifier from pointer target type [-Wdiscarded-qualifiers]
215 | *(volatile typeof(x) *)&(x) = (val); \
| ^net/tls/tls_main.c:650:4: note: in expansion of macro 'smp_store_release'
650 | smp_store_release(&saved_tcpv4_prot, prot);
This appears to be a legitimate warning about assigning a const pointer into the non-const 'saved_tcpv4_prot' global. Annotate both the ipv4 and ipv6 pointers 'const' to make the code internally consistent.
--- net/tls/tls_main.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-)
net/tls/tls_main.c +2 -2
@@ -56,9 +56,9 @@ enum { TLS_NUM_PROTS, }; -static struct proto *saved_tcpv6_prot; +static const struct proto *saved_tcpv6_prot;static DEFINE_MUTEX (tcpv6_prot_mutex); -static struct proto *saved_tcpv4_prot; +static const struct proto *saved_tcpv4_prot;static DEFINE_MUTEX (tcpv4_prot_mutex);static struct proto tls_prots[TLS_NUM_PROTS ][TLS_NUM_CONFIG ][TLS_NUM_CONFIG ];static struct proto_ops tls_sw_proto_ops;
Signature · 1 line
2.26.0
Quoted 26 lines · Arnd Bergmann
Building with some experimental patches, I came across a warning in the tls code:
include/linux/compiler.h:215:30: warning: assignment discards 'const' qualifier from pointer target type [-Wdiscarded-qualifiers]
215 | *(volatile typeof(x) *)&(x) = (val); \
| ^net/tls/tls_main.c:650:4: note: in expansion of macro 'smp_store_release'
650 |smp_store_release(&saved_tcpv4_prot, prot);This appears to be a legitimate warning about assigning a const pointer into the non-const '
saved_tcpv4_prot' global. Annotate both the ipv4 and ipv6 pointers 'const' to make the code internally consistent.Fixes 5bb4c45d466c ("net/tls: Read sk_prot once when building tls proto ops")Signed-off-by Arnd Bergmann <[email protected]>--- net/tls/tls_main.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-)net/tls/tls_main.c +0
-0@@ -56,9 +56,9 @@ enum { TLS_NUM_PROTS,
net/tls/tls_main.c enum { · line 64
Quoted 10 lines
net/tls/tls_main.c +2
-2}; -static struct proto *saved_tcpv6_prot; +static const struct proto *saved_tcpv6_prot;static DEFINE_MUTEX (tcpv6_prot_mutex); -static struct proto *saved_tcpv4_prot; +static const struct proto *saved_tcpv4_prot;static DEFINE_MUTEX (tcpv4_prot_mutex);static struct proto tls_prots[TLS_NUM_PROTS ][TLS_NUM_CONFIG ][TLS_NUM_CONFIG ];static struct proto_ops tls_sw_proto_ops;
LGTM
From: Arnd Bergmann <[email protected]>
Date: Wed, 8 Apr 2020 20:54:43 +0200
Quoted 9 lines
Building with some experimental patches, I came across a warning in the tls code:
include/linux/compiler.h:215:30: warning: assignment discards 'const' qualifier from pointer target type [-Wdiscarded-qualifiers]
215 | *(volatile typeof(x) *)&(x) = (val); \
| ^net/tls/tls_main.c:650:4: note: in expansion of macro 'smp_store_release'
650 |smp_store_release(&saved_tcpv4_prot, prot);
Quoted 6 lines
This appears to be a legitimate warning about assigning a const pointer into the non-const '
saved_tcpv4_prot' global. Annotate both the ipv4 and ipv6 pointers 'const' to make the code internally consistent.Fixes 5bb4c45d466c ("net/tls: Read sk_prot once when building tls proto ops")Signed-off-by Arnd Bergmann <[email protected]>
Applied, thanks.