drm/nouveau: fifo: Avoid -Wflex-array-member-not-at-end warning
Subsystems (3)
PATCH v3 1/1 drm/nouveau: fifo: Avoid -Wflex-array-member-not-at-end warning
-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:
drivers/gpu/drm/nouveau/nvif/fifo.c:29:42: 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.
---
Changes in v3:
- Use the new TRAILING_OVERLAP() helper.
Changes in v2:
- Adjust heap allocation.
drivers/gpu/drm/nouveau/nvif/fifo.c | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-)
drivers/gpu/drm/nouveau/nvif/fifo.c +2 -3
@@ -25,13 +25,12 @@ static int nvif_fifo_runlists(struct nvif_device *device) {struct nvif_object *object = &device->object; -struct { -struct nv_device_info_v1 m; + TRAILING_OVERLAP(struct nv_device_info_v1, m, data, struct {struct nv_device_info_v1_data runlists;struct nv_device_info_v1_data runlist[64 ]; } v; - } *a; + ) *a;int ret, i;if (device->runlist)
Signature · 1 line
2.43.0
Hi,
Quoted 5 lines · Gustavo A. R. Silva
-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:
Quoted 8 lines
drivers/gpu/drm/nouveau/nvif/fifo.c:29:42: 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 <[email protected]>
I took a look at the modified structure layout with the union from the macro using pahole and found the layouts and sizes to be equivalent -- all the while fixing the warning you demonstrated.
Quoted 3 lines
---
Changes in v3:
- Use the newTRAILING_OVERLAP()helper.
There's really starting to be a lot of these helper macros!
Quoted 31 lines
Changes in v2:
- Adjust heap allocation.drivers/gpu/drm/nouveau/nvif/fifo.c | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-)drivers/gpu/drm/nouveau/nvif/fifo.c +2
-3@@ -25,13 +25,12 @@ static int nvif_fifo_runlists(struct nvif_device *device) {struct nvif_object *object = &device->object; -struct { -struct nv_device_info_v1 m; + TRAILING_OVERLAP(struct nv_device_info_v1, m, data, struct {struct nv_device_info_v1_data runlists;struct nv_device_info_v1_data runlist[64 ]; } v; - } *a; + ) *a;int ret, i;if (device->runlist)Signature · 1 line
2.43.0
Thanks
Justin
Hi all,
Friendly ping: who can take this, please?
Thanks
-Gustavo
Quoted 43 lines · Gustavo A. R. Silva
-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:
drivers/gpu/drm/nouveau/nvif/fifo.c:29:42: 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 <[email protected]>---
Changes in v3:
- Use the newTRAILING_OVERLAP()helper.Changes in v2:
- Adjust heap allocation.drivers/gpu/drm/nouveau/nvif/fifo.c | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-)drivers/gpu/drm/nouveau/nvif/fifo.c +2
-3@@ -25,13 +25,12 @@ static int nvif_fifo_runlists(struct nvif_device *device) {struct nvif_object *object = &device->object; -struct { -struct nv_device_info_v1 m; + TRAILING_OVERLAP(struct nv_device_info_v1, m, data, struct {struct nv_device_info_v1_data runlists;struct nv_device_info_v1_data runlist[64 ]; } v; - } *a; + ) *a;int ret, i;if (device->runlist)
Quoted 1 line · Gustavo A. R. Silva
Friendly ping: who can take this, please?
For some reason this patch wasn't tagged for applying in my inbox -- seems like it slipped through.
I was about to pick it up, but recognized just in time that Kees already took it through his hardening tree.
Sorry for the delay; thanks Kees for picking it up. Even though already applied, please consider this patch:
Thanks,
Danilo
Quoted 7 lines · Danilo Krummrich
Quoted 1 line · Gustavo A. R. Silva
Friendly ping: who can take this, please?
For some reason this patch wasn't tagged for applying in my inbox -- seems like it slipped through.
I was about to pick it up, but recognized just in time that Kees already took it through his hardening tree.
Ah great!
Quoted 4 lines
Sorry for the delay; thanks Kees for picking it up. Even though already applied, please consider this patch:
Acked-by Danilo Krummrich <[email protected]>
Thanks! I had figured it was slipping through the cracks so I snagged it. I'll add your Ack. :) If you'd rather take it, just say the word and I can drop it from my tree.
-Kees
Signature · 1 line
Kees Cook
Quoted 11 lines · Kees Cook
Quoted 7 lines · Danilo Krummrich
Quoted 1 line · Gustavo A. R. Silva
Friendly ping: who can take this, please?
For some reason this patch wasn't tagged for applying in my inbox -- seems like it slipped through.
I was about to pick it up, but recognized just in time that Kees already took it through his hardening tree.
Ah great!
Quoted 8 lines
Quoted 4 lines
Sorry for the delay; thanks Kees for picking it up. Even though already applied, please consider this patch:
Acked-by Danilo Krummrich <[email protected]>Thanks! I had figured it was slipping through the cracks so I snagged it. I'll add your Ack. :) If you'd rather take it, just say the word and I can drop it from my tree.
Thank you both!
-Gustavo
Kees Cook
AppliedQuoted 8 lines · Gustavo A. R. Silva
-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:
drivers/gpu/drm/nouveau/nvif/fifo.c:29:42: warning: structure containing a flexible array member is not at the end of another structure [-Wflex-array-member-not-at-end][...]
Applied to for-next/hardening, thanks!
[1/1] drm/nouveau: fifo: Avoid -Wflex-array-member-not-at-end warning
https://git.kernel.org/kees/c/2d4909bae919
Take care,
Signature · 1 line
Kees Cook