Skip to contentSkip to conversation

drm/nouveau: fifo: Avoid -Wflex-array-member-not-at-end warning

PATCH Applied Gustavo A. R. Silva 5 participants 7 messages Aug 14, 2025 – Jan 7

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

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
index a463289962b2..b0ab80995d98 100644
@@ -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
Reviewed-by on v3 1/1
#1 lore raw

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.

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 new TRAILING_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
index a463289962b2..b0ab80995d98 100644
@@ -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

#2 lore raw
In reply to Gustavo A. R. Silva

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.

---
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
index a463289962b2..b0ab80995d98 100644
@@ -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)
maintainer Acked-by
#3 lore raw
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

#4 lore raw
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:

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
#5 lore raw
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:

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

Applied
#6 lore raw
In reply to Gustavo A. R. Silva
Quoted 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