Skip to contentSkip to conversation

scsi: st: Add missing break in switch statement in st_ioctl()

PATCH Applied Nathan Chancellor 4 participants 5 messages Aug 17, 2021 – Sep 14, 2021

Subsystems (2)
lore
Share & tools
lore
#0 lore raw

PATCH 1/1 scsi: st: Add missing break in switch statement in st_ioctl()

Clang + -Wimplicit-fallthrough warns:

drivers/scsi/st.c:3831:2: warning: unannotated fall-through between switch labels [-Wimplicit-fallthrough]

        default:
        ^
drivers/scsi/st.c:3831:2: note: insert 'break;' to avoid fall-through
        default:
        ^
        break;

1 warning generated.

Clang's -Wimplicit-fallthrough is a little bit more pedantic than GCC's, requiring every case block to end in break, return, or fallthrough, rather than allowing implicit fallthroughs to cases that just contain break or return. Add a break so that there is no more warning, as has been done all over the tree already.

Fixes 2e27f576abc6 ("scsi: scsi_ioctl: Call scsi_cmd_ioctl() from scsi_ioctl()")
---
 drivers/scsi/st.c | 1 +
 1 file changed, 1 insertion(+)
drivers/scsi/st.c +1 -0
index 2d1b0594af69..0e36a36ed24d 100644
@@ -3828,6 +3828,7 @@ static long st_ioctl(struct file *file, unsigned int cmd_in, unsigned long arg)
 	case CDROM_SEND_PACKET:
 		if (!capable(CAP_SYS_RAWIO))
 			return -EPERM;
+		break;
 	default:
 		break;
 	}

base-commit: 58dd8f6e1cf8c47e81fbec9f47099772ab75278b

Signature · 1 line
2.33.0
Reviewed-by on v1 1/1
#1 lore raw
Quoted 12 lines · Nathan Chancellor

Clang + -Wimplicit-fallthrough warns:

drivers/scsi/st.c:3831:2: warning: unannotated fall-through between switch labels [-Wimplicit-fallthrough]

        default:
        ^
drivers/scsi/st.c:3831:2: note: insert 'break;' to avoid fall-through
        default:
        ^
        break;

1 warning generated.

Quoted 7 lines

Clang's -Wimplicit-fallthrough is a little bit more pedantic than GCC's, requiring every case block to end in break, return, or fallthrough, rather than allowing implicit fallthroughs to cases that just contain break or return. Add a break so that there is no more warning, as has been done all over the tree already.

Fixes 2e27f576abc6 ("scsi: scsi_ioctl: Call scsi_cmd_ioctl() from scsi_ioctl()")

I don't think this tag is needed for these patches.

Quoted 1 line

I also got the warnings in staging and ntfs3, I have the fixes for those in my local tree and I will commit them to my tree, soon.

Thanks
--
Gustavo

Quoted 19 lines
---
 drivers/scsi/st.c | 1 +
 1 file changed, 1 insertion(+)
drivers/scsi/st.c +1 -0
index 2d1b0594af69..0e36a36ed24d 100644
@@ -3828,6 +3828,7 @@ static long st_ioctl(struct file *file, unsigned int cmd_in, unsigned long arg)
 	case CDROM_SEND_PACKET:
 		if (!capable(CAP_SYS_RAWIO))
 			return -EPERM;
+		break;
 	default:
 		break;
 	}

base-commit: 58dd8f6e1cf8c47e81fbec9f47099772ab75278b

#2 lore raw
In reply to Nathan Chancellor
Quoted 37 lines · Nathan Chancellor

Clang + -Wimplicit-fallthrough warns:

drivers/scsi/st.c:3831:2: warning: unannotated fall-through between switch labels [-Wimplicit-fallthrough]

        default:
        ^
drivers/scsi/st.c:3831:2: note: insert 'break;' to avoid fall-through
        default:
        ^
        break;

1 warning generated.

Clang's -Wimplicit-fallthrough is a little bit more pedantic than GCC's, requiring every case block to end in break, return, or fallthrough, rather than allowing implicit fallthroughs to cases that just contain break or return. Add a break so that there is no more warning, as has been done all over the tree already.

Fixes 2e27f576abc6 ("scsi: scsi_ioctl: Call scsi_cmd_ioctl() from scsi_ioctl()")
---
 drivers/scsi/st.c | 1 +
 1 file changed, 1 insertion(+)
drivers/scsi/st.c +1 -0
index 2d1b0594af69..0e36a36ed24d 100644
@@ -3828,6 +3828,7 @@ static long st_ioctl(struct file *file, unsigned int cmd_in, unsigned long arg)
 	case CDROM_SEND_PACKET:
 		if (!capable(CAP_SYS_RAWIO))
 			return -EPERM;
+		break;
 	default:
 		break;
 	}
Quoted 2 lines

base-commit: 58dd8f6e1cf8c47e81fbec9f47099772ab75278b

Well, that sure is ugly.

Do you think the following change would cause any static checkers to spit their dummys and throw their toys out of the pram?

@@ -3828,6 +3828,7 @@ static long st_ioctl(struct file *file, unsigned int cmd_in, unsigned long arg)
case CDROM_SEND_PACKET:
if (!capable(CAP_SYS_RAWIO))
return -EPERM;
+ break;
- default:
- break;
}

#3 lore raw
Quoted 49 lines · Finn Thain
Quoted 37 lines · Nathan Chancellor

Clang + -Wimplicit-fallthrough warns:

drivers/scsi/st.c:3831:2: warning: unannotated fall-through between switch labels [-Wimplicit-fallthrough]

         default:
         ^
drivers/scsi/st.c:3831:2: note: insert 'break;' to avoid fall-through
         default:
         ^
         break;

1 warning generated.

Clang's -Wimplicit-fallthrough is a little bit more pedantic than GCC's, requiring every case block to end in break, return, or fallthrough, rather than allowing implicit fallthroughs to cases that just contain break or return. Add a break so that there is no more warning, as has been done all over the tree already.

Fixes 2e27f576abc6 ("scsi: scsi_ioctl: Call scsi_cmd_ioctl() from scsi_ioctl()")
---
  drivers/scsi/st.c | 1 +
  1 file changed, 1 insertion(+)
drivers/scsi/st.c +1 -0
index 2d1b0594af69..0e36a36ed24d 100644
@@ -3828,6 +3828,7 @@ static long st_ioctl(struct file *file, unsigned int cmd_in, unsigned long arg)
  	case CDROM_SEND_PACKET:
  		if (!capable(CAP_SYS_RAWIO))
  			return -EPERM;
+		break;
  	default:
  		break;
  	}
Quoted 2 lines

base-commit: 58dd8f6e1cf8c47e81fbec9f47099772ab75278b

Well, that sure is ugly.

Do you think the following change would cause any static checkers to spit their dummys and throw their toys out of the pram?

drivers/scsi/st.c static long st_ioctl(struct file *file, unsigned int cmd_in, unsigned long arg) · line 3832

Quoted 7 lines
drivers/scsi/st.c +1 -2
@@ -3828,6 +3828,7 @@ static long st_ioctl(struct file *file, unsigned int cmd_in, unsigned long arg)
  	case CDROM_SEND_PACKET:
  		if (!capable(CAP_SYS_RAWIO))
  			return -EPERM;
+		break;
-	default:
-		break;
  	}

I cannot speak for other static checkers but clang does not complain in this instance. cmd_in is the switch value, which is unsigned int; as far as I am aware, clang will only complain about a switch not handling all values when switching on an enumerated type.

Gustavo, if you are already handling all of the other warnings in -next, do you want to take this one too?

Cheers,
Nathan

#4 lore raw
In reply to Nathan Chancellor
Quoted 10 lines · Nathan Chancellor

Clang + -Wimplicit-fallthrough warns:

drivers/scsi/st.c:3831:2: warning: unannotated fall-through between switch labels [-Wimplicit-fallthrough]

        default:
        ^
drivers/scsi/st.c:3831:2: note: insert 'break;' to avoid fall-through
        default:
        ^
        break;
Quoted 3 lines

1 warning generated.

[...]

Applied to 5.15/scsi-fixes, thanks!

[1/1] scsi: st: Add missing break in switch statement in st_ioctl()

      https://git.kernel.org/mkp/scsi/c/6a2ea0d34af1
Signature · 1 line
Martin K. Petersen	Oracle Linux Engineering