[igt-dev] [PATCH i-g-t 1/2] lib/kms: Constify some string arrays

Ville Syrjala ville.syrjala at linux.intel.com
Fri Mar 16 18:16:48 UTC 2018


From: Ville Syrjälä <ville.syrjala at linux.intel.com>

Make a bunch of string arrays const.

Signed-off-by: Ville Syrjälä <ville.syrjala at linux.intel.com>
---
 lib/igt_kms.c | 18 ++++++++++--------
 lib/igt_kms.h |  6 +++---
 2 files changed, 13 insertions(+), 11 deletions(-)

diff --git a/lib/igt_kms.c b/lib/igt_kms.c
index cf6389f2474c..59f97cb4c5a0 100644
--- a/lib/igt_kms.c
+++ b/lib/igt_kms.c
@@ -158,7 +158,7 @@ const unsigned char* igt_kms_get_base_edid(void)
 #define EDID_NAME alt_edid
 #include "igt_edid_template.h"
 
-const char *igt_plane_prop_names[IGT_NUM_PLANE_PROPS] = {
+const char * const igt_plane_prop_names[IGT_NUM_PLANE_PROPS] = {
 	"SRC_X",
 	"SRC_Y",
 	"SRC_W",
@@ -175,7 +175,7 @@ const char *igt_plane_prop_names[IGT_NUM_PLANE_PROPS] = {
 	"IN_FORMATS",
 };
 
-const char *igt_crtc_prop_names[IGT_NUM_CRTC_PROPS] = {
+const char * const igt_crtc_prop_names[IGT_NUM_CRTC_PROPS] = {
 	"background_color",
 	"CTM",
 	"GAMMA_LUT",
@@ -187,7 +187,7 @@ const char *igt_crtc_prop_names[IGT_NUM_CRTC_PROPS] = {
 	"OUT_FENCE_PTR"
 };
 
-const char *igt_connector_prop_names[IGT_NUM_CONNECTOR_PROPS] = {
+const char * const igt_connector_prop_names[IGT_NUM_CONNECTOR_PROPS] = {
 	"scaling mode",
 	"CRTC_ID",
 	"DPMS",
@@ -200,7 +200,7 @@ const char *igt_connector_prop_names[IGT_NUM_CONNECTOR_PROPS] = {
  */
 static void
 igt_fill_plane_props(igt_display_t *display, igt_plane_t *plane,
-		     int num_props, const char **prop_names)
+		     int num_props, const char * const prop_names[])
 {
 	drmModeObjectPropertiesPtr props;
 	int i, j, fd;
@@ -234,7 +234,7 @@ igt_fill_plane_props(igt_display_t *display, igt_plane_t *plane,
  */
 static void
 igt_atomic_fill_connector_props(igt_display_t *display, igt_output_t *output,
-			int num_connector_props, const char **conn_prop_names)
+			int num_connector_props, const char * const conn_prop_names[])
 {
 	drmModeObjectPropertiesPtr props;
 	int i, j, fd;
@@ -264,7 +264,7 @@ igt_atomic_fill_connector_props(igt_display_t *display, igt_output_t *output,
 
 static void
 igt_fill_pipe_props(igt_display_t *display, igt_pipe_t *pipe,
-		    int num_crtc_props, const char **crtc_prop_names)
+		    int num_crtc_props, const char * const crtc_prop_names[])
 {
 	drmModeObjectPropertiesPtr props;
 	int i, j, fd;
@@ -324,7 +324,9 @@ const unsigned char* igt_kms_get_alt_edid(void)
  */
 const char *kmstest_pipe_name(enum pipe pipe)
 {
-	const char *str[] = { "A", "B", "C", "D", "E", "F"};
+	static const char * const str[] = {
+		"A", "B", "C", "D", "E", "F",
+	};
 
 	if (pipe == PIPE_NONE)
 		return "None";
@@ -367,7 +369,7 @@ int kmstest_pipe_to_index(char pipe)
  */
 const char *kmstest_plane_type_name(int plane_type)
 {
-	static const char *names[] = {
+	static const char * const names[] = {
 		[DRM_PLANE_TYPE_OVERLAY] = "overlay",
 		[DRM_PLANE_TYPE_PRIMARY] = "primary",
 		[DRM_PLANE_TYPE_CURSOR] = "cursor",
diff --git a/lib/igt_kms.h b/lib/igt_kms.h
index 1ea3be991509..194f62fa8347 100644
--- a/lib/igt_kms.h
+++ b/lib/igt_kms.h
@@ -113,7 +113,7 @@ enum igt_atomic_crtc_properties {
  * igt_crtc_prop_names contains a list of crtc property names,
  * as indexed by the igt_atomic_crtc_properties enum.
  */
-extern const char *igt_crtc_prop_names[];
+extern const char * const igt_crtc_prop_names[];
 
 enum igt_atomic_connector_properties {
        IGT_CONNECTOR_SCALING_MODE = 0,
@@ -129,7 +129,7 @@ enum igt_atomic_connector_properties {
  * igt_connector_prop_names contains a list of crtc property names,
  * as indexed by the igt_atomic_connector_properties enum.
  */
-extern const char *igt_connector_prop_names[];
+extern const char * const igt_connector_prop_names[];
 
 struct kmstest_connector_config {
 	drmModeCrtc *crtc;
@@ -272,7 +272,7 @@ enum igt_atomic_plane_properties {
  * igt_plane_prop_names contains a list of crtc property names,
  * as indexed by the igt_atomic_plane_properties enum.
  */
-extern const char *igt_plane_prop_names[];
+extern const char * const igt_plane_prop_names[];
 
 typedef struct igt_display igt_display_t;
 typedef struct igt_pipe igt_pipe_t;
-- 
2.16.1



More information about the igt-dev mailing list