Skip to contentSkip to conversation

drm/i915: Fix some gcc warnings

PATCH In review [email protected] 3 participants 5 messages Aug 21, 2015 – Aug 26, 2015

Subsystems (2)
lore
Share & tools
lore
#0 lore raw

PATCH 1/3 drm/i915: Fix some gcc warnings

From: Ville Syrjälä <[email protected]>

Simple one:
drivers/gpu/drm/i915/i915_debugfs.c:2449:57: warning: Using plain integer as NULL pointer

And something a bit more peculiar:
drivers/gpu/drm/i915/i915_debugfs.c:4953:18: warning: Variable length array is used. drivers/gpu/drm/i915/i915_debugfs.c:4953:32: warning: Variable length array is used.

We pass a 'const int' as the array size which results in the warning, dropping the const gets rid of the warning. Weird, but I think getting rid of the warnings is better than holding on to the const.

---
 drivers/gpu/drm/i915/i915_debugfs.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)
drivers/gpu/drm/i915/i915_debugfs.c +2 -2
index 7a28de5..4088cb1 100644
@@ -2446,7 +2446,7 @@ static int i915_guc_info(struct seq_file *m, void *data)
 	struct drm_device *dev = node->minor->dev;
 	struct drm_i915_private *dev_priv = dev->dev_private;
 	struct intel_guc guc;
-	struct i915_guc_client client = { .client_obj = 0 };
+	struct i915_guc_client client = {};
 	struct intel_engine_cs *ring;
 	enum intel_ring_id i;
 	u64 total = 0;
@@ -4948,7 +4948,7 @@ static void cherryview_sseu_device_status(struct drm_device *dev,
 					  struct sseu_dev_status *stat)
 {
 	struct drm_i915_private *dev_priv = dev->dev_private;
-	const int ss_max = 2;
+	int ss_max = 2;
 	int ss;
 	u32 sig1[ss_max], sig2[ss_max];
 
Signature · 6 lines
2.4.6

_______________________________________________
Intel-gfx mailing list
[email protected]
http://lists.freedesktop.org/mailman/listinfo/intel-gfx
#1 lore raw

PATCH 2/3 drm/i915: Use ARRAY_SIZE() instead of hand rolling it

From: Ville Syrjälä <[email protected]>

A couple of hand rolled ARRAY_SIZE()s caught my eye. Get rid of them.

---
 drivers/gpu/drm/i915/intel_sdvo.c   | 2 +-
 drivers/gpu/drm/i915/intel_tv.c     | 2 +-
 drivers/gpu/drm/i915/intel_uncore.c | 3 +--
 3 files changed, 3 insertions(+), 4 deletions(-)
drivers/gpu/drm/i915/intel_sdvo.c +1 -1
index c98098e..25d74d2 100644
@@ -63,7 +63,7 @@ static const char *tv_format_names[] = {
 	"SECAM_60"
 };
 
-#define TV_FORMAT_NUM  (sizeof(tv_format_names) / sizeof(*tv_format_names))
+#define TV_FORMAT_NUM  ARRAY_SIZE(tv_format_names)
 
 struct intel_sdvo {
 	struct intel_encoder base;
drivers/gpu/drm/i915/intel_tv.c +1 -1
index 0568ae6..cbe39dc 100644
@@ -1291,7 +1291,7 @@ static void intel_tv_find_better_format(struct drm_connector *connector)
 		return;
 
 
-	for (i = 0; i < sizeof(tv_modes) / sizeof(*tv_modes); i++) {
+	for (i = 0; i < ARRAY_SIZE(tv_modes); i++) {
 		tv_mode = tv_modes + i;
 
 		if ((intel_tv->type == DRM_MODE_CONNECTOR_Component) ==
drivers/gpu/drm/i915/intel_uncore.c +1 -2
index 9d3c2e4..ad4e421 100644
@@ -52,8 +52,7 @@ static const char * const forcewake_domain_names[] = {
 const char *
 intel_uncore_forcewake_domain_to_str(const enum forcewake_domain_id id)
 {
-	BUILD_BUG_ON((sizeof(forcewake_domain_names)/sizeof(const char *)) !=
-		     FW_DOMAIN_ID_COUNT);
+	BUILD_BUG_ON(ARRAY_SIZE(forcewake_domain_names) != FW_DOMAIN_ID_COUNT);
 
 	if (id >= 0 && id < FW_DOMAIN_ID_COUNT)
 		return forcewake_domain_names[id];
Signature · 6 lines
2.4.6

_______________________________________________
Intel-gfx mailing list
[email protected]
http://lists.freedesktop.org/mailman/listinfo/intel-gfx
#2 lore raw

PATCH 3/3 drm/i915: Make some string arrays const

In reply to [email protected]

From: Ville Syrjälä <[email protected]>

Most of our char* arrays are markes as const already, but a few slipped through the cracks. Fix it.

---
 drivers/gpu/drm/i915/intel_sdvo.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)
drivers/gpu/drm/i915/intel_sdvo.c +2 -2
index 25d74d2..ca3dd7c 100644
@@ -53,7 +53,7 @@
 #define IS_DIGITAL(c) (c->output_flag & (SDVO_TMDS_MASK | SDVO_LVDS_MASK))
 
 
-static const char *tv_format_names[] = {
+static const char * const tv_format_names[] = {
 	"NTSC_M"   , "NTSC_J"  , "NTSC_443",
 	"PAL_B"    , "PAL_D"   , "PAL_G"   ,
 	"PAL_H"    , "PAL_I"   , "PAL_M"   ,
@@ -452,7 +452,7 @@ static void intel_sdvo_debug_write(struct intel_sdvo *intel_sdvo, u8 cmd,
 	DRM_DEBUG_KMS("%s: W: %02X %s\n", SDVO_NAME(intel_sdvo), cmd, buffer);
 }
 
-static const char *cmd_status_names[] = {
+static const char * const cmd_status_names[] = {
 	"Power on",
 	"Success",
 	"Not supported",
Signature · 6 lines
2.4.6

_______________________________________________
Intel-gfx mailing list
[email protected]
http://lists.freedesktop.org/mailman/listinfo/intel-gfx
#3 lore raw

Re: [PATCH 3/3] drm/i915: Make some string arrays const

Quoted 6 lines · On Fri, Aug 21, 2015 at 08:45:29PM +0300, [email protected] wrote:

From: Ville Syrjälä <[email protected]>

Most of our char* arrays are markes as const already, but a few slipped through the cracks. Fix it.

All 3, Reviewed-by: Chris Wilson <[email protected]> -Chris

Signature · 5 lines
Chris Wilson, Intel Open Source Technology Centre
_______________________________________________
Intel-gfx mailing list
[email protected]
http://lists.freedesktop.org/mailman/listinfo/intel-gfx
#4 lore raw

Re: [PATCH 3/3] drm/i915: Make some string arrays const

Quoted 9 lines · Chris Wilson
Quoted 6 lines · On Fri, Aug 21, 2015 at 08:45:29PM +0300, [email protected] wrote:

From: Ville Syrjälä <[email protected]>

Most of our char* arrays are markes as const already, but a few slipped through the cracks. Fix it.

All 3, Reviewed-by: Chris Wilson <[email protected]>

All merged to dinq, thanks.
-Daniel

Signature · 7 lines
Daniel Vetter
Software Engineer, Intel Corporation
http://blog.ffwll.ch
_______________________________________________
Intel-gfx mailing list
[email protected]
http://lists.freedesktop.org/mailman/listinfo/intel-gfx