public inbox for linux-kernel@vger.kernel.org
 help / color / mirror / Atom feed
* [PATCH v3] staging: sm750fb: constify fix_id array
@ 2026-04-01 11:03 Hungyu Lin
  2026-04-01 11:18 ` Greg Kroah-Hartman
  0 siblings, 1 reply; 4+ messages in thread
From: Hungyu Lin @ 2026-04-01 11:03 UTC (permalink / raw)
  To: Sudip Mukherjee, Teddy Wang, Greg Kroah-Hartman
  Cc: linux-fbdev, linux-staging, linux-kernel, Hungyu Lin

Make the static fix_id array const-qualified so it can be placed
in read-only memory.

Signed-off-by: Hungyu Lin <dennylin0707@gmail.com>

---
Changes in v3:
- Drop g_fbmode change as it is modified at runtime.
- Resend as a new thread as requested.
---
 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 9a42a08c8..f7b5b22f1 100644
--- a/drivers/staging/sm750fb/sm750.c
+++ b/drivers/staging/sm750fb/sm750.c
@@ -728,7 +728,7 @@ static int lynxfb_set_fbinfo(struct fb_info *info, int index)
 		lynx750_ext, NULL, vesa_modes,
 	};
 	int cdb[] = {ARRAY_SIZE(lynx750_ext), 0, VESA_MODEDB_SIZE};
-	static const char *fix_id[2] = {
+	static const char * const fix_id[2] = {
 		"sm750_fb1", "sm750_fb2",
 	};
 
-- 
2.34.1


^ permalink raw reply related	[flat|nested] 4+ messages in thread

* Re: [PATCH v3] staging: sm750fb: constify fix_id array
  2026-04-01 11:03 [PATCH v3] staging: sm750fb: constify fix_id array Hungyu Lin
@ 2026-04-01 11:18 ` Greg Kroah-Hartman
  2026-04-01 11:38   ` Greg Kroah-Hartman
  0 siblings, 1 reply; 4+ messages in thread
From: Greg Kroah-Hartman @ 2026-04-01 11:18 UTC (permalink / raw)
  To: Hungyu Lin
  Cc: Sudip Mukherjee, Teddy Wang, linux-fbdev, linux-staging,
	linux-kernel

On Wed, Apr 01, 2026 at 11:03:33AM +0000, Hungyu Lin wrote:
> Make the static fix_id array const-qualified so it can be placed
> in read-only memory.
> 
> Signed-off-by: Hungyu Lin <dennylin0707@gmail.com>
> 
> ---
> Changes in v3:
> - Drop g_fbmode change as it is modified at runtime.
> - Resend as a new thread as requested.
> ---
>  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 9a42a08c8..f7b5b22f1 100644
> --- a/drivers/staging/sm750fb/sm750.c
> +++ b/drivers/staging/sm750fb/sm750.c
> @@ -728,7 +728,7 @@ static int lynxfb_set_fbinfo(struct fb_info *info, int index)
>  		lynx750_ext, NULL, vesa_modes,
>  	};
>  	int cdb[] = {ARRAY_SIZE(lynx750_ext), 0, VESA_MODEDB_SIZE};
> -	static const char *fix_id[2] = {
> +	static const char * const fix_id[2] = {

Wait, is this really right?

You have a const char * array, and now you make the pointer to that
const char * array const as well?  But that was static already, so what
exactly just got moved to read only memory?  What does the compiler do
differently here?  How was this tested?

I need a bit more "proof" that this change really is correct as the
const * and * to const and static stuff here always is confusing.  There
used to be some tool that would "unwind" this to figure it all out, but
I can't find that at the moment...

thanks,

greg k-h

^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: [PATCH v3] staging: sm750fb: constify fix_id array
  2026-04-01 11:18 ` Greg Kroah-Hartman
@ 2026-04-01 11:38   ` Greg Kroah-Hartman
  2026-04-01 12:03     ` Denny Lin
  0 siblings, 1 reply; 4+ messages in thread
From: Greg Kroah-Hartman @ 2026-04-01 11:38 UTC (permalink / raw)
  To: Hungyu Lin
  Cc: Sudip Mukherjee, Teddy Wang, linux-fbdev, linux-staging,
	linux-kernel

On Wed, Apr 01, 2026 at 01:18:15PM +0200, Greg Kroah-Hartman wrote:
> On Wed, Apr 01, 2026 at 11:03:33AM +0000, Hungyu Lin wrote:
> > Make the static fix_id array const-qualified so it can be placed
> > in read-only memory.
> > 
> > Signed-off-by: Hungyu Lin <dennylin0707@gmail.com>
> > 
> > ---
> > Changes in v3:
> > - Drop g_fbmode change as it is modified at runtime.
> > - Resend as a new thread as requested.
> > ---
> >  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 9a42a08c8..f7b5b22f1 100644
> > --- a/drivers/staging/sm750fb/sm750.c
> > +++ b/drivers/staging/sm750fb/sm750.c
> > @@ -728,7 +728,7 @@ static int lynxfb_set_fbinfo(struct fb_info *info, int index)
> >  		lynx750_ext, NULL, vesa_modes,
> >  	};
> >  	int cdb[] = {ARRAY_SIZE(lynx750_ext), 0, VESA_MODEDB_SIZE};
> > -	static const char *fix_id[2] = {
> > +	static const char * const fix_id[2] = {
> 
> Wait, is this really right?
> 
> You have a const char * array, and now you make the pointer to that
> const char * array const as well?  But that was static already, so what
> exactly just got moved to read only memory?  What does the compiler do
> differently here?  How was this tested?
> 
> I need a bit more "proof" that this change really is correct as the
> const * and * to const and static stuff here always is confusing.  There
> used to be some tool that would "unwind" this to figure it all out, but
> I can't find that at the moment...

Ah, found it:
	https://cdecl.org/

So:
	const char * fix_id[2]
is:
	declare fix_id as array 2 of pointer to const char

and:
	const char * const fix_id[2]
is:
	declare fix_id as array 2 of const pointer to const char

so I think that's right and your patch is ok?

But clarifiying what exactly got moved from where into where, would be
good to have done.  Please look at the output of the compiler for proof
of that and put that in the changelog text for the next version.

thanks,

greg k-h

^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: [PATCH v3] staging: sm750fb: constify fix_id array
  2026-04-01 11:38   ` Greg Kroah-Hartman
@ 2026-04-01 12:03     ` Denny Lin
  0 siblings, 0 replies; 4+ messages in thread
From: Denny Lin @ 2026-04-01 12:03 UTC (permalink / raw)
  To: Greg Kroah-Hartman
  Cc: Sudip Mukherjee, Teddy Wang, linux-fbdev, linux-staging,
	linux-kernel

Hi Greg,

Thanks for the clarification.

I've addressed this in v4 by clarifying the const semantics and adding
'nm' output showing the symbol is placed in a read-only section.

Thanks,
Hungyu

^ permalink raw reply	[flat|nested] 4+ messages in thread

end of thread, other threads:[~2026-04-01 12:03 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2026-04-01 11:03 [PATCH v3] staging: sm750fb: constify fix_id array Hungyu Lin
2026-04-01 11:18 ` Greg Kroah-Hartman
2026-04-01 11:38   ` Greg Kroah-Hartman
2026-04-01 12:03     ` Denny Lin

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox