All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH] rtc: rzn1: initialize val in rzn1_rtc_set_offset
@ 2022-05-18 13:47 Tom Rix
  2022-05-18 15:09 ` Miquel Raynal
  0 siblings, 1 reply; 2+ messages in thread
From: Tom Rix @ 2022-05-18 13:47 UTC (permalink / raw)
  To: miquel.raynal, a.zummo, alexandre.belloni, nathan, ndesaulniers
  Cc: linux-rtc, linux-renesas-soc, linux-kernel, llvm, Tom Rix

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;
 	int ret;
 
 	/*
-- 
2.27.0


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

* Re: [PATCH] rtc: rzn1: initialize val in rzn1_rtc_set_offset
  2022-05-18 13:47 [PATCH] rtc: rzn1: initialize val in rzn1_rtc_set_offset Tom Rix
@ 2022-05-18 15:09 ` Miquel Raynal
  0 siblings, 0 replies; 2+ messages in thread
From: Miquel Raynal @ 2022-05-18 15:09 UTC (permalink / raw)
  To: Tom Rix
  Cc: a.zummo, alexandre.belloni, nathan, ndesaulniers, linux-rtc,
	linux-renesas-soc, linux-kernel, llvm

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

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

end of thread, other threads:[~2022-05-18 15:09 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
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 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.