Skip to contentSkip to conversation

ACPICA: iASL: Replace zero-length array with flexible-array member

PATCH In review Gustavo A. R. Silva 3 participants 4 messages Feb 16, 2022 – Feb 18, 2022

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

PATCH 1/1 ACPICA: iASL: Replace zero-length array with flexible-array member

There is a regular need in the kernel to provide a way to declare having a dynamically sized set of trailing elements in a structure. Kernel code should always use “flexible array members”[1] for these cases. The older style of one-element or zero-length arrays should no longer be used[2].

[1] https://en.wikipedia.org/wiki/Flexible_array_member
[2] https://www.kernel.org/doc/html/v5.16/process/deprecated.html#zero-length-and-one-element-arrays

---
 include/acpi/actbl2.h | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
include/acpi/actbl2.h +1 -1
index 16847c8d9d5f..9ee4d1b39125 100644
@@ -2319,7 +2319,7 @@ struct acpi_table_rgrt {
 	u16 version;
 	u8 image_type;
 	u8 reserved;
-	u8 image[0];
+	u8 image[];
 };
 
 /* image_type values */
Signature · 1 line
2.27.0
Reviewed-by on v1 1/1
#1 lore raw
Quoted 11 lines · Gustavo A. R. Silva

There is a regular need in the kernel to provide a way to declare having a dynamically sized set of trailing elements in a structure. Kernel code should always use “flexible array members”[1] for these cases. The older style of one-element or zero-length arrays should no longer be used[2].

[1] https://en.wikipedia.org/wiki/Flexible_array_member
[2] https://www.kernel.org/doc/html/v5.16/process/deprecated.html#zero-length-and-one-element-arrays

Signature · 1 line
Kees Cook
#2 lore raw
Quoted 8 lines · Kees Cook
Quoted 6 lines · Gustavo A. R. Silva

There is a regular need in the kernel to provide a way to declare having a dynamically sized set of trailing elements in a structure. Kernel code should always use “flexible array members”[1] for these cases. The older style of one-element or zero-length arrays should no longer be used[2].

Quoted 7 lines
Quoted 5 lines

[1] https://en.wikipedia.org/wiki/Flexible_array_member
[2] https://www.kernel.org/doc/html/v5.16/process/deprecated.html#zero-length-and-one-element-arrays

Signed-off-by Gustavo A. R. Silva <gustavoars(a)kernel.org>
Reviewed-by Kees Cook <keescook(a)chromium.org>

I've created an upstream ACPICA pull request for this change, thanks!

#3 lore raw
Quoted 3 lines · Rafael J. Wysocki

On Wed, Feb 16, 2022 at 9:36 PM Kees Cook <[email protected]> wrote:

I've created an upstream ACPICA pull request for this change, thanks!

Great.

Thanks, Rafael.
--
Gustavo