All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH] scsi: st: Add missing break in switch statement in st_ioctl()
@ 2021-08-17 23:55 Nathan Chancellor
  2021-08-18  0:06 ` Gustavo A. R. Silva
                   ` (2 more replies)
  0 siblings, 3 replies; 5+ messages in thread
From: Nathan Chancellor @ 2021-08-17 23:55 UTC (permalink / raw)
  To: Kai Mäkisara, James E.J. Bottomley, Martin K. Petersen,
	Gustavo A. R. Silva
  Cc: Nick Desaulniers, linux-scsi, linux-kernel, clang-built-linux,
	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()")
Signed-off-by: Nathan Chancellor <nathan@kernel.org>
---
 drivers/scsi/st.c | 1 +
 1 file changed, 1 insertion(+)

diff --git a/drivers/scsi/st.c b/drivers/scsi/st.c
index 2d1b0594af69..0e36a36ed24d 100644
--- a/drivers/scsi/st.c
+++ b/drivers/scsi/st.c
@@ -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.33.0


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

* Re: [PATCH] scsi: st: Add missing break in switch statement in st_ioctl()
  2021-08-17 23:55 [PATCH] scsi: st: Add missing break in switch statement in st_ioctl() Nathan Chancellor
@ 2021-08-18  0:06 ` Gustavo A. R. Silva
  2021-08-18  0:54 ` Finn Thain
  2021-09-14  3:43 ` Martin K. Petersen
  2 siblings, 0 replies; 5+ messages in thread
From: Gustavo A. R. Silva @ 2021-08-18  0:06 UTC (permalink / raw)
  To: Nathan Chancellor, Kai Mäkisara, James E.J. Bottomley,
	Martin K. Petersen, Gustavo A. R. Silva
  Cc: Nick Desaulniers, linux-scsi, linux-kernel, clang-built-linux



On 8/17/21 18:55, Nathan Chancellor wrote:
> 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()")

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

> Signed-off-by: Nathan Chancellor <nathan@kernel.org>

Reviewed-by: Gustavo A. R. Silva <gustavoars@kernel.org>

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

> ---
>  drivers/scsi/st.c | 1 +
>  1 file changed, 1 insertion(+)
> 
> diff --git a/drivers/scsi/st.c b/drivers/scsi/st.c
> index 2d1b0594af69..0e36a36ed24d 100644
> --- a/drivers/scsi/st.c
> +++ b/drivers/scsi/st.c
> @@ -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
> 

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

* Re: [PATCH] scsi: st: Add missing break in switch statement in st_ioctl()
  2021-08-17 23:55 [PATCH] scsi: st: Add missing break in switch statement in st_ioctl() Nathan Chancellor
  2021-08-18  0:06 ` Gustavo A. R. Silva
@ 2021-08-18  0:54 ` Finn Thain
  2021-08-18  1:12   ` Nathan Chancellor
  2021-09-14  3:43 ` Martin K. Petersen
  2 siblings, 1 reply; 5+ messages in thread
From: Finn Thain @ 2021-08-18  0:54 UTC (permalink / raw)
  To: Nathan Chancellor
  Cc: Kai Mäkisara, James E.J. Bottomley, Martin K. Petersen,
	Gustavo A. R. Silva, Nick Desaulniers, linux-scsi, linux-kernel,
	clang-built-linux

On Tue, 17 Aug 2021, Nathan Chancellor wrote:

> 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()")
> Signed-off-by: Nathan Chancellor <nathan@kernel.org>
> ---
>  drivers/scsi/st.c | 1 +
>  1 file changed, 1 insertion(+)
> 
> diff --git a/drivers/scsi/st.c b/drivers/scsi/st.c
> index 2d1b0594af69..0e36a36ed24d 100644
> --- a/drivers/scsi/st.c
> +++ b/drivers/scsi/st.c
> @@ -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
> 

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;
 	}
 	

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

* Re: [PATCH] scsi: st: Add missing break in switch statement in st_ioctl()
  2021-08-18  0:54 ` Finn Thain
@ 2021-08-18  1:12   ` Nathan Chancellor
  0 siblings, 0 replies; 5+ messages in thread
From: Nathan Chancellor @ 2021-08-18  1:12 UTC (permalink / raw)
  To: Finn Thain
  Cc: Kai Mäkisara, James E.J. Bottomley, Martin K. Petersen,
	Gustavo A. R. Silva, Nick Desaulniers, linux-scsi, linux-kernel,
	clang-built-linux

On 8/17/2021 5:54 PM, Finn Thain wrote:
> On Tue, 17 Aug 2021, Nathan Chancellor wrote:
> 
>> 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()")
>> Signed-off-by: Nathan Chancellor <nathan@kernel.org>
>> ---
>>   drivers/scsi/st.c | 1 +
>>   1 file changed, 1 insertion(+)
>>
>> diff --git a/drivers/scsi/st.c b/drivers/scsi/st.c
>> index 2d1b0594af69..0e36a36ed24d 100644
>> --- a/drivers/scsi/st.c
>> +++ b/drivers/scsi/st.c
>> @@ -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
>>
> 
> 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;
>   	}
>   	

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

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

* Re: [PATCH] scsi: st: Add missing break in switch statement in st_ioctl()
  2021-08-17 23:55 [PATCH] scsi: st: Add missing break in switch statement in st_ioctl() Nathan Chancellor
  2021-08-18  0:06 ` Gustavo A. R. Silva
  2021-08-18  0:54 ` Finn Thain
@ 2021-09-14  3:43 ` Martin K. Petersen
  2 siblings, 0 replies; 5+ messages in thread
From: Martin K. Petersen @ 2021-09-14  3:43 UTC (permalink / raw)
  To: Kai Mäkisara, Nathan Chancellor, James E.J. Bottomley,
	Gustavo A. R. Silva
  Cc: Martin K . Petersen, linux-scsi, clang-built-linux, linux-kernel,
	Nick Desaulniers

On Tue, 17 Aug 2021 16:55:31 -0700, Nathan Chancellor wrote:

> 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.
> 
> [...]

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

-- 
Martin K. Petersen	Oracle Linux Engineering

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

end of thread, other threads:[~2021-09-14  3:45 UTC | newest]

Thread overview: 5+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2021-08-17 23:55 [PATCH] scsi: st: Add missing break in switch statement in st_ioctl() Nathan Chancellor
2021-08-18  0:06 ` Gustavo A. R. Silva
2021-08-18  0:54 ` Finn Thain
2021-08-18  1:12   ` Nathan Chancellor
2021-09-14  3:43 ` 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.