mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
From: Daniel Vetter <daniel@ffwll.ch>
To: Arnd Bergmann <arnd@arndb.de>
Cc: Patrik Jakobsson <patrik.r.jakobsson@gmail.com>,
	David Airlie <airlied@linux.ie>,
	dri-devel@lists.freedesktop.org, linux-kernel@vger.kernel.org
Subject: Re: [PATCH] [RESEND] drm/gma500: initialize gma_clock_t structures
Date: Wed, 17 Jan 2018 09:27:12 +0100	[thread overview]
Message-ID: <20180117082712.GF2759@phenom.ffwll.local> (raw)
In-Reply-To: <20180116145720.2348043-1-arnd@arndb.de>

On Tue, Jan 16, 2018 at 03:57:10PM +0100, Arnd Bergmann wrote:
> The two functions pass a partially initialized structure back to the
> caller after a memset() on the destination.
> 
> This is not entirely well-defined, most compilers are sensible enough
> to either keep the zero-initialization for the uninitialized members,
> but gcc-4.4 does not, and it warns about this:
> 
> drivers/gpu/drm/gma500/oaktrail_crtc.c: In function 'mrst_sdvo_find_best_pll':
> drivers/gpu/drm/gma500/oaktrail_crtc.c:175: warning: 'clock.vco' may be used uninitialized in this function
> drivers/gpu/drm/gma500/oaktrail_crtc.c:175: warning: 'clock.dot' may be used uninitialized in this function
> drivers/gpu/drm/gma500/oaktrail_crtc.c:175: warning: 'clock.p2' may be used uninitialized in this function
> drivers/gpu/drm/gma500/oaktrail_crtc.c:175: warning: 'clock.m2' may be used uninitialized in this function
> drivers/gpu/drm/gma500/oaktrail_crtc.c:175: warning: 'clock.m1' may be used uninitialized in this function
> drivers/gpu/drm/gma500/oaktrail_crtc.c: In function 'mrst_lvds_find_best_pll':
> drivers/gpu/drm/gma500/oaktrail_crtc.c:208: warning: 'clock.p' may be used uninitialized in this function
> drivers/gpu/drm/gma500/oaktrail_crtc.c:208: warning: 'clock.vco' may be used uninitialized in this function
> drivers/gpu/drm/gma500/oaktrail_crtc.c:208: warning: 'clock.p2' may be used uninitialized in this function
> drivers/gpu/drm/gma500/oaktrail_crtc.c:208: warning: 'clock.m2' may be used uninitialized in this function
> drivers/gpu/drm/gma500/oaktrail_crtc.c:208: warning: 'clock.m1' may be used uninitialized in this function
> drivers/gpu/drm/gma500/oaktrail_crtc.c:208: warning: 'clock.n' may be used uninitialized in this function
> 
> This adds an initialization at declaration time to avoid the warning
> and make it well-defined on all compiler versions.
> 
> Signed-off-by: Arnd Bergmann <arnd@arndb.de>

Applied to drm-misc-next-fixes for 4.16, thx for your patch. Aside: Still
don't want commit rights? :-)

Cheers, Daniel
> ---
> Originally submitted on Sep 15, 2017, but got no reply. Resending unchanged.
> ---
>  drivers/gpu/drm/gma500/oaktrail_crtc.c | 4 ++--
>  1 file changed, 2 insertions(+), 2 deletions(-)
> 
> diff --git a/drivers/gpu/drm/gma500/oaktrail_crtc.c b/drivers/gpu/drm/gma500/oaktrail_crtc.c
> index 0fff269d3fe6..b49fe79c3f44 100644
> --- a/drivers/gpu/drm/gma500/oaktrail_crtc.c
> +++ b/drivers/gpu/drm/gma500/oaktrail_crtc.c
> @@ -134,7 +134,7 @@ static bool mrst_sdvo_find_best_pll(const struct gma_limit_t *limit,
>  				    struct drm_crtc *crtc, int target,
>  				    int refclk, struct gma_clock_t *best_clock)
>  {
> -	struct gma_clock_t clock;
> +	struct gma_clock_t clock = {};
>  	u32 target_vco, actual_freq;
>  	s32 freq_error, min_error = 100000;
>  
> @@ -191,7 +191,7 @@ static bool mrst_lvds_find_best_pll(const struct gma_limit_t *limit,
>  				    struct drm_crtc *crtc, int target,
>  				    int refclk, struct gma_clock_t *best_clock)
>  {
> -	struct gma_clock_t clock;
> +	struct gma_clock_t clock = {};
>  	int err = target;
>  
>  	memset(best_clock, 0, sizeof(*best_clock));
> -- 
> 2.9.0
> 
> _______________________________________________
> dri-devel mailing list
> dri-devel@lists.freedesktop.org
> https://lists.freedesktop.org/mailman/listinfo/dri-devel

-- 
Daniel Vetter
Software Engineer, Intel Corporation
http://blog.ffwll.ch

  parent reply	other threads:[~2018-01-17  8:27 UTC|newest]

Thread overview: 7+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2018-01-16 14:57 Arnd Bergmann
2018-01-17  8:23 ` Patrik Jakobsson
2018-01-17  8:27 ` Daniel Vetter [this message]
2018-01-17 14:36   ` Arnd Bergmann
2018-01-17 14:55     ` Daniel Vetter
2018-01-17 19:44       ` Arnd Bergmann
2018-01-17 21:19         ` Daniel Vetter

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20180117082712.GF2759@phenom.ffwll.local \
    --to=daniel@ffwll.ch \
    --cc=airlied@linux.ie \
    --cc=arnd@arndb.de \
    --cc=dri-devel@lists.freedesktop.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=patrik.r.jakobsson@gmail.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox

all inboxes | Powered by JetHome®