linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Miquel Raynal <miquel.raynal@bootlin.com>
To: Tom Rix <trix@redhat.com>
Cc: a.zummo@towertech.it, alexandre.belloni@bootlin.com,
	nathan@kernel.org, ndesaulniers@google.com,
	linux-rtc@vger.kernel.org, linux-renesas-soc@vger.kernel.org,
	linux-kernel@vger.kernel.org, llvm@lists.linux.dev
Subject: Re: [PATCH] rtc: rzn1: initialize val in rzn1_rtc_set_offset
Date: Wed, 18 May 2022 17:09:20 +0200	[thread overview]
Message-ID: <20220518170920.4db16990@xps-13> (raw)
In-Reply-To: <20220518134747.3215597-1-trix@redhat.com>

Hi,

trix@redhat.com wrote on Wed, 18 May 2022 09:47:47 -0400:

> The clang build fails with
> rtc-rzn1.c:291:3: error: variable 'val' is uninitialized when used here [-Werror,-Wuninitialized]
>   val |= RZN1_RTC_SUBU_DEV;
>   ^~~
> 
> The val variable in rzn1_rtc_set_offset() is never initialized so
> the series of |= operations in the function will start with a
> garbage value.  So initialize val to 0.
> 
> Fixes: be4a11cf98af ("rtc: rzn1: Add oscillator offset support")
> Signed-off-by: Tom Rix <trix@redhat.com>
> ---
>  drivers/rtc/rtc-rzn1.c | 2 +-
>  1 file changed, 1 insertion(+), 1 deletion(-)
> 
> diff --git a/drivers/rtc/rtc-rzn1.c b/drivers/rtc/rtc-rzn1.c
> index 980ade8c9601..0b4bf6e43464 100644
> --- a/drivers/rtc/rtc-rzn1.c
> +++ b/drivers/rtc/rtc-rzn1.c
> @@ -272,7 +272,7 @@ static int rzn1_rtc_set_offset(struct device *dev, long offset)
>  	struct rzn1_rtc *rtc = dev_get_drvdata(dev);
>  	unsigned int steps;
>  	int stepsh, stepsl;
> -	u32 val;
> +	u32 val = 0;

Actually reviewing this makes me realize I mixed two variables
together:
- val here and below should be renamed to something like "subu" or
  and indeed initialized to 0 here.
- a "ctl2" u32 should be introduced and be used instead of "val" in the
  readl_poll_timeout() call.

Thanks,
Miquèl

      reply	other threads:[~2022-05-18 15:09 UTC|newest]

Thread overview: 2+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2022-05-18 13:47 [PATCH] rtc: rzn1: initialize val in rzn1_rtc_set_offset Tom Rix
2022-05-18 15:09 ` Miquel Raynal [this message]

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=20220518170920.4db16990@xps-13 \
    --to=miquel.raynal@bootlin.com \
    --cc=a.zummo@towertech.it \
    --cc=alexandre.belloni@bootlin.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-renesas-soc@vger.kernel.org \
    --cc=linux-rtc@vger.kernel.org \
    --cc=llvm@lists.linux.dev \
    --cc=nathan@kernel.org \
    --cc=ndesaulniers@google.com \
    --cc=trix@redhat.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;
as well as URLs for NNTP newsgroup(s).