* [PATCH] scsi: ufs-mediatek: Avoid using ret uninitialized in ufs_mtk_setup_clocks
@ 2019-03-20 18:03 ` Nathan Chancellor
0 siblings, 0 replies; 10+ messages in thread
From: Nathan Chancellor @ 2019-03-20 18:03 UTC (permalink / raw)
To: James E.J. Bottomley, Martin K. Petersen
Cc: Stanley Chu, Matthias Brugger, Alim Akhtar, Avri Altman,
Pedro Sousa, linux-scsi, linux-kernel, linux-arm-kernel,
linux-mediatek, clang-built-linux, Nick Desaulniers,
Nathan Chancellor
When building with -Wsometimes-uninitialized, Clang warns:
drivers/scsi/ufs/ufs-mediatek.c:112:7: warning: variable 'ret' is used
uninitialized whenever 'if' condition is false
[-Wsometimes-uninitialized]
if (on)
^~
drivers/scsi/ufs/ufs-mediatek.c:120:9: note: uninitialized use occurs
here
return ret;
^~~
drivers/scsi/ufs/ufs-mediatek.c:112:3: note: remove the 'if' if its
condition is always true
if (on)
^~~~~~~
drivers/scsi/ufs/ufs-mediatek.c:108:7: warning: variable 'ret' is used
uninitialized whenever 'if' condition is false
[-Wsometimes-uninitialized]
if (!on)
^~~
drivers/scsi/ufs/ufs-mediatek.c:120:9: note: uninitialized use occurs
here
return ret;
^~~
drivers/scsi/ufs/ufs-mediatek.c:108:3: note: remove the 'if' if its
condition is always true
if (!on)
^~~~~~~~
drivers/scsi/ufs/ufs-mediatek.c:96:9: note: initialize the variable
'ret' to silence this warning
int ret;
^
= 0
2 warnings generated.
Remove the default case and initialize ret to -EINVAL to properly fix
this warning.
Fixes: ddd90623ce26 ("scsi: ufs-mediatek: Add UFS support for Mediatek SoC chips")
Link: https://github.com/ClangBuiltLinux/linux/issues/426
Signed-off-by: Nathan Chancellor <natechancellor@gmail.com>
---
drivers/scsi/ufs/ufs-mediatek.c | 5 +----
1 file changed, 1 insertion(+), 4 deletions(-)
diff --git a/drivers/scsi/ufs/ufs-mediatek.c b/drivers/scsi/ufs/ufs-mediatek.c
index c3b78fc83d3f..34aecad04468 100644
--- a/drivers/scsi/ufs/ufs-mediatek.c
+++ b/drivers/scsi/ufs/ufs-mediatek.c
@@ -93,7 +93,7 @@ static int ufs_mtk_setup_clocks(struct ufs_hba *hba, bool on,
enum ufs_notify_change_status status)
{
struct ufs_mtk_host *host = ufshcd_get_variant(hba);
- int ret;
+ int ret = -EINVAL;
/*
* In case ufs_mtk_init() is not yet done, simply ignore.
@@ -112,9 +112,6 @@ static int ufs_mtk_setup_clocks(struct ufs_hba *hba, bool on,
if (on)
ret = phy_power_on(host->mphy);
break;
- default:
- ret = -EINVAL;
- break;
}
return ret;
--
2.21.0
^ permalink raw reply related [flat|nested] 10+ messages in thread
* [PATCH] scsi: ufs-mediatek: Avoid using ret uninitialized in ufs_mtk_setup_clocks
@ 2019-03-20 18:03 ` Nathan Chancellor
0 siblings, 0 replies; 10+ messages in thread
From: Nathan Chancellor @ 2019-03-20 18:03 UTC (permalink / raw)
To: James E.J. Bottomley, Martin K. Petersen
Cc: linux-scsi, clang-built-linux, Nick Desaulniers, linux-kernel,
Avri Altman, linux-mediatek, Alim Akhtar, Matthias Brugger,
Nathan Chancellor, Stanley Chu, Pedro Sousa, linux-arm-kernel
When building with -Wsometimes-uninitialized, Clang warns:
drivers/scsi/ufs/ufs-mediatek.c:112:7: warning: variable 'ret' is used
uninitialized whenever 'if' condition is false
[-Wsometimes-uninitialized]
if (on)
^~
drivers/scsi/ufs/ufs-mediatek.c:120:9: note: uninitialized use occurs
here
return ret;
^~~
drivers/scsi/ufs/ufs-mediatek.c:112:3: note: remove the 'if' if its
condition is always true
if (on)
^~~~~~~
drivers/scsi/ufs/ufs-mediatek.c:108:7: warning: variable 'ret' is used
uninitialized whenever 'if' condition is false
[-Wsometimes-uninitialized]
if (!on)
^~~
drivers/scsi/ufs/ufs-mediatek.c:120:9: note: uninitialized use occurs
here
return ret;
^~~
drivers/scsi/ufs/ufs-mediatek.c:108:3: note: remove the 'if' if its
condition is always true
if (!on)
^~~~~~~~
drivers/scsi/ufs/ufs-mediatek.c:96:9: note: initialize the variable
'ret' to silence this warning
int ret;
^
= 0
2 warnings generated.
Remove the default case and initialize ret to -EINVAL to properly fix
this warning.
Fixes: ddd90623ce26 ("scsi: ufs-mediatek: Add UFS support for Mediatek SoC chips")
Link: https://github.com/ClangBuiltLinux/linux/issues/426
Signed-off-by: Nathan Chancellor <natechancellor@gmail.com>
---
drivers/scsi/ufs/ufs-mediatek.c | 5 +----
1 file changed, 1 insertion(+), 4 deletions(-)
diff --git a/drivers/scsi/ufs/ufs-mediatek.c b/drivers/scsi/ufs/ufs-mediatek.c
index c3b78fc83d3f..34aecad04468 100644
--- a/drivers/scsi/ufs/ufs-mediatek.c
+++ b/drivers/scsi/ufs/ufs-mediatek.c
@@ -93,7 +93,7 @@ static int ufs_mtk_setup_clocks(struct ufs_hba *hba, bool on,
enum ufs_notify_change_status status)
{
struct ufs_mtk_host *host = ufshcd_get_variant(hba);
- int ret;
+ int ret = -EINVAL;
/*
* In case ufs_mtk_init() is not yet done, simply ignore.
@@ -112,9 +112,6 @@ static int ufs_mtk_setup_clocks(struct ufs_hba *hba, bool on,
if (on)
ret = phy_power_on(host->mphy);
break;
- default:
- ret = -EINVAL;
- break;
}
return ret;
--
2.21.0
_______________________________________________
linux-arm-kernel mailing list
linux-arm-kernel@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-arm-kernel
^ permalink raw reply related [flat|nested] 10+ messages in thread
* Re: [PATCH] scsi: ufs-mediatek: Avoid using ret uninitialized in ufs_mtk_setup_clocks
2019-03-20 18:03 ` Nathan Chancellor
@ 2019-03-20 22:23 ` Nick Desaulniers
-1 siblings, 0 replies; 10+ messages in thread
From: Nick Desaulniers @ 2019-03-20 22:23 UTC (permalink / raw)
To: Nathan Chancellor
Cc: James E.J. Bottomley, Martin K. Petersen, Stanley Chu,
Matthias Brugger, Alim Akhtar, Avri Altman, Pedro Sousa,
linux-scsi, LKML, Linux ARM, linux-mediatek, clang-built-linux
On Wed, Mar 20, 2019 at 11:06 AM Nathan Chancellor
<natechancellor@gmail.com> wrote:
>
> When building with -Wsometimes-uninitialized, Clang warns:
>
> drivers/scsi/ufs/ufs-mediatek.c:112:7: warning: variable 'ret' is used
> uninitialized whenever 'if' condition is false
> [-Wsometimes-uninitialized]
> if (on)
> ^~
> drivers/scsi/ufs/ufs-mediatek.c:120:9: note: uninitialized use occurs
> here
> return ret;
> ^~~
> drivers/scsi/ufs/ufs-mediatek.c:112:3: note: remove the 'if' if its
> condition is always true
> if (on)
> ^~~~~~~
> drivers/scsi/ufs/ufs-mediatek.c:108:7: warning: variable 'ret' is used
> uninitialized whenever 'if' condition is false
> [-Wsometimes-uninitialized]
> if (!on)
> ^~~
> drivers/scsi/ufs/ufs-mediatek.c:120:9: note: uninitialized use occurs
> here
> return ret;
> ^~~
> drivers/scsi/ufs/ufs-mediatek.c:108:3: note: remove the 'if' if its
> condition is always true
> if (!on)
> ^~~~~~~~
> drivers/scsi/ufs/ufs-mediatek.c:96:9: note: initialize the variable
> 'ret' to silence this warning
> int ret;
> ^
> = 0
> 2 warnings generated.
>
> Remove the default case and initialize ret to -EINVAL to properly fix
> this warning.
>
> Fixes: ddd90623ce26 ("scsi: ufs-mediatek: Add UFS support for Mediatek SoC chips")
> Link: https://github.com/ClangBuiltLinux/linux/issues/426
> Signed-off-by: Nathan Chancellor <natechancellor@gmail.com>
> ---
> drivers/scsi/ufs/ufs-mediatek.c | 5 +----
> 1 file changed, 1 insertion(+), 4 deletions(-)
>
> diff --git a/drivers/scsi/ufs/ufs-mediatek.c b/drivers/scsi/ufs/ufs-mediatek.c
> index c3b78fc83d3f..34aecad04468 100644
> --- a/drivers/scsi/ufs/ufs-mediatek.c
> +++ b/drivers/scsi/ufs/ufs-mediatek.c
> @@ -93,7 +93,7 @@ static int ufs_mtk_setup_clocks(struct ufs_hba *hba, bool on,
> enum ufs_notify_change_status status)
> {
> struct ufs_mtk_host *host = ufshcd_get_variant(hba);
> - int ret;
> + int ret = -EINVAL;
>
> /*
> * In case ufs_mtk_init() is not yet done, simply ignore.
> @@ -112,9 +112,6 @@ static int ufs_mtk_setup_clocks(struct ufs_hba *hba, bool on,
> if (on)
> ret = phy_power_on(host->mphy);
> break;
> - default:
> - ret = -EINVAL;
> - break;
> }
>
> return ret;
> --
> 2.21.0
>
The enum being switched on (enum ufs_notify_change_status) only has 2
values; so the default case is impossible. A switch is probably
overkill, but this change is fine as is. Thanks for sending it.
Reviewed-by: Nick Desaulniers <ndesaulniers@google.com>
--
Thanks,
~Nick Desaulniers
^ permalink raw reply [flat|nested] 10+ messages in thread
* Re: [PATCH] scsi: ufs-mediatek: Avoid using ret uninitialized in ufs_mtk_setup_clocks
@ 2019-03-20 22:23 ` Nick Desaulniers
0 siblings, 0 replies; 10+ messages in thread
From: Nick Desaulniers @ 2019-03-20 22:23 UTC (permalink / raw)
To: Nathan Chancellor
Cc: linux-scsi, Martin K. Petersen, clang-built-linux,
James E.J. Bottomley, LKML, Avri Altman, linux-mediatek,
Alim Akhtar, Matthias Brugger, Stanley Chu, Pedro Sousa,
Linux ARM
On Wed, Mar 20, 2019 at 11:06 AM Nathan Chancellor
<natechancellor@gmail.com> wrote:
>
> When building with -Wsometimes-uninitialized, Clang warns:
>
> drivers/scsi/ufs/ufs-mediatek.c:112:7: warning: variable 'ret' is used
> uninitialized whenever 'if' condition is false
> [-Wsometimes-uninitialized]
> if (on)
> ^~
> drivers/scsi/ufs/ufs-mediatek.c:120:9: note: uninitialized use occurs
> here
> return ret;
> ^~~
> drivers/scsi/ufs/ufs-mediatek.c:112:3: note: remove the 'if' if its
> condition is always true
> if (on)
> ^~~~~~~
> drivers/scsi/ufs/ufs-mediatek.c:108:7: warning: variable 'ret' is used
> uninitialized whenever 'if' condition is false
> [-Wsometimes-uninitialized]
> if (!on)
> ^~~
> drivers/scsi/ufs/ufs-mediatek.c:120:9: note: uninitialized use occurs
> here
> return ret;
> ^~~
> drivers/scsi/ufs/ufs-mediatek.c:108:3: note: remove the 'if' if its
> condition is always true
> if (!on)
> ^~~~~~~~
> drivers/scsi/ufs/ufs-mediatek.c:96:9: note: initialize the variable
> 'ret' to silence this warning
> int ret;
> ^
> = 0
> 2 warnings generated.
>
> Remove the default case and initialize ret to -EINVAL to properly fix
> this warning.
>
> Fixes: ddd90623ce26 ("scsi: ufs-mediatek: Add UFS support for Mediatek SoC chips")
> Link: https://github.com/ClangBuiltLinux/linux/issues/426
> Signed-off-by: Nathan Chancellor <natechancellor@gmail.com>
> ---
> drivers/scsi/ufs/ufs-mediatek.c | 5 +----
> 1 file changed, 1 insertion(+), 4 deletions(-)
>
> diff --git a/drivers/scsi/ufs/ufs-mediatek.c b/drivers/scsi/ufs/ufs-mediatek.c
> index c3b78fc83d3f..34aecad04468 100644
> --- a/drivers/scsi/ufs/ufs-mediatek.c
> +++ b/drivers/scsi/ufs/ufs-mediatek.c
> @@ -93,7 +93,7 @@ static int ufs_mtk_setup_clocks(struct ufs_hba *hba, bool on,
> enum ufs_notify_change_status status)
> {
> struct ufs_mtk_host *host = ufshcd_get_variant(hba);
> - int ret;
> + int ret = -EINVAL;
>
> /*
> * In case ufs_mtk_init() is not yet done, simply ignore.
> @@ -112,9 +112,6 @@ static int ufs_mtk_setup_clocks(struct ufs_hba *hba, bool on,
> if (on)
> ret = phy_power_on(host->mphy);
> break;
> - default:
> - ret = -EINVAL;
> - break;
> }
>
> return ret;
> --
> 2.21.0
>
The enum being switched on (enum ufs_notify_change_status) only has 2
values; so the default case is impossible. A switch is probably
overkill, but this change is fine as is. Thanks for sending it.
Reviewed-by: Nick Desaulniers <ndesaulniers@google.com>
--
Thanks,
~Nick Desaulniers
_______________________________________________
linux-arm-kernel mailing list
linux-arm-kernel@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-arm-kernel
^ permalink raw reply [flat|nested] 10+ messages in thread
* Re: [PATCH] scsi: ufs-mediatek: Avoid using ret uninitialized in ufs_mtk_setup_clocks
2019-03-20 22:23 ` Nick Desaulniers
(?)
@ 2019-03-20 23:23 ` Stanley Chu
-1 siblings, 0 replies; 10+ messages in thread
From: Stanley Chu @ 2019-03-20 23:23 UTC (permalink / raw)
To: Nathan Chancellor
Cc: James E.J. Bottomley, Martin K. Petersen, Matthias Brugger,
Alim Akhtar, Avri Altman, Pedro Sousa, linux-scsi, LKML,
Linux ARM, linux-mediatek, clang-built-linux, Nick Desaulniers
Hi,
On Wed, 2019-03-20 at 15:23 -0700, Nick Desaulniers wrote:
> On Wed, Mar 20, 2019 at 11:06 AM Nathan Chancellor
> <natechancellor@gmail.com> wrote:
> >
> > When building with -Wsometimes-uninitialized, Clang warns:
> >
> > drivers/scsi/ufs/ufs-mediatek.c:112:7: warning: variable 'ret' is used
> > uninitialized whenever 'if' condition is false
> > [-Wsometimes-uninitialized]
> > if (on)
> > ^~
> > drivers/scsi/ufs/ufs-mediatek.c:120:9: note: uninitialized use occurs
> > here
> > return ret;
> > ^~~
> > drivers/scsi/ufs/ufs-mediatek.c:112:3: note: remove the 'if' if its
> > condition is always true
> > if (on)
> > ^~~~~~~
> > drivers/scsi/ufs/ufs-mediatek.c:108:7: warning: variable 'ret' is used
> > uninitialized whenever 'if' condition is false
> > [-Wsometimes-uninitialized]
> > if (!on)
> > ^~~
> > drivers/scsi/ufs/ufs-mediatek.c:120:9: note: uninitialized use occurs
> > here
> > return ret;
> > ^~~
> > drivers/scsi/ufs/ufs-mediatek.c:108:3: note: remove the 'if' if its
> > condition is always true
> > if (!on)
> > ^~~~~~~~
> > drivers/scsi/ufs/ufs-mediatek.c:96:9: note: initialize the variable
> > 'ret' to silence this warning
> > int ret;
> > ^
> > = 0
> > 2 warnings generated.
> >
> > Remove the default case and initialize ret to -EINVAL to properly fix
> > this warning.
> >
> > Fixes: ddd90623ce26 ("scsi: ufs-mediatek: Add UFS support for Mediatek SoC chips")
> > Link: https://github.com/ClangBuiltLinux/linux/issues/426
> > Signed-off-by: Nathan Chancellor <natechancellor@gmail.com>
> > ---
> > drivers/scsi/ufs/ufs-mediatek.c | 5 +----
> > 1 file changed, 1 insertion(+), 4 deletions(-)
> >
> > diff --git a/drivers/scsi/ufs/ufs-mediatek.c b/drivers/scsi/ufs/ufs-mediatek.c
> > index c3b78fc83d3f..34aecad04468 100644
> > --- a/drivers/scsi/ufs/ufs-mediatek.c
> > +++ b/drivers/scsi/ufs/ufs-mediatek.c
> > @@ -93,7 +93,7 @@ static int ufs_mtk_setup_clocks(struct ufs_hba *hba, bool on,
> > enum ufs_notify_change_status status)
> > {
> > struct ufs_mtk_host *host = ufshcd_get_variant(hba);
> > - int ret;
> > + int ret = -EINVAL;
> >
> > /*
> > * In case ufs_mtk_init() is not yet done, simply ignore.
> > @@ -112,9 +112,6 @@ static int ufs_mtk_setup_clocks(struct ufs_hba *hba, bool on,
> > if (on)
> > ret = phy_power_on(host->mphy);
> > break;
> > - default:
> > - ret = -EINVAL;
> > - break;
> > }
> >
> > return ret;
> > --
> > 2.21.0
> >
>
> The enum being switched on (enum ufs_notify_change_status) only has 2
> values; so the default case is impossible. A switch is probably
> overkill, but this change is fine as is. Thanks for sending it.
> Reviewed-by: Nick Desaulniers <ndesaulniers@google.com>
Currently the caller is always using "on" with "POST_CHANGE" and "!on"
with "PRE_CHANGE", however the warnings shall be fixed. Thanks for
fixing it.
Reviewed-by: Stanley Chu <stanley.chu@mediatek.com>
^ permalink raw reply [flat|nested] 10+ messages in thread
* Re: [PATCH] scsi: ufs-mediatek: Avoid using ret uninitialized in ufs_mtk_setup_clocks
@ 2019-03-20 23:23 ` Stanley Chu
0 siblings, 0 replies; 10+ messages in thread
From: Stanley Chu @ 2019-03-20 23:23 UTC (permalink / raw)
To: Nathan Chancellor
Cc: James E.J. Bottomley, Martin K. Petersen, Matthias Brugger,
Alim Akhtar, Avri Altman, Pedro Sousa, linux-scsi, LKML,
Linux ARM, linux-mediatek, clang-built-linux, Nick Desaulniers
Hi,
On Wed, 2019-03-20 at 15:23 -0700, Nick Desaulniers wrote:
> On Wed, Mar 20, 2019 at 11:06 AM Nathan Chancellor
> <natechancellor@gmail.com> wrote:
> >
> > When building with -Wsometimes-uninitialized, Clang warns:
> >
> > drivers/scsi/ufs/ufs-mediatek.c:112:7: warning: variable 'ret' is used
> > uninitialized whenever 'if' condition is false
> > [-Wsometimes-uninitialized]
> > if (on)
> > ^~
> > drivers/scsi/ufs/ufs-mediatek.c:120:9: note: uninitialized use occurs
> > here
> > return ret;
> > ^~~
> > drivers/scsi/ufs/ufs-mediatek.c:112:3: note: remove the 'if' if its
> > condition is always true
> > if (on)
> > ^~~~~~~
> > drivers/scsi/ufs/ufs-mediatek.c:108:7: warning: variable 'ret' is used
> > uninitialized whenever 'if' condition is false
> > [-Wsometimes-uninitialized]
> > if (!on)
> > ^~~
> > drivers/scsi/ufs/ufs-mediatek.c:120:9: note: uninitialized use occurs
> > here
> > return ret;
> > ^~~
> > drivers/scsi/ufs/ufs-mediatek.c:108:3: note: remove the 'if' if its
> > condition is always true
> > if (!on)
> > ^~~~~~~~
> > drivers/scsi/ufs/ufs-mediatek.c:96:9: note: initialize the variable
> > 'ret' to silence this warning
> > int ret;
> > ^
> > = 0
> > 2 warnings generated.
> >
> > Remove the default case and initialize ret to -EINVAL to properly fix
> > this warning.
> >
> > Fixes: ddd90623ce26 ("scsi: ufs-mediatek: Add UFS support for Mediatek SoC chips")
> > Link: https://github.com/ClangBuiltLinux/linux/issues/426
> > Signed-off-by: Nathan Chancellor <natechancellor@gmail.com>
> > ---
> > drivers/scsi/ufs/ufs-mediatek.c | 5 +----
> > 1 file changed, 1 insertion(+), 4 deletions(-)
> >
> > diff --git a/drivers/scsi/ufs/ufs-mediatek.c b/drivers/scsi/ufs/ufs-mediatek.c
> > index c3b78fc83d3f..34aecad04468 100644
> > --- a/drivers/scsi/ufs/ufs-mediatek.c
> > +++ b/drivers/scsi/ufs/ufs-mediatek.c
> > @@ -93,7 +93,7 @@ static int ufs_mtk_setup_clocks(struct ufs_hba *hba, bool on,
> > enum ufs_notify_change_status status)
> > {
> > struct ufs_mtk_host *host = ufshcd_get_variant(hba);
> > - int ret;
> > + int ret = -EINVAL;
> >
> > /*
> > * In case ufs_mtk_init() is not yet done, simply ignore.
> > @@ -112,9 +112,6 @@ static int ufs_mtk_setup_clocks(struct ufs_hba *hba, bool on,
> > if (on)
> > ret = phy_power_on(host->mphy);
> > break;
> > - default:
> > - ret = -EINVAL;
> > - break;
> > }
> >
> > return ret;
> > --
> > 2.21.0
> >
>
> The enum being switched on (enum ufs_notify_change_status) only has 2
> values; so the default case is impossible. A switch is probably
> overkill, but this change is fine as is. Thanks for sending it.
> Reviewed-by: Nick Desaulniers <ndesaulniers@google.com>
Currently the caller is always using "on" with "POST_CHANGE" and "!on"
with "PRE_CHANGE", however the warnings shall be fixed. Thanks for
fixing it.
Reviewed-by: Stanley Chu <stanley.chu@mediatek.com>
^ permalink raw reply [flat|nested] 10+ messages in thread
* Re: [PATCH] scsi: ufs-mediatek: Avoid using ret uninitialized in ufs_mtk_setup_clocks
@ 2019-03-20 23:23 ` Stanley Chu
0 siblings, 0 replies; 10+ messages in thread
From: Stanley Chu @ 2019-03-20 23:23 UTC (permalink / raw)
To: Nathan Chancellor
Cc: linux-scsi, Martin K. Petersen, clang-built-linux,
James E.J. Bottomley, Nick Desaulniers, LKML, Avri Altman,
linux-mediatek, Alim Akhtar, Matthias Brugger, Pedro Sousa,
Linux ARM
Hi,
On Wed, 2019-03-20 at 15:23 -0700, Nick Desaulniers wrote:
> On Wed, Mar 20, 2019 at 11:06 AM Nathan Chancellor
> <natechancellor@gmail.com> wrote:
> >
> > When building with -Wsometimes-uninitialized, Clang warns:
> >
> > drivers/scsi/ufs/ufs-mediatek.c:112:7: warning: variable 'ret' is used
> > uninitialized whenever 'if' condition is false
> > [-Wsometimes-uninitialized]
> > if (on)
> > ^~
> > drivers/scsi/ufs/ufs-mediatek.c:120:9: note: uninitialized use occurs
> > here
> > return ret;
> > ^~~
> > drivers/scsi/ufs/ufs-mediatek.c:112:3: note: remove the 'if' if its
> > condition is always true
> > if (on)
> > ^~~~~~~
> > drivers/scsi/ufs/ufs-mediatek.c:108:7: warning: variable 'ret' is used
> > uninitialized whenever 'if' condition is false
> > [-Wsometimes-uninitialized]
> > if (!on)
> > ^~~
> > drivers/scsi/ufs/ufs-mediatek.c:120:9: note: uninitialized use occurs
> > here
> > return ret;
> > ^~~
> > drivers/scsi/ufs/ufs-mediatek.c:108:3: note: remove the 'if' if its
> > condition is always true
> > if (!on)
> > ^~~~~~~~
> > drivers/scsi/ufs/ufs-mediatek.c:96:9: note: initialize the variable
> > 'ret' to silence this warning
> > int ret;
> > ^
> > = 0
> > 2 warnings generated.
> >
> > Remove the default case and initialize ret to -EINVAL to properly fix
> > this warning.
> >
> > Fixes: ddd90623ce26 ("scsi: ufs-mediatek: Add UFS support for Mediatek SoC chips")
> > Link: https://github.com/ClangBuiltLinux/linux/issues/426
> > Signed-off-by: Nathan Chancellor <natechancellor@gmail.com>
> > ---
> > drivers/scsi/ufs/ufs-mediatek.c | 5 +----
> > 1 file changed, 1 insertion(+), 4 deletions(-)
> >
> > diff --git a/drivers/scsi/ufs/ufs-mediatek.c b/drivers/scsi/ufs/ufs-mediatek.c
> > index c3b78fc83d3f..34aecad04468 100644
> > --- a/drivers/scsi/ufs/ufs-mediatek.c
> > +++ b/drivers/scsi/ufs/ufs-mediatek.c
> > @@ -93,7 +93,7 @@ static int ufs_mtk_setup_clocks(struct ufs_hba *hba, bool on,
> > enum ufs_notify_change_status status)
> > {
> > struct ufs_mtk_host *host = ufshcd_get_variant(hba);
> > - int ret;
> > + int ret = -EINVAL;
> >
> > /*
> > * In case ufs_mtk_init() is not yet done, simply ignore.
> > @@ -112,9 +112,6 @@ static int ufs_mtk_setup_clocks(struct ufs_hba *hba, bool on,
> > if (on)
> > ret = phy_power_on(host->mphy);
> > break;
> > - default:
> > - ret = -EINVAL;
> > - break;
> > }
> >
> > return ret;
> > --
> > 2.21.0
> >
>
> The enum being switched on (enum ufs_notify_change_status) only has 2
> values; so the default case is impossible. A switch is probably
> overkill, but this change is fine as is. Thanks for sending it.
> Reviewed-by: Nick Desaulniers <ndesaulniers@google.com>
Currently the caller is always using "on" with "POST_CHANGE" and "!on"
with "PRE_CHANGE", however the warnings shall be fixed. Thanks for
fixing it.
Reviewed-by: Stanley Chu <stanley.chu@mediatek.com>
_______________________________________________
linux-arm-kernel mailing list
linux-arm-kernel@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-arm-kernel
^ permalink raw reply [flat|nested] 10+ messages in thread
* Re: [PATCH] scsi: ufs-mediatek: Avoid using ret uninitialized in ufs_mtk_setup_clocks
2019-03-20 18:03 ` Nathan Chancellor
(?)
@ 2019-03-21 0:10 ` Martin K. Petersen
-1 siblings, 0 replies; 10+ messages in thread
From: Martin K. Petersen @ 2019-03-21 0:10 UTC (permalink / raw)
To: Nathan Chancellor
Cc: James E.J. Bottomley, Martin K. Petersen, Stanley Chu,
Matthias Brugger, Alim Akhtar, Avri Altman, Pedro Sousa,
linux-scsi, linux-kernel, linux-arm-kernel, linux-mediatek,
clang-built-linux, Nick Desaulniers
Nathan,
> Remove the default case and initialize ret to -EINVAL to properly fix
> this warning.
Applied to 5.2/scsi-queue, thanks!
--
Martin K. Petersen Oracle Linux Engineering
^ permalink raw reply [flat|nested] 10+ messages in thread
* Re: [PATCH] scsi: ufs-mediatek: Avoid using ret uninitialized in ufs_mtk_setup_clocks
@ 2019-03-21 0:10 ` Martin K. Petersen
0 siblings, 0 replies; 10+ messages in thread
From: Martin K. Petersen @ 2019-03-21 0:10 UTC (permalink / raw)
To: Nathan Chancellor
Cc: linux-scsi, Martin K. Petersen, clang-built-linux,
James E.J. Bottomley, Nick Desaulniers, linux-kernel,
Avri Altman, linux-mediatek, Alim Akhtar, Matthias Brugger,
Stanley Chu, Pedro Sousa, linux-arm-kernel
Nathan,
> Remove the default case and initialize ret to -EINVAL to properly fix
> this warning.
Applied to 5.2/scsi-queue, thanks!
--
Martin K. Petersen Oracle Linux Engineering
^ permalink raw reply [flat|nested] 10+ messages in thread
* Re: [PATCH] scsi: ufs-mediatek: Avoid using ret uninitialized in ufs_mtk_setup_clocks
@ 2019-03-21 0:10 ` Martin K. Petersen
0 siblings, 0 replies; 10+ messages in thread
From: Martin K. Petersen @ 2019-03-21 0:10 UTC (permalink / raw)
To: Nathan Chancellor
Cc: linux-scsi, Martin K. Petersen, clang-built-linux,
James E.J. Bottomley, Nick Desaulniers, linux-kernel,
Avri Altman, linux-mediatek, Alim Akhtar, Matthias Brugger,
Stanley Chu, Pedro Sousa, linux-arm-kernel
Nathan,
> Remove the default case and initialize ret to -EINVAL to properly fix
> this warning.
Applied to 5.2/scsi-queue, thanks!
--
Martin K. Petersen Oracle Linux Engineering
_______________________________________________
linux-arm-kernel mailing list
linux-arm-kernel@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-arm-kernel
^ permalink raw reply [flat|nested] 10+ messages in thread
end of thread, other threads:[~2019-03-21 0:11 UTC | newest]
Thread overview: 10+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2019-03-20 18:03 [PATCH] scsi: ufs-mediatek: Avoid using ret uninitialized in ufs_mtk_setup_clocks Nathan Chancellor
2019-03-20 18:03 ` Nathan Chancellor
2019-03-20 22:23 ` Nick Desaulniers
2019-03-20 22:23 ` Nick Desaulniers
2019-03-20 23:23 ` Stanley Chu
2019-03-20 23:23 ` Stanley Chu
2019-03-20 23:23 ` Stanley Chu
2019-03-21 0:10 ` Martin K. Petersen
2019-03-21 0:10 ` Martin K. Petersen
2019-03-21 0:10 ` Martin K. Petersen
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.