Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1756546AbcJWQ4D (ORCPT ); Sun, 23 Oct 2016 12:56:03 -0400 Received: from mail-wm0-f65.google.com ([74.125.82.65]:34842 "EHLO mail-wm0-f65.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1752710AbcJWQ4C (ORCPT ); Sun, 23 Oct 2016 12:56:02 -0400 Subject: Re: [PATCH 1/1] drm/i915/dsi: silence a warning about uninitialized return value To: Daniel Vetter , Jani Nikula , intel-gfx@lists.freedesktop.org, dri-devel@lists.freedesktop.org References: <20160904185809.31916-1-nicolas.iooss_linux@m4x.org> Cc: linux-kernel@vger.kernel.org From: Nicolas Iooss Message-ID: <8ebf69c1-2e57-4a67-f392-346d54741826@m4x.org> Date: Sun, 23 Oct 2016 18:55:58 +0200 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:45.0) Gecko/20100101 Thunderbird/45.4.0 MIME-Version: 1.0 In-Reply-To: <20160904185809.31916-1-nicolas.iooss_linux@m4x.org> Content-Type: text/plain; charset=windows-1252 Content-Transfer-Encoding: 7bit Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Length: 2675 Lines: 61 Hello, I sent the patch below a few weeks ago. I got some comments (cf. [1]) which looked good, but the patch has not been merged in linux-next yet. Do I need to fix something (like rewrite the commit message) in order to get it merged? Thanks, Nicolas [1] https://patchwork.freedesktop.org/patch/108941/ On 04/09/16 20:58, Nicolas Iooss wrote: > 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 > --- > 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 */ >