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

Manish Kumar posted 1 patch 3 months, 1 week ago
drivers/staging/sm750fb/sm750.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
[PATCH] staging: sm750fb: make g_fbmode[] a read-only pointer array
Posted by Manish Kumar 3 months, 1 week ago
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.

Signed-off-by: Manish Kumar <manish1588@gmail.com>
---
 drivers/staging/sm750fb/sm750.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/drivers/staging/sm750fb/sm750.c b/drivers/staging/sm750fb/sm750.c
index 1d929aca399c..e77ad73f0db1 100644
--- a/drivers/staging/sm750fb/sm750.c
+++ b/drivers/staging/sm750fb/sm750.c
@@ -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;
-- 
2.43.0
Re: [PATCH] staging: sm750fb: make g_fbmode[] a read-only pointer array
Posted by Dan Carpenter 3 months, 1 week ago
On Fri, Jun 27, 2025 at 11:01:20PM +0530, Manish Kumar wrote:
> 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.
> 
> Signed-off-by: Manish Kumar <manish1588@gmail.com>

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

regards,
dan carpenter
Re: [PATCH] staging: sm750fb: make g_fbmode[] a read-only pointer array
Posted by Manish Kumar 3 months, 1 week ago
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