Skip to contentSkip to conversation

i915, debugfs: Fix uninitialized warning

PATCH Applied Borislav Petkov 4 participants 6 messages Nov 21, 2013 – Nov 23, 2013

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

PATCH 1/1 i915, debugfs: Fix uninitialized warning

From: Borislav Petkov <[email protected]>

gcc complains that:

drivers/gpu/drm/i915/i915_debugfs.c: In function ‘display_crc_ctl_write’:
drivers/gpu/drm/i915/i915_debugfs.c:2393:2: warning: ‘val’ may be used uninitialized in this function [-Wuninitialized] drivers/gpu/drm/i915/i915_debugfs.c:2350:6: note: ‘val’ was declared here

but it can't see that we're going to use val only in the success case. So shut it up.

---
 drivers/gpu/drm/i915/i915_debugfs.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/gpu/drm/i915/i915_debugfs.c +1 -1
index 6ed45a984230..1191aa47adc9 100644
@@ -2347,7 +2347,7 @@ static int pipe_crc_set_source(struct drm_device *dev, enum pipe pipe,
 {
 	struct drm_i915_private *dev_priv = dev->dev_private;
 	struct intel_pipe_crc *pipe_crc = &dev_priv->pipe_crc[pipe];
-	u32 val;
+	u32 val = 0; /* shut up gcc */
 	int ret;
 
 	if (pipe_crc->source == source)
Signature · 1 line
1.8.4
#1 lore raw
Quoted 25 lines · Borislav Petkov

From: Borislav Petkov <[email protected]>

gcc complains that:

drivers/gpu/drm/i915/i915_debugfs.c: In function ‘display_crc_ctl_write’:
drivers/gpu/drm/i915/i915_debugfs.c:2393:2: warning: ‘val’ may be used uninitialized in this function [-Wuninitialized] drivers/gpu/drm/i915/i915_debugfs.c:2350:6: note: ‘val’ was declared here

but it can't see that we're going to use val only in the success case. So shut it up.

---
 drivers/gpu/drm/i915/i915_debugfs.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/gpu/drm/i915/i915_debugfs.c +0 -0
index 6ed45a984230..1191aa47adc9 100644

drivers/gpu/drm/i915/i915_debugfs.c static int pipe_crc_set_source(struct drm_device *dev, enum pipe pipe, · line 2350

Quoted 5 lines
drivers/gpu/drm/i915/i915_debugfs.c +1 -1
@@ -2347,7 +2347,7 @@ static int pipe_crc_set_source(struct drm_device *dev, enum pipe pipe,
 {
        struct drm_i915_private *dev_priv = dev->dev_private;
        struct intel_pipe_crc *pipe_crc = &dev_priv->pipe_crc[pipe];
-       u32 val;
+       u32 val = 0; /* shut up gcc */

Wouldn't it be better to use uninitialized_var() here?

Quoted 11 lines
drivers/gpu/drm/i915/i915_debugfs.c +0 -1
        int ret;
 
        if (pipe_crc->source == source)
--

1.8.4

--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in the body of a message to [email protected]
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/

Signature · 2 lines
Thanks,
//richard
#2 lore raw
Quoted 4 lines · Richard Weinberger
Quoted 4 lines
drivers/gpu/drm/i915/i915_debugfs.c +0 -0
index 6ed45a984230..1191aa47adc9 100644
Quoted 8 lines

drivers/gpu/drm/i915/i915_debugfs.c static int pipe_crc_set_source(struct drm_device *dev, enum pipe pipe, · line 2350

Quoted 6 lines
drivers/gpu/drm/i915/i915_debugfs.c +1 -1
@@ -2347,7 +2347,7 @@ static int pipe_crc_set_source(struct drm_device *dev, enum pipe pipe,
 {
        struct drm_i915_private *dev_priv = dev->dev_private;
        struct intel_pipe_crc *pipe_crc = &dev_priv->pipe_crc[pipe];
-       u32 val;
+       u32 val = 0; /* shut up gcc */

Wouldn't it be better to use uninitialized_var() here?

I remember Linus' rant about this macro so that's why I don't use it anymore.

In this specific case, it doesn't matter whichever we do so I'll let the maintainer make a wish :)

Signature · 5 lines
Regards/Gruss,
    Boris.

Sent from a fat crate under my desk. Formatting is fine.
--
#3 lore raw
Quoted 14 lines · Borislav Petkov
Quoted 4 lines · Richard Weinberger
Quoted 4 lines
drivers/gpu/drm/i915/i915_debugfs.c +0 -0
index 6ed45a984230..1191aa47adc9 100644
Quoted 8 lines

drivers/gpu/drm/i915/i915_debugfs.c static int pipe_crc_set_source(struct drm_device *dev, enum pipe pipe, · line 2350

Quoted 6 lines
drivers/gpu/drm/i915/i915_debugfs.c +1 -1
@@ -2347,7 +2347,7 @@ static int pipe_crc_set_source(struct drm_device *dev, enum pipe pipe,
 {
        struct drm_i915_private *dev_priv = dev->dev_private;
        struct intel_pipe_crc *pipe_crc = &dev_priv->pipe_crc[pipe];
-       u32 val;
+       u32 val = 0; /* shut up gcc */

Wouldn't it be better to use uninitialized_var() here?

Quoted 5 lines

I remember Linus' rant about this macro so that's why I don't use it anymore.

In this specific case, it doesn't matter whichever we do so I'll let the maintainer make a wish :)

IIRC this warning was there for me too on gcc 4.6, but it disappeared on gcc 4.7, which is why I decided not to send a patch for it.

Signature · 2 lines
Ville Syrjälä
Intel OTC
#4 lore raw
Quoted 2 lines · Ville Syrjälä

IIRC this warning was there for me too on gcc 4.6, but it disappeared on gcc 4.7, which is why I decided not to send a patch for it.

A disappearing and reappearing warning happened to me recently too. I attributed that to compiler upgrades. With this it will shut up for good. :-)

Signature · 9 lines
Regards/Gruss,
    Boris.

Sent from a fat crate under my desk. Formatting is fine.
--
_______________________________________________
Intel-gfx mailing list
[email protected]
http://lists.freedesktop.org/mailman/listinfo/intel-gfx
#5 lore raw
In reply to Borislav Petkov
Quoted 8 lines · Borislav Petkov

From: Borislav Petkov <[email protected]>

gcc complains that:

drivers/gpu/drm/i915/i915_debugfs.c: In function ‘display_crc_ctl_write’:
drivers/gpu/drm/i915/i915_debugfs.c:2393:2: warning: ‘val’ may be used uninitialized in this function [-Wuninitialized] drivers/gpu/drm/i915/i915_debugfs.c:2350:6: note: ‘val’ was declared here

Quoted 8 lines

but it can't see that we're going to use val only in the success case. So shut it up.

Queued for -next, thanks for the patch.
-Daniel

Quoted 20 lines
---
 drivers/gpu/drm/i915/i915_debugfs.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/gpu/drm/i915/i915_debugfs.c +1 -1
index 6ed45a984230..1191aa47adc9 100644
@@ -2347,7 +2347,7 @@ static int pipe_crc_set_source(struct drm_device *dev, enum pipe pipe,
 {
 	struct drm_i915_private *dev_priv = dev->dev_private;
 	struct intel_pipe_crc *pipe_crc = &dev_priv->pipe_crc[pipe];
-	u32 val;
+	u32 val = 0; /* shut up gcc */
 	int ret;
 
 	if (pipe_crc->source == source)
Signature · 1 line
1.8.4
Signature · 7 lines
Daniel Vetter
Software Engineer, Intel Corporation
+41 (0) 79 365 57 48 - http://blog.ffwll.ch
_______________________________________________
Intel-gfx mailing list
[email protected]
http://lists.freedesktop.org/mailman/listinfo/intel-gfx