Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

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.

Fixes: 5bb4c45d466c ("net/tls: Read sk_prot once when building tls proto ops")
Signed-off-by: Arnd Bergmann <arnd@arndb.de>
Signed-off-by: David S. Miller <davem@davemloft.net>

authored by

Arnd Bergmann and committed by
David S. Miller
f691a25c 2abe0523

+2 -2
+2 -2
net/tls/tls_main.c
··· 56 56 TLS_NUM_PROTS, 57 57 }; 58 58 59 - static struct proto *saved_tcpv6_prot; 59 + static const struct proto *saved_tcpv6_prot; 60 60 static DEFINE_MUTEX(tcpv6_prot_mutex); 61 - static struct proto *saved_tcpv4_prot; 61 + static const struct proto *saved_tcpv4_prot; 62 62 static DEFINE_MUTEX(tcpv4_prot_mutex); 63 63 static struct proto tls_prots[TLS_NUM_PROTS][TLS_NUM_CONFIG][TLS_NUM_CONFIG]; 64 64 static struct proto_ops tls_sw_proto_ops;