Gustavo A. R. Silva
2023-Jan-10 01:39 UTC
[Nouveau] [PATCH][next] drm/nouveau/nvkm: Replace zero-length array with flexible-array member
Zero-length arrays are deprecated[1] and we are moving towards adopting C99 flexible-array members instead. So, replace zero-length array declaration in struct nvfw_hs_load_header_v2 with flex-array member. This helps with the ongoing efforts to tighten the FORTIFY_SOURCE routines on memcpy() and help us make progress towards globally enabling -fstrict-flex-arrays=3 [2]. Link: https://www.kernel.org/doc/html/latest/process/deprecated.html#zero-length-and-one-element-arrays [1] Link: https://gcc.gnu.org/pipermail/gcc-patches/2022-October/602902.html [2] Link: https://github.com/KSPP/linux/issues/78 Signed-off-by: Gustavo A. R. Silva <gustavoars at kernel.org> --- drivers/gpu/drm/nouveau/include/nvfw/hs.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/drivers/gpu/drm/nouveau/include/nvfw/hs.h b/drivers/gpu/drm/nouveau/include/nvfw/hs.h index 8c4cd08a7b5f..8b58b668fc0c 100644 --- a/drivers/gpu/drm/nouveau/include/nvfw/hs.h +++ b/drivers/gpu/drm/nouveau/include/nvfw/hs.h @@ -52,7 +52,7 @@ struct nvfw_hs_load_header_v2 { struct { u32 offset; u32 size; - } app[0]; + } app[]; }; const struct nvfw_hs_load_header_v2 *nvfw_hs_load_header_v2(struct nvkm_subdev *, const void *); -- 2.34.1
Kees Cook
2023-Jan-12 22:49 UTC
[Nouveau] [PATCH][next] drm/nouveau/nvkm: Replace zero-length array with flexible-array member
On Mon, Jan 09, 2023 at 07:39:30PM -0600, Gustavo A. R. Silva wrote:> Zero-length arrays are deprecated[1] and we are moving towards > adopting C99 flexible-array members instead. So, replace zero-length > array declaration in struct nvfw_hs_load_header_v2 with flex-array > member. > > This helps with the ongoing efforts to tighten the FORTIFY_SOURCE > routines on memcpy() and help us make progress towards globally > enabling -fstrict-flex-arrays=3 [2]. > > Link: https://www.kernel.org/doc/html/latest/process/deprecated.html#zero-length-and-one-element-arrays [1] > Link: https://gcc.gnu.org/pipermail/gcc-patches/2022-October/602902.html [2] > Link: https://github.com/KSPP/linux/issues/78 > Signed-off-by: Gustavo A. R. Silva <gustavoars at kernel.org>Reviewed-by: Kees Cook <keescook at chromium.org> -- Kees Cook
Apparently Analagous Threads
- [PATCH 081/141] drm/nouveau/clk: Fix fall-through warnings for Clang
- [PATCH 082/141] drm/nouveau: Fix fall-through warnings for Clang
- [PATCH 083/141] drm/nouveau/therm: Fix fall-through warnings for Clang
- [PATCH] drm/qxl: replace zero-length array with flexible-array member
- [PATCH] drm/nouveau/nvfw/acr: set wpr_generic_header_dump storage-class-specifier to static