Skip to contentSkip to conversation

crypto: zstd - replace zero-length array with flexible array member

PATCH In review Thorsten Blum 4 participants 5 messages Jul 3, 2025 – Jul 10, 2025

Subsystems (2)
lore
Share & tools
lore
#0 lore raw

PATCH 1/1 crypto: zstd - replace zero-length array with flexible array member

Replace the deprecated zero-length array with a modern flexible array member in the struct zstd_ctx.

No functional changes intended.

---
 crypto/zstd.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
crypto/zstd.c +1 -1
index 657e0cf7b952..c489976c3e8b 100644
@@ -25,7 +25,7 @@ struct zstd_ctx {
 	zstd_dctx *dctx;
 	size_t wksp_size;
 	zstd_parameters params;
-	u8 wksp[0] __aligned(8);
+	u8 wksp[] __aligned(8);
 };
 
 static DEFINE_MUTEX(zstd_stream_lock);
Signature · 1 line
2.50.0
Reviewed-by on v1 1/1
#1 lore raw
Quoted 2 lines · Thorsten Blum

Replace the deprecated zero-length array with a modern flexible array member in the struct zstd_ctx.

Oh, weird. This is a very recent change. This should include:

Fixes f5ad93ffb541 ("crypto: zstd - convert to acomp")
Quoted 14 lines

No functional changes intended.

---
 crypto/zstd.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
crypto/zstd.c +0 -0
index 657e0cf7b952..c489976c3e8b 100644

crypto/zstd.c struct zstd_ctx { · line 28

Quoted 5 lines
crypto/zstd.c +1 -1
@@ -25,7 +25,7 @@ struct zstd_ctx {
 	zstd_dctx *dctx;
 	size_t wksp_size;
 	zstd_parameters params;
-	u8 wksp[0] __aligned(8);
+	u8 wksp[] __aligned(8);

And likely, to use __counted_by(wksp_size)

I'm surprised checkpatch.pl didn't warn, but I guess the __aligned confused the script?

-Kees

Quoted 7 lines
crypto/zstd.c +0 -0
 };
 
 static DEFINE_MUTEX(zstd_stream_lock);
Signature · 1 line
2.50.0
Signature · 1 line
Kees Cook
#2 lore raw
Quoted 1 line · Kees Cook

And likely, to use __counted_by(wksp_size)

I hesitated because semantically "size" isn't a "count" although the values are the same here.

Quoted 1 line

Thanks!

#3 lore raw
In reply to Thorsten Blum
Quoted 16 lines · Thorsten Blum

Replace the deprecated zero-length array with a modern flexible array member in the struct zstd_ctx.

No functional changes intended.

---
 crypto/zstd.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
crypto/zstd.c +0 -0
index 657e0cf7b952..c489976c3e8b 100644

crypto/zstd.c struct zstd_ctx { · line 28

Quoted 5 lines
crypto/zstd.c +1 -1
@@ -25,7 +25,7 @@ struct zstd_ctx {
 	zstd_dctx *dctx;
 	size_t wksp_size;
 	zstd_parameters params;
-	u8 wksp[0] __aligned(8);
+	u8 wksp[] __aligned(8);

This is from patch "crypto: zstd - convert to acomp" currently as commit f5ad93ffb54119a8dc in linux-next. Should it rather be folded there? It's part of the crypto queue.

maintainer
#4 lore raw
In reply to Thorsten Blum
Quoted 10 lines · Thorsten Blum

Replace the deprecated zero-length array with a modern flexible array member in the struct zstd_ctx.

No functional changes intended.

---
 crypto/zstd.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

Patch applied. Thanks.

Signature · 3 lines
Email: Herbert Xu <[email protected]>
Home Page: http://gondor.apana.org.au/~herbert/
PGP Key: http://gondor.apana.org.au/~herbert/pubkey.txt