diff mbox series

drm/modes: Make the whitelist more const

Message ID 20190906074614.30608-1-mripard@kernel.org (mailing list archive)
State New, archived
Headers show
Series drm/modes: Make the whitelist more const | expand

Commit Message

Maxime Ripard Sept. 6, 2019, 7:46 a.m. UTC
The commit 3764137906a5 ("drm/modes: Introduce a whitelist for the named
modes") introduced a whitelist in the named modes lookup code in order to
be a bit more robust.

However, even though the char pointers were made const, the data they were
pointing were not. Let's fix that.

Fixes: 3764137906a5 ("drm/modes: Introduce a whitelist for the named modes")
Suggested-by: Jani Nikula <jani.nikula@linux.intel.com>
Signed-off-by: Maxime Ripard <mripard@kernel.org>
---
 drivers/gpu/drm/drm_modes.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

Comments

Jani Nikula Sept. 6, 2019, 7:56 a.m. UTC | #1
On Fri, 06 Sep 2019, Maxime Ripard <mripard@kernel.org> wrote:
> The commit 3764137906a5 ("drm/modes: Introduce a whitelist for the named
> modes") introduced a whitelist in the named modes lookup code in order to
> be a bit more robust.
>
> However, even though the char pointers were made const, the data they were
> pointing were not. Let's fix that.

Or rather, the char pointers were const, and they pointed at const
string literals, but the array of pointers itself was not const.

Reviewed-by: Jani Nikula <jani.nikula@intel.com>

> Fixes: 3764137906a5 ("drm/modes: Introduce a whitelist for the named modes")
> Suggested-by: Jani Nikula <jani.nikula@linux.intel.com>
> Signed-off-by: Maxime Ripard <mripard@kernel.org>
> ---
>  drivers/gpu/drm/drm_modes.c | 2 +-
>  1 file changed, 1 insertion(+), 1 deletion(-)
>
> diff --git a/drivers/gpu/drm/drm_modes.c b/drivers/gpu/drm/drm_modes.c
> index 858c67281518..88232698d7a0 100644
> --- a/drivers/gpu/drm/drm_modes.c
> +++ b/drivers/gpu/drm/drm_modes.c
> @@ -1677,7 +1677,7 @@ static int drm_mode_parse_cmdline_options(char *str, size_t len,
>  	return 0;
>  }
>  
> -static const char *drm_named_modes_whitelist[] = {
> +static const char * const drm_named_modes_whitelist[] = {
>  	"NTSC",
>  	"PAL",
>  };
Maxime Ripard Sept. 6, 2019, 4:13 p.m. UTC | #2
On Fri, Sep 06, 2019 at 10:56:10AM +0300, Jani Nikula wrote:
> On Fri, 06 Sep 2019, Maxime Ripard <mripard@kernel.org> wrote:
> > The commit 3764137906a5 ("drm/modes: Introduce a whitelist for the named
> > modes") introduced a whitelist in the named modes lookup code in order to
> > be a bit more robust.
> >
> > However, even though the char pointers were made const, the data they were
> > pointing were not. Let's fix that.
>
> Or rather, the char pointers were const, and they pointed at const
> string literals, but the array of pointers itself was not const.

Right, I'm always confused with const in this case. I've updated the
commit log, thanks!
Maxime

--
Maxime Ripard, Bootlin
Embedded Linux and Kernel engineering
https://bootlin.com
diff mbox series

Patch

diff --git a/drivers/gpu/drm/drm_modes.c b/drivers/gpu/drm/drm_modes.c
index 858c67281518..88232698d7a0 100644
--- a/drivers/gpu/drm/drm_modes.c
+++ b/drivers/gpu/drm/drm_modes.c
@@ -1677,7 +1677,7 @@  static int drm_mode_parse_cmdline_options(char *str, size_t len,
 	return 0;
 }
 
-static const char *drm_named_modes_whitelist[] = {
+static const char * const drm_named_modes_whitelist[] = {
 	"NTSC",
 	"PAL",
 };