Skip to contentSkip to conversation

staging: sm750fb: make g_fbmode[] a read-only pointer array

PATCH In review Manish Kumar 2 participants 4 messages Jun 27, 2025 1 message not in the archive

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

PATCH 1/1 staging: sm750fb: make g_fbmode[] a read-only pointer array

This fixes a checkpatch warning by changing the declaration of g_fbmode[] from 'static const char *' to 'static const char * const', making both the string contents and the array elements read-only.

---
 drivers/staging/sm750fb/sm750.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/staging/sm750fb/sm750.c +1 -1
index 1d929aca399c..e77ad73f0db1 100644
@@ -33,7 +33,7 @@
 static int g_hwcursor = 1;
 static int g_noaccel;
 static int g_nomtrr;
-static const char *g_fbmode[] = {NULL, NULL};
+static const char * const g_fbmode[] = {NULL, NULL};
 static const char *g_def_fbmode = "1024x768-32@60";
 static char *g_settings;
 static int g_dualview;
Signature · 1 line
2.43.0
#1 lore raw
Quoted 5 lines · Manish Kumar

This fixes a checkpatch warning by changing the declaration of g_fbmode[] from 'static const char *' to 'static const char * const', making both the string contents and the array elements read-only.

This breaks the build. Now we can't change the pointer to anythine else except NULL.

regards,
dan carpenter

#2 lore raw

Hi Dan,

Thank you for the review. You're absolutely right — changing the array to const breaks the assignments that follow.

I've reverted this and will send a new cleanup patch later.

Regards,
Manish

A message that is not in the archive (sent off-list or not yet received): CAAoxDjcYwV9JhRLGJ+opJLEU5j4RHYUt4XZ8E4R9DgF2VqZD8Q@mail.gmail.com

#4 lore raw
Quoted 9 lines · Manish Kumar

Hi Dan,

Thank you for the review and pointing out the issue. You're right — changing the array to const makes it unmodifiable, which breaks the assignment logic in the driver.

I've reverted the change and will look for another checkpatch warning to address for the next version of the patch.

Awesome. Thanks.

regards,
dan carpenter