lkml.org 
[lkml]   [2019]   [Mar]   [7]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
 
Messages in this thread
/
From
Date
SubjectRe: [PATCH] pwm: img: Turn final 'else if' into 'else' in img_pwm_config
On Thu, Mar 7, 2019 at 2:36 PM Nathan Chancellor
<natechancellor@gmail.com> wrote:
>
> When building with -Wsometimes-uninitialized, Clang warns:
>
> drivers/pwm/pwm-img.c:126:13: error: variable 'timebase' is used
> uninitialized whenever 'if' condition is false
> [-Werror,-Wsometimes-uninitialized]
>
> The final else if functions as an else; make that explicit so that Clang
> understands that timebase cannot be used uninitialized.

A welcome simplification! Thank you.
Reviewed-by: Nick Desaulniers <ndesaulniers@google.com>

>
> Link: https://github.com/ClangBuiltLinux/linux/issues/400
> Signed-off-by: Nathan Chancellor <natechancellor@gmail.com>
> ---
> drivers/pwm/pwm-img.c | 2 +-
> 1 file changed, 1 insertion(+), 1 deletion(-)
>
> diff --git a/drivers/pwm/pwm-img.c b/drivers/pwm/pwm-img.c
> index 815f5333bb8f..1cc5fbe1e1d3 100644
> --- a/drivers/pwm/pwm-img.c
> +++ b/drivers/pwm/pwm-img.c
> @@ -123,7 +123,7 @@ static int img_pwm_config(struct pwm_chip *chip, struct pwm_device *pwm,
> } else if (mul <= max_timebase * 512) {
> div = PWM_CTRL_CFG_SUB_DIV0_DIV1;
> timebase = DIV_ROUND_UP(mul, 512);
> - } else if (mul > max_timebase * 512) {
> + } else {
> dev_err(chip->dev,
> "failed to configure timebase steps/divider value\n");
> return -EINVAL;
> --
> 2.21.0
>


--
Thanks,
~Nick Desaulniers

\
 
 \ /
  Last update: 2019-03-08 01:23    [W:0.094 / U:0.304 seconds]
©2003-2020 Jasper Spaans|hosted at Digital Ocean and TransIP|Read the blog|Advertise on this site