linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH 1/1] drm/i915/dsi: silence a warning about uninitialized return value
@ 2016-09-04 18:58 Nicolas Iooss
  2016-09-06 10:21 ` [Intel-gfx] " Dave Gordon
  2016-10-23 16:55 ` Nicolas Iooss
  0 siblings, 2 replies; 9+ messages in thread
From: Nicolas Iooss @ 2016-09-04 18:58 UTC (permalink / raw)
  To: Daniel Vetter, Jani Nikula, intel-gfx, dri-devel
  Cc: linux-kernel, Nicolas Iooss

When building the kernel with clang and some warning flags, the compiler
reports that the return value of dcs_get_backlight() may be
uninitialized:

    drivers/gpu/drm/i915/intel_dsi_dcs_backlight.c:53:2: error: variable
    'data' is used uninitialized whenever 'for' loop exits because its
    condition is false [-Werror,-Wsometimes-uninitialized]
            for_each_dsi_port(port, intel_dsi->dcs_backlight_ports) {
            ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
    drivers/gpu/drm/i915/intel_dsi.h:126:49: note: expanded from macro
    'for_each_dsi_port'
    #define for_each_dsi_port(__port, __ports_mask)
                                for_each_port_masked(__port, __ports_mask)
                                ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
    drivers/gpu/drm/i915/i915_drv.h:322:26: note: expanded from macro
    'for_each_port_masked'
        for ((__port) = PORT_A; (__port) < I915_MAX_PORTS; (__port)++)  \
                                ^~~~~~~~~~~~~~~~~~~~~~~~~
    drivers/gpu/drm/i915/intel_dsi_dcs_backlight.c:60:9: note:
    uninitialized use occurs here
            return data;
                   ^~~~

As intel_dsi->dcs_backlight_ports seems to be always initialized to a
non-null value, the content of the for loop is always executed and there
is no bug in the current code. Nevertheless the compiler has no way of
knowing that assumption, so initialize variable 'data' to silence the
warning here.

Signed-off-by: Nicolas Iooss <nicolas.iooss_linux@m4x.org>
---
 drivers/gpu/drm/i915/intel_dsi_dcs_backlight.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/drivers/gpu/drm/i915/intel_dsi_dcs_backlight.c b/drivers/gpu/drm/i915/intel_dsi_dcs_backlight.c
index ac7c6020c443..eec45856f910 100644
--- a/drivers/gpu/drm/i915/intel_dsi_dcs_backlight.c
+++ b/drivers/gpu/drm/i915/intel_dsi_dcs_backlight.c
@@ -46,7 +46,7 @@ static u32 dcs_get_backlight(struct intel_connector *connector)
 	struct intel_encoder *encoder = connector->encoder;
 	struct intel_dsi *intel_dsi = enc_to_intel_dsi(&encoder->base);
 	struct mipi_dsi_device *dsi_device;
-	u8 data;
+	u8 data = 0;
 	enum port port;
 
 	/* FIXME: Need to take care of 16 bit brightness level */
-- 
2.9.3

^ permalink raw reply related	[flat|nested] 9+ messages in thread

end of thread, other threads:[~2016-10-23 17:22 UTC | newest]

Thread overview: 9+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2016-09-04 18:58 [PATCH 1/1] drm/i915/dsi: silence a warning about uninitialized return value Nicolas Iooss
2016-09-06 10:21 ` [Intel-gfx] " Dave Gordon
2016-09-06 20:36   ` Nicolas Iooss
2016-09-07 16:03     ` Dave Gordon
2016-09-07 23:02       ` Nicolas Iooss
2016-09-08 14:31         ` Dave Gordon
2016-09-11 21:16           ` Nicolas Iooss
2016-10-23 16:55 ` Nicolas Iooss
2016-10-23 17:22   ` [Intel-gfx] " Chris Wilson

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).