Skip to contentSkip to conversation

alpha: Replace one-element array with flexible array member

PATCH RESEND Superseded Thorsten Blum 2 participants 3 messages Dec 20, 2024 – Dec 23, 2024 Alpha port

lore
Share & tools
lore
#0 lore raw

PATCH RESEND 1/1 alpha: Replace one-element array with flexible array member

Replace the deprecated one-element array with a modern flexible array member in the struct crb_struct.

---
 arch/alpha/include/asm/hwrpb.h | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
arch/alpha/include/asm/hwrpb.h +1 -1
index fc76f36265ad..db831cf8de10 100644
@@ -135,7 +135,7 @@ struct crb_struct {
 	/* virtual->physical map */
 	unsigned long map_entries;
 	unsigned long map_pages;
-	struct vf_map_struct map[1];
+	struct vf_map_struct map[];
 };
 
 struct memclust_struct {
Signature · 1 line
2.47.1
Reviewed-by on v1 1/1
#1 lore raw
Quoted 13 lines · Thorsten Blum

Replace the deprecated one-element array with a modern flexible array member in the struct crb_struct.

---
 arch/alpha/include/asm/hwrpb.h | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
arch/alpha/include/asm/hwrpb.h +0 -0
index fc76f36265ad..db831cf8de10 100644

arch/alpha/include/asm/hwrpb.h struct crb_struct { · line 139

Quoted 6 lines
arch/alpha/include/asm/hwrpb.h +1 -1
@@ -135,7 +135,7 @@ struct crb_struct {
 	/* virtual->physical map */
 	unsigned long map_entries;
 	unsigned long map_pages;
-	struct vf_map_struct map[1];
+	struct vf_map_struct map[];
 };

Seems like this could use __counted_by(map_entries) as well?

...

                for (i = 0; i < crb->map_entries; ++i) {
                        unsigned long pfn = crb->map[i].pa >> PAGE_SHIFT;

...

But yes, this appears to be used as a flexible array and should be adjusted. I see no sizeof() uses that would change. So:

-Kees

Signature · 1 line
Kees Cook
#2 lore raw
Quoted 8 lines · Kees Cook
Quoted 5 lines · Thorsten Blum

Replace the deprecated one-element array with a modern flexible array member in the struct crb_struct.

---

Seems like this could use __counted_by(map_entries) as well?

Yes, but alpha doesn't seem to support __counted_by() yet. Does it still make sense to add it then?

Thanks,
Thorsten