Skip to contentSkip to conversation

ufshcd: fix Wsometimes-uninitialized warning

PATCH Applied Arnd Bergmann 3 participants 5 messages Dec 3, 2020 – Dec 9, 2020 SCSI

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 ufshcd: fix Wsometimes-uninitialized warning

From: Arnd Bergmann <[email protected]>

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")
---
 drivers/scsi/ufs/ufshcd.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/scsi/ufs/ufshcd.c +1 -1
index f165baee937f..b4f7c4263334 100644
@@ -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)) {
Signature · 1 line
2.27.0
Reviewed-by on v1 1/1
#1 lore raw
Quoted 15 lines

From: Arnd Bergmann <[email protected]>

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)
                                   ^~~~~~~~~~~~~~~~~~~
Quoted 5 lines

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")
Quoted 20 lines
---
 drivers/scsi/ufs/ufshcd.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/scsi/ufs/ufshcd.c +1 -1
index f165baee937f..b4f7c4263334 100644
@@ -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

Reviewed-by on v1 1/1
#2 lore raw
In reply to Arnd Bergmann
Quoted 15 lines

From: Arnd Bergmann <[email protected]>

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)
                                   ^~~~~~~~~~~~~~~~~~~
Quoted 5 lines

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")
Quoted 20 lines
---
 drivers/scsi/ufs/ufshcd.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/scsi/ufs/ufshcd.c +1 -1
index f165baee937f..b4f7c4263334 100644
@@ -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

#3 lore raw
In reply to Arnd Bergmann

Arnd,

Quoted 6 lines

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!

Signature · 1 line
Martin K. Petersen	Oracle Linux Engineering
#4 lore raw
In reply to Arnd Bergmann
Quoted 11 lines · Arnd Bergmann

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
Signature · 1 line
Martin K. Petersen	Oracle Linux Engineering