[PATCH][next] tls: Avoid -Wflex-array-member-not-at-end warning

Gustavo A. R. Silva posted 1 patch 1 week, 2 days ago
There is a newer version of this series
net/tls/tls.h | 5 +++--
1 file changed, 3 insertions(+), 2 deletions(-)
[PATCH][next] tls: Avoid -Wflex-array-member-not-at-end warning
Posted by Gustavo A. R. Silva 1 week, 2 days ago
-Wflex-array-member-not-at-end was introduced in GCC-14, and we are
getting ready to enable it, globally.

Use the new TRAILING_OVERLAP() helper to fix the following warning:

net/tls/tls.h:131:29: warning: structure containing a flexible array member is not at the end of another structure [-Wflex-array-member-not-at-end]

This helper creates a union between a flexible-array member (FAM)
and a set of members that would otherwise follow it. This overlays
the trailing members onto the FAM while preserving the original
memory layout.

Signed-off-by: Gustavo A. R. Silva <gustavoars@kernel.org>
---
 net/tls/tls.h | 5 +++--
 1 file changed, 3 insertions(+), 2 deletions(-)

diff --git a/net/tls/tls.h b/net/tls/tls.h
index 4e077068e6d9..d06435d186c0 100644
--- a/net/tls/tls.h
+++ b/net/tls/tls.h
@@ -128,8 +128,9 @@ struct tls_rec {
 
 	char aad_space[TLS_AAD_SPACE_SIZE];
 	u8 iv_data[TLS_MAX_IV_SIZE];
-	struct aead_request aead_req;
-	u8 aead_req_ctx[];
+	TRAILING_OVERLAP(struct aead_request, aead_req, __ctx,
+		u8 aead_req_ctx[];
+	);
 };
 
 int __net_init tls_proc_init(struct net *net);
-- 
2.43.0
Re: [PATCH][next] tls: Avoid -Wflex-array-member-not-at-end warning
Posted by Sabrina Dubroca 1 week, 2 days ago
2025-09-22, 16:39:20 +0200, Gustavo A. R. Silva wrote:
> -Wflex-array-member-not-at-end was introduced in GCC-14, and we are
> getting ready to enable it, globally.
> 
> Use the new TRAILING_OVERLAP() helper to fix the following warning:
> 
> net/tls/tls.h:131:29: warning: structure containing a flexible array member is not at the end of another structure [-Wflex-array-member-not-at-end]
> 
> This helper creates a union between a flexible-array member (FAM)
> and a set of members that would otherwise follow it. This overlays
> the trailing members onto the FAM while preserving the original
> memory layout.

Do we need to keep aead_req_ctx in tls_rec? It doesn't seem to be
used, and I don't see it ever being used since it was introduced in
commit a42055e8d2c3 ("net/tls: Add support for async encryption of
records for performance").

-- 
Sabrina