lists.openwall.net   lists  /  announce  owl-users  owl-dev  john-users  john-dev  passwdqc-users  yescrypt  popa3d-users  /  oss-security  kernel-hardening  musl  sabotage  tlsify  passwords  /  crypt-dev  xvendor  /  Bugtraq  Full-Disclosure  linux-kernel  linux-netdev  linux-ext4  linux-hardening  linux-cve-announce  PHC 
Open Source and information security mailing list archives
 
Hash Suite: Windows password security audit tool. GUI, reports in PDF.
[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <20200908042851.GA1422621@ubuntu-n2-xlarge-x86>
Date:   Mon, 7 Sep 2020 21:28:51 -0700
From:   Nathan Chancellor <natechancellor@...il.com>
To:     trix@...hat.com
Cc:     tony.luck@...el.com, qiuxu.zhuo@...el.com, bp@...en8.de,
        mchehab@...nel.org, james.morse@....com, rric@...nel.org,
        ndesaulniers@...gle.com, linux-edac@...r.kernel.org,
        linux-kernel@...r.kernel.org, clang-built-linux@...glegroups.com
Subject: Re: [PATCH] EDAC: sb_edac: simplify switch statement

On Mon, Sep 07, 2020 at 08:32:25AM -0700, trix@...hat.com wrote:
> From: Tom Rix <trix@...hat.com>
> 
> clang static analyzer reports this problem
> 
> sb_edac.c:959:2: warning: Undefined or garbage value
>   returned to caller
>         return type;
>         ^~~~~~~~~~~
> 
> This is a false positive.
> 
> However by initializing the type to DEV_UNKNOWN the 3 case can be
> removed from the switch, saving a comparison and jump.
> 
> Signed-off-by: Tom Rix <trix@...hat.com>

Some maintainers have a preference for a default case statement but
presumably this case statement has been cutting it as is so:

Reviewed-by: Nathan Chancellor <natechancellor@...il.com>

> ---
>  drivers/edac/sb_edac.c | 5 +----
>  1 file changed, 1 insertion(+), 4 deletions(-)
> 
> diff --git a/drivers/edac/sb_edac.c b/drivers/edac/sb_edac.c
> index 68f2fe4df333..93daa4297f2e 100644
> --- a/drivers/edac/sb_edac.c
> +++ b/drivers/edac/sb_edac.c
> @@ -939,12 +939,9 @@ static enum dev_type sbridge_get_width(struct sbridge_pvt *pvt, u32 mtr)
>  
>  static enum dev_type __ibridge_get_width(u32 mtr)
>  {
> -	enum dev_type type;
> +	enum dev_type type = DEV_UNKNOWN;
>  
>  	switch (mtr) {
> -	case 3:
> -		type = DEV_UNKNOWN;
> -		break;
>  	case 2:
>  		type = DEV_X16;
>  		break;
> -- 
> 2.18.1
> 
> -- 
> You received this message because you are subscribed to the Google Groups "Clang Built Linux" group.
> To unsubscribe from this group and stop receiving emails from it, send an email to clang-built-linux+unsubscribe@...glegroups.com.
> To view this discussion on the web visit https://groups.google.com/d/msgid/clang-built-linux/20200907153225.7294-1-trix%40redhat.com.

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ