Skip to contentSkip to conversation

staging: sm750fb: mark g_fbmode as const

PATCH In review Iñaki Sobera Sotomayor 2 participants 3 messages Sep 22 – Sep 23

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

PATCH 1/1 staging: sm750fb: mark g_fbmode as const

The g_fbmode array of pointers is only used during module initialization to parse display options and is never modified. Marking both the pointers and the array const allows the compiler to place it in .rodata, which avoids accidental modifications and cleans up a checkpatch warning.

---
 drivers/staging/sm750fb/sm750.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/staging/sm750fb/sm750.c +1 -1
index 8b93bfeb2..c3f391cdd 100644
@@ -12,7 +12,7 @@
 static int g_hwcursor = 1;
 static int g_noaccel __ro_after_init;
 static int g_nomtrr __ro_after_init;
-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 __ro_after_init;
Signature · 1 line
2.55.0
#1 lore raw
Quoted 15 lines · Iñaki Sobera Sotomayor

The g_fbmode array of pointers is only used during module initialization to parse display options and is never modified. Marking both the pointers and the array const allows the compiler to place it in .rodata, which avoids accidental modifications and cleans up a checkpatch warning.

---
  drivers/staging/sm750fb/sm750.c | 2 +-
  1 file changed, 1 insertion(+), 1 deletion(-)
drivers/staging/sm750fb/sm750.c +0 -0
index 8b93bfeb2..c3f391cdd 100644

drivers/staging/sm750fb/sm750.c line 18

Quoted 8 lines
drivers/staging/sm750fb/sm750.c +1 -1
@@ -12,7 +12,7 @@
  static int g_hwcursor = 1;
  static int g_noaccel __ro_after_init;
  static int g_nomtrr __ro_after_init;
-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 __ro_after_init;

Did you compile this patch? While SM750 module is enabled?

Regards,
Ahmet Sezgin Duran

#2 lore raw

Hi Ahmet,

Thank you for pointing this out. You are completely right.

I mistakenly missed that g_fbmode elements are assigned in sm750.c (lines 762, 764, 872, 876) when handling display options, so making the array itself const breaks compilation when CONFIG_FB_SM750 is enabled.

Please disregard this patch. Apologies for the noise.

Best regards,
Iñaki Sobera Sotomayor

Quoted 30 lines · Ahmet Sezgin Duran
Quoted 15 lines · Iñaki Sobera Sotomayor

The g_fbmode array of pointers is only used during module initialization to parse display options and is never modified. Marking both the pointers and the array const allows the compiler to place it in .rodata, which avoids accidental modifications and cleans up a checkpatch warning.

---
  drivers/staging/sm750fb/sm750.c | 2 +-
  1 file changed, 1 insertion(+), 1 deletion(-)
drivers/staging/sm750fb/sm750.c +0 -0
index 8b93bfeb2..c3f391cdd 100644

drivers/staging/sm750fb/sm750.c line 18

Quoted 8 lines
drivers/staging/sm750fb/sm750.c +1 -1
@@ -12,7 +12,7 @@
  static int g_hwcursor = 1;
  static int g_noaccel __ro_after_init;
  static int g_nomtrr __ro_after_init;
-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 __ro_after_init;

Did you compile this patch? While SM750 module is enabled?

Regards,
Ahmet Sezgin Duran