Skip to contentSkip to conversation

drm/modes: Make the whitelist more const

PATCH In review Maxime Ripard 2 participants 3 messages Sep 6, 2019

Subsystems (2)
lore
Share & tools
lore

Maxime Ripard

author maintainer
#0 lore raw

PATCH 1/1 drm/modes: Make the whitelist more const

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")
---
 drivers/gpu/drm/drm_modes.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/gpu/drm/drm_modes.c +1 -1
index 858c67281518..88232698d7a0 100644
@@ -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",
 };
Signature · 6 lines
2.21.0

_______________________________________________
dri-devel mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/dri-devel
Reviewed-by on v1 1/1
#1 lore raw
Quoted 6 lines · Maxime Ripard

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.

Quoted 20 lines
Fixes 3764137906a5 ("drm/modes: Introduce a whitelist for the named modes")
---
 drivers/gpu/drm/drm_modes.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/gpu/drm/drm_modes.c +1 -1
index 858c67281518..88232698d7a0 100644
@@ -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",
 };
Signature · 5 lines
Jani Nikula, Intel Open Source Graphics Center
_______________________________________________
dri-devel mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/dri-devel
author maintainer
#2 lore raw
Quoted 10 lines · Jani Nikula
Quoted 6 lines · Maxime Ripard

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

_______________________________________________
dri-devel mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/dri-devel