linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH] ufshcd: fix Wsometimes-uninitialized warning
@ 2020-12-03 22:31 Arnd Bergmann
  2020-12-05  8:08 ` Avri Altman
                   ` (3 more replies)
  0 siblings, 4 replies; 5+ messages in thread
From: Arnd Bergmann @ 2020-12-03 22:31 UTC (permalink / raw)
  To: James E.J. Bottomley, Martin K. Petersen, Nathan Chancellor,
	Nick Desaulniers, Jaegeuk Kim
  Cc: Arnd Bergmann, Alim Akhtar, Avri Altman, Stanley Chu, Can Guo,
	Asutosh Das, Bean Huo, Bart Van Assche, linux-scsi, linux-kernel,
	clang-built-linux

From: Arnd Bergmann <arnd@arndb.de>

clang complains about a possible code path in which a variable is
used without an initialization:

drivers/scsi/ufs/ufshcd.c:7690:3: error: variable 'sdp' is used uninitialized whenever 'if' condition is false [-Werror,-Wsometimes-uninitialized]
                BUG_ON(1);
                ^~~~~~~~~
include/asm-generic/bug.h:63:36: note: expanded from macro 'BUG_ON'
 #define BUG_ON(condition) do { if (unlikely(condition)) BUG(); } while (0)
                                   ^~~~~~~~~~~~~~~~~~~

Turn the BUG_ON(1) into an unconditional BUG() that makes it clear
to clang that this code path is never hit.

Fixes: 4f3e900b6282 ("scsi: ufs: Clear UAC for FFU and RPMB LUNs")
Signed-off-by: Arnd Bergmann <arnd@arndb.de>
---
 drivers/scsi/ufs/ufshcd.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/drivers/scsi/ufs/ufshcd.c b/drivers/scsi/ufs/ufshcd.c
index f165baee937f..b4f7c4263334 100644
--- a/drivers/scsi/ufs/ufshcd.c
+++ b/drivers/scsi/ufs/ufshcd.c
@@ -7687,7 +7687,7 @@ static int ufshcd_clear_ua_wlun(struct ufs_hba *hba, u8 wlun)
 	else if (wlun == UFS_UPIU_RPMB_WLUN)
 		sdp = hba->sdev_rpmb;
 	else
-		BUG_ON(1);
+		BUG();
 	if (sdp) {
 		ret = scsi_device_get(sdp);
 		if (!ret && !scsi_device_online(sdp)) {
-- 
2.27.0


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

* RE: [PATCH] ufshcd: fix Wsometimes-uninitialized warning
  2020-12-03 22:31 [PATCH] ufshcd: fix Wsometimes-uninitialized warning Arnd Bergmann
@ 2020-12-05  8:08 ` Avri Altman
  2020-12-05  8:11 ` Avri Altman
                   ` (2 subsequent siblings)
  3 siblings, 0 replies; 5+ messages in thread
From: Avri Altman @ 2020-12-05  8:08 UTC (permalink / raw)
  To: Arnd Bergmann, James E.J. Bottomley, Martin K. Petersen,
	Nathan Chancellor, Nick Desaulniers, Jaegeuk Kim
  Cc: Arnd Bergmann, Alim Akhtar, Stanley Chu, Can Guo, Asutosh Das,
	Bean Huo, Bart Van Assche, linux-scsi, linux-kernel,
	clang-built-linux

> 
> 
> From: Arnd Bergmann <arnd@arndb.de>
> 
> clang complains about a possible code path in which a variable is
> used without an initialization:
> 
> drivers/scsi/ufs/ufshcd.c:7690:3: error: variable 'sdp' is used uninitialized
> whenever 'if' condition is false [-Werror,-Wsometimes-uninitialized]
>                 BUG_ON(1);
>                 ^~~~~~~~~
> include/asm-generic/bug.h:63:36: note: expanded from macro 'BUG_ON'
>  #define BUG_ON(condition) do { if (unlikely(condition)) BUG(); } while (0)
>                                    ^~~~~~~~~~~~~~~~~~~
> 
> Turn the BUG_ON(1) into an unconditional BUG() that makes it clear
> to clang that this code path is never hit.
> 
> Fixes: 4f3e900b6282 ("scsi: ufs: Clear UAC for FFU and RPMB LUNs")
> Signed-off-by: Arnd Bergmann <arnd@arndb.de>
Reviewed-by: Avri Altman <avri.altman@wdc.com>

> ---
>  drivers/scsi/ufs/ufshcd.c | 2 +-
>  1 file changed, 1 insertion(+), 1 deletion(-)
> 
> diff --git a/drivers/scsi/ufs/ufshcd.c b/drivers/scsi/ufs/ufshcd.c
> index f165baee937f..b4f7c4263334 100644
> --- a/drivers/scsi/ufs/ufshcd.c
> +++ b/drivers/scsi/ufs/ufshcd.c
> @@ -7687,7 +7687,7 @@ static int ufshcd_clear_ua_wlun(struct ufs_hba
> *hba, u8 wlun)
>         else if (wlun == UFS_UPIU_RPMB_WLUN)
>                 sdp = hba->sdev_rpmb;
>         else
> -               BUG_ON(1);
> +               BUG();
>         if (sdp) {
>                 ret = scsi_device_get(sdp);
>                 if (!ret && !scsi_device_online(sdp)) {
> --
> 2.27.0


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

* RE: [PATCH] ufshcd: fix Wsometimes-uninitialized warning
  2020-12-03 22:31 [PATCH] ufshcd: fix Wsometimes-uninitialized warning Arnd Bergmann
  2020-12-05  8:08 ` Avri Altman
@ 2020-12-05  8:11 ` Avri Altman
  2020-12-08  1:30 ` Martin K. Petersen
  2020-12-09 17:23 ` Martin K. Petersen
  3 siblings, 0 replies; 5+ messages in thread
From: Avri Altman @ 2020-12-05  8:11 UTC (permalink / raw)
  To: Arnd Bergmann, James E.J. Bottomley, Martin K. Petersen,
	Nathan Chancellor, Nick Desaulniers, Jaegeuk Kim
  Cc: Arnd Bergmann, Alim Akhtar, Stanley Chu, Can Guo, Asutosh Das,
	Bean Huo, Bart Van Assche, linux-scsi, linux-kernel,
	clang-built-linux

> 
> 
> From: Arnd Bergmann <arnd@arndb.de>
> 
> clang complains about a possible code path in which a variable is
> used without an initialization:
> 
> drivers/scsi/ufs/ufshcd.c:7690:3: error: variable 'sdp' is used uninitialized
> whenever 'if' condition is false [-Werror,-Wsometimes-uninitialized]
>                 BUG_ON(1);
>                 ^~~~~~~~~
> include/asm-generic/bug.h:63:36: note: expanded from macro 'BUG_ON'
>  #define BUG_ON(condition) do { if (unlikely(condition)) BUG(); } while (0)
>                                    ^~~~~~~~~~~~~~~~~~~
> 
> Turn the BUG_ON(1) into an unconditional BUG() that makes it clear
> to clang that this code path is never hit.
> 
> Fixes: 4f3e900b6282 ("scsi: ufs: Clear UAC for FFU and RPMB LUNs")
> Signed-off-by: Arnd Bergmann <arnd@arndb.de>
Reviewed-by: Avri Altman <avri.altman@wdc.com>

> ---
>  drivers/scsi/ufs/ufshcd.c | 2 +-
>  1 file changed, 1 insertion(+), 1 deletion(-)
> 
> diff --git a/drivers/scsi/ufs/ufshcd.c b/drivers/scsi/ufs/ufshcd.c
> index f165baee937f..b4f7c4263334 100644
> --- a/drivers/scsi/ufs/ufshcd.c
> +++ b/drivers/scsi/ufs/ufshcd.c
> @@ -7687,7 +7687,7 @@ static int ufshcd_clear_ua_wlun(struct ufs_hba
> *hba, u8 wlun)
>         else if (wlun == UFS_UPIU_RPMB_WLUN)
>                 sdp = hba->sdev_rpmb;
>         else
> -               BUG_ON(1);
> +               BUG();
>         if (sdp) {
>                 ret = scsi_device_get(sdp);
>                 if (!ret && !scsi_device_online(sdp)) {
> --
> 2.27.0


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

* Re: [PATCH] ufshcd: fix Wsometimes-uninitialized warning
  2020-12-03 22:31 [PATCH] ufshcd: fix Wsometimes-uninitialized warning Arnd Bergmann
  2020-12-05  8:08 ` Avri Altman
  2020-12-05  8:11 ` Avri Altman
@ 2020-12-08  1:30 ` Martin K. Petersen
  2020-12-09 17:23 ` Martin K. Petersen
  3 siblings, 0 replies; 5+ messages in thread
From: Martin K. Petersen @ 2020-12-08  1:30 UTC (permalink / raw)
  To: Arnd Bergmann
  Cc: James E.J. Bottomley, Martin K. Petersen, Nathan Chancellor,
	Nick Desaulniers, Jaegeuk Kim, Arnd Bergmann, Alim Akhtar,
	Avri Altman, Stanley Chu, Can Guo, Asutosh Das, Bean Huo,
	Bart Van Assche, linux-scsi, linux-kernel, clang-built-linux


Arnd,

> clang complains about a possible code path in which a variable is
> used without an initialization:
>
> drivers/scsi/ufs/ufshcd.c:7690:3: error: variable 'sdp' is used uninitialized whenever 'if' condition is false [-Werror,-Wsometimes-uninitialized]
>                 BUG_ON(1);
>                 ^~~~~~~~~

Applied to 5.11/scsi-staging, thanks!

-- 
Martin K. Petersen	Oracle Linux Engineering

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

* Re: [PATCH] ufshcd: fix Wsometimes-uninitialized warning
  2020-12-03 22:31 [PATCH] ufshcd: fix Wsometimes-uninitialized warning Arnd Bergmann
                   ` (2 preceding siblings ...)
  2020-12-08  1:30 ` Martin K. Petersen
@ 2020-12-09 17:23 ` Martin K. Petersen
  3 siblings, 0 replies; 5+ messages in thread
From: Martin K. Petersen @ 2020-12-09 17:23 UTC (permalink / raw)
  To: Nathan Chancellor, Jaegeuk Kim, Nick Desaulniers,
	James E.J. Bottomley, Arnd Bergmann
  Cc: Martin K . Petersen, Stanley Chu, Asutosh Das, clang-built-linux,
	Can Guo, Avri Altman, Bean Huo, Bart Van Assche, linux-kernel,
	Alim Akhtar, linux-scsi, Arnd Bergmann

On Thu, 3 Dec 2020 23:31:26 +0100, Arnd Bergmann wrote:

> clang complains about a possible code path in which a variable is
> used without an initialization:
> 
> drivers/scsi/ufs/ufshcd.c:7690:3: error: variable 'sdp' is used uninitialized whenever 'if' condition is false [-Werror,-Wsometimes-uninitialized]
>                 BUG_ON(1);
>                 ^~~~~~~~~
> include/asm-generic/bug.h:63:36: note: expanded from macro 'BUG_ON'
>  #define BUG_ON(condition) do { if (unlikely(condition)) BUG(); } while (0)
>                                    ^~~~~~~~~~~~~~~~~~~
> 
> [...]

Applied to 5.11/scsi-queue, thanks!

[1/1] ufshcd: fix Wsometimes-uninitialized warning
      https://git.kernel.org/mkp/scsi/c/4c60244dc372

-- 
Martin K. Petersen	Oracle Linux Engineering

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

end of thread, other threads:[~2020-12-09 17:26 UTC | newest]

Thread overview: 5+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2020-12-03 22:31 [PATCH] ufshcd: fix Wsometimes-uninitialized warning Arnd Bergmann
2020-12-05  8:08 ` Avri Altman
2020-12-05  8:11 ` Avri Altman
2020-12-08  1:30 ` Martin K. Petersen
2020-12-09 17:23 ` Martin K. Petersen

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).