* [PATCH] EDAC: sb_edac: simplify switch statement
@ 2020-09-07 15:32 trix
2020-09-08 4:28 ` Nathan Chancellor
2020-09-08 22:08 ` Luck, Tony
0 siblings, 2 replies; 4+ messages in thread
From: trix @ 2020-09-07 15:32 UTC (permalink / raw)
To: tony.luck, qiuxu.zhuo, bp, mchehab, james.morse, rric,
natechancellor, ndesaulniers
Cc: linux-edac, linux-kernel, clang-built-linux, Tom Rix
From: Tom Rix <trix@redhat.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@redhat.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
^ permalink raw reply related [flat|nested] 4+ messages in thread
* Re: [PATCH] EDAC: sb_edac: simplify switch statement
2020-09-07 15:32 [PATCH] EDAC: sb_edac: simplify switch statement trix
@ 2020-09-08 4:28 ` Nathan Chancellor
2020-09-08 22:08 ` Luck, Tony
1 sibling, 0 replies; 4+ messages in thread
From: Nathan Chancellor @ 2020-09-08 4:28 UTC (permalink / raw)
To: trix
Cc: tony.luck, qiuxu.zhuo, bp, mchehab, james.morse, rric,
ndesaulniers, linux-edac, linux-kernel, clang-built-linux
On Mon, Sep 07, 2020 at 08:32:25AM -0700, trix@redhat.com wrote:
> From: Tom Rix <trix@redhat.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@redhat.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@gmail.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@googlegroups.com.
> To view this discussion on the web visit https://groups.google.com/d/msgid/clang-built-linux/20200907153225.7294-1-trix%40redhat.com.
^ permalink raw reply [flat|nested] 4+ messages in thread
* RE: [PATCH] EDAC: sb_edac: simplify switch statement
2020-09-07 15:32 [PATCH] EDAC: sb_edac: simplify switch statement trix
2020-09-08 4:28 ` Nathan Chancellor
@ 2020-09-08 22:08 ` Luck, Tony
2020-09-10 16:11 ` Borislav Petkov
1 sibling, 1 reply; 4+ messages in thread
From: Luck, Tony @ 2020-09-08 22:08 UTC (permalink / raw)
To: trix, Zhuo, Qiuxu, bp, mchehab, james.morse, rric,
natechancellor, ndesaulniers
Cc: linux-edac, linux-kernel, clang-built-linux
> 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@redhat.com>
Applied. Thanks.
-Tony
[Boris: Pushed to edac-misc and edac-for-next branches in RAS tree]
^ permalink raw reply [flat|nested] 4+ messages in thread
* Re: [PATCH] EDAC: sb_edac: simplify switch statement
2020-09-08 22:08 ` Luck, Tony
@ 2020-09-10 16:11 ` Borislav Petkov
0 siblings, 0 replies; 4+ messages in thread
From: Borislav Petkov @ 2020-09-10 16:11 UTC (permalink / raw)
To: Luck, Tony
Cc: trix, Zhuo, Qiuxu, mchehab, james.morse, rric, natechancellor,
ndesaulniers, linux-edac, linux-kernel, clang-built-linux
On Tue, Sep 08, 2020 at 10:08:28PM +0000, Luck, Tony wrote:
> [Boris: Pushed to edac-misc and edac-for-next branches in RAS tree]
Yap, looks good.
Thx.
--
Regards/Gruss,
Boris.
https://people.kernel.org/tglx/notes-about-netiquette
^ permalink raw reply [flat|nested] 4+ messages in thread
end of thread, other threads:[~2020-09-10 16:11 UTC | newest]
Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2020-09-07 15:32 [PATCH] EDAC: sb_edac: simplify switch statement trix
2020-09-08 4:28 ` Nathan Chancellor
2020-09-08 22:08 ` Luck, Tony
2020-09-10 16:11 ` Borislav Petkov
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).