All of lore.kernel.org
 help / color / mirror / Atom feed
From: Thierry Reding <thierry.reding@gmail.com>
To: "Uwe Kleine-König" <u.kleine-koenig@pengutronix.de>
Cc: "Maxime Ripard" <mripard@kernel.org>,
	"Jernej Skrabec" <jernej.skrabec@siol.net>,
	"Clément Péron" <peron.clem@gmail.com>,
	linux-pwm@vger.kernel.org
Subject: Re: [PATCH] pwm: sun4i: Initialize variables before use
Date: Tue, 21 Jan 2020 14:50:11 +0100	[thread overview]
Message-ID: <20200121135011.GD899558@ulmo> (raw)
In-Reply-To: <20200120200917.gvua5h2egoznwd4h@pengutronix.de>

[-- Attachment #1: Type: text/plain, Size: 1943 bytes --]

On Mon, Jan 20, 2020 at 09:09:17PM +0100, Uwe Kleine-König wrote:
> Hello Thierry,
> 
> On Mon, Jan 20, 2020 at 03:32:06PM +0100, Thierry Reding wrote:
> > GCC can't always determine that the duty, period and prescaler values
> > are initialized when returning from sun4i_pwm_calculate(), so help out a
> > little by initializing them to 0.
> 
> Is it worth mentioning the gcc version you're using?

I could, but what good is that going to be? I don't think this is
something that's limited to one specific version but I don't know
exactly which ones are impacted. Stating just one specific version
isn't all that useful in that case.

> > Signed-off-by: Thierry Reding <thierry.reding@gmail.com>
> > ---
> >  drivers/pwm/pwm-sun4i.c | 4 ++--
> >  1 file changed, 2 insertions(+), 2 deletions(-)
> > 
> > diff --git a/drivers/pwm/pwm-sun4i.c b/drivers/pwm/pwm-sun4i.c
> > index 0decc7cde133..3e3efa6c768f 100644
> 
> I don't find this object (0decc7cde133) in my tree or next. Which
> version is this?

I made this on top of my local pwm/for-next when I was build-testing,
which I usually do before pushing, so it's not surprising that you
don't have this in your tree.

> 
> > --- a/drivers/pwm/pwm-sun4i.c
> > +++ b/drivers/pwm/pwm-sun4i.c
> > @@ -234,9 +234,9 @@ static int sun4i_pwm_apply(struct pwm_chip *chip, struct pwm_device *pwm,
> >  {
> >  	struct sun4i_pwm_chip *sun4i_pwm = to_sun4i_pwm_chip(chip);
> >  	struct pwm_state cstate;
> > -	u32 ctrl, duty, period, val;
> > +	u32 ctrl, duty = 0, period = 0, val;
> 
> +     u32 ctrl, uninitialized_var(duty), uninitialized_var(period), val;
> 
> should fix the warnings, too, and additionally explicitly documents that
> it's just the compiler that doesn't see there is no problem.

I haven't convinced myself fully yet that there really isn't a problem.
I'm fairly sure it's safe, but always initializing to 0 doesn't hurt.

Thierry

[-- Attachment #2: signature.asc --]
[-- Type: application/pgp-signature, Size: 833 bytes --]

  parent reply	other threads:[~2020-01-21 13:50 UTC|newest]

Thread overview: 5+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2020-01-20 14:32 [PATCH] pwm: sun4i: Initialize variables before use Thierry Reding
2020-01-20 20:09 ` Uwe Kleine-König
2020-01-20 20:23   ` Clément Péron
2020-01-21 13:50   ` Thierry Reding [this message]
2020-01-21 14:31     ` Uwe Kleine-König

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=20200121135011.GD899558@ulmo \
    --to=thierry.reding@gmail.com \
    --cc=jernej.skrabec@siol.net \
    --cc=linux-pwm@vger.kernel.org \
    --cc=mripard@kernel.org \
    --cc=peron.clem@gmail.com \
    --cc=u.kleine-koenig@pengutronix.de \
    /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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.