* [PATCH] memstick: avoid out-of-range warning
@ 2021-09-27 9:44 Arnd Bergmann
2021-09-27 22:32 ` Ulf Hansson
0 siblings, 1 reply; 3+ messages in thread
From: Arnd Bergmann @ 2021-09-27 9:44 UTC (permalink / raw)
To: Maxim Levitsky, Alex Dubov, Ulf Hansson
Cc: Arnd Bergmann, Nathan Chancellor, Nick Desaulniers, Jens Axboe,
Andrew Morton, linux-mmc, linux-kernel, llvm
From: Arnd Bergmann <arnd@arndb.de>
clang-14 complains about a sanity check that always passes when the
page size is 64KB or larger:
drivers/memstick/core/ms_block.c:1739:21: error: result of comparison of constant 65536 with expression of type 'unsigned short' is always false [-Werror,-Wtautological-constant-out-of-range-compare]
if (msb->page_size > PAGE_SIZE) {
~~~~~~~~~~~~~~ ^ ~~~~~~~~~
This is fine, it will still work on all architectures, so just shut
up that warning with a cast.
Fixes: 0ab30494bc4f ("memstick: add support for legacy memorysticks")
Signed-off-by: Arnd Bergmann <arnd@arndb.de>
---
drivers/memstick/core/ms_block.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/drivers/memstick/core/ms_block.c b/drivers/memstick/core/ms_block.c
index acf36676e388..487e4cc2951e 100644
--- a/drivers/memstick/core/ms_block.c
+++ b/drivers/memstick/core/ms_block.c
@@ -1736,7 +1736,7 @@ static int msb_init_card(struct memstick_dev *card)
msb->pages_in_block = boot_block->attr.block_size * 2;
msb->block_size = msb->page_size * msb->pages_in_block;
- if (msb->page_size > PAGE_SIZE) {
+ if ((size_t)msb->page_size > PAGE_SIZE) {
/* this isn't supported by linux at all, anyway*/
dbg("device page %d size isn't supported", msb->page_size);
return -EINVAL;
--
2.29.2
^ permalink raw reply related [flat|nested] 3+ messages in thread
* Re: [PATCH] memstick: avoid out-of-range warning
2021-09-27 9:44 [PATCH] memstick: avoid out-of-range warning Arnd Bergmann
@ 2021-09-27 22:32 ` Ulf Hansson
0 siblings, 0 replies; 3+ messages in thread
From: Ulf Hansson @ 2021-09-27 22:32 UTC (permalink / raw)
To: Arnd Bergmann
Cc: Maxim Levitsky, Alex Dubov, Arnd Bergmann, Nathan Chancellor,
Nick Desaulniers, Jens Axboe, Andrew Morton, linux-mmc,
Linux Kernel Mailing List, llvm
On Mon, 27 Sept 2021 at 11:45, Arnd Bergmann <arnd@kernel.org> wrote:
>
> From: Arnd Bergmann <arnd@arndb.de>
>
> clang-14 complains about a sanity check that always passes when the
> page size is 64KB or larger:
>
> drivers/memstick/core/ms_block.c:1739:21: error: result of comparison of constant 65536 with expression of type 'unsigned short' is always false [-Werror,-Wtautological-constant-out-of-range-compare]
> if (msb->page_size > PAGE_SIZE) {
> ~~~~~~~~~~~~~~ ^ ~~~~~~~~~
>
> This is fine, it will still work on all architectures, so just shut
> up that warning with a cast.
>
> Fixes: 0ab30494bc4f ("memstick: add support for legacy memorysticks")
> Signed-off-by: Arnd Bergmann <arnd@arndb.de>
Applied for next, thanks!
Kind regards
Uffe
> ---
> drivers/memstick/core/ms_block.c | 2 +-
> 1 file changed, 1 insertion(+), 1 deletion(-)
>
> diff --git a/drivers/memstick/core/ms_block.c b/drivers/memstick/core/ms_block.c
> index acf36676e388..487e4cc2951e 100644
> --- a/drivers/memstick/core/ms_block.c
> +++ b/drivers/memstick/core/ms_block.c
> @@ -1736,7 +1736,7 @@ static int msb_init_card(struct memstick_dev *card)
> msb->pages_in_block = boot_block->attr.block_size * 2;
> msb->block_size = msb->page_size * msb->pages_in_block;
>
> - if (msb->page_size > PAGE_SIZE) {
> + if ((size_t)msb->page_size > PAGE_SIZE) {
> /* this isn't supported by linux at all, anyway*/
> dbg("device page %d size isn't supported", msb->page_size);
> return -EINVAL;
> --
> 2.29.2
>
^ permalink raw reply [flat|nested] 3+ messages in thread
* Re: [PATCH] memstick: avoid out-of-range warning
@ 2021-09-27 22:32 ` Ulf Hansson
0 siblings, 0 replies; 3+ messages in thread
From: Ulf Hansson @ 2021-09-27 22:32 UTC (permalink / raw)
To: Arnd Bergmann
Cc: Maxim Levitsky, Alex Dubov, Arnd Bergmann, Nathan Chancellor,
Nick Desaulniers, Jens Axboe, Andrew Morton, linux-mmc,
Linux Kernel Mailing List, llvm
On Mon, 27 Sept 2021 at 11:45, Arnd Bergmann <arnd@kernel.org> wrote:
>
> From: Arnd Bergmann <arnd@arndb.de>
>
> clang-14 complains about a sanity check that always passes when the
> page size is 64KB or larger:
>
> drivers/memstick/core/ms_block.c:1739:21: error: result of comparison of constant 65536 with expression of type 'unsigned short' is always false [-Werror,-Wtautological-constant-out-of-range-compare]
> if (msb->page_size > PAGE_SIZE) {
> ~~~~~~~~~~~~~~ ^ ~~~~~~~~~
>
> This is fine, it will still work on all architectures, so just shut
> up that warning with a cast.
>
> Fixes: 0ab30494bc4f ("memstick: add support for legacy memorysticks")
> Signed-off-by: Arnd Bergmann <arnd@arndb.de>
Applied for next, thanks!
Kind regards
Uffe
> ---
> drivers/memstick/core/ms_block.c | 2 +-
> 1 file changed, 1 insertion(+), 1 deletion(-)
>
> diff --git a/drivers/memstick/core/ms_block.c b/drivers/memstick/core/ms_block.c
> index acf36676e388..487e4cc2951e 100644
> --- a/drivers/memstick/core/ms_block.c
> +++ b/drivers/memstick/core/ms_block.c
> @@ -1736,7 +1736,7 @@ static int msb_init_card(struct memstick_dev *card)
> msb->pages_in_block = boot_block->attr.block_size * 2;
> msb->block_size = msb->page_size * msb->pages_in_block;
>
> - if (msb->page_size > PAGE_SIZE) {
> + if ((size_t)msb->page_size > PAGE_SIZE) {
> /* this isn't supported by linux at all, anyway*/
> dbg("device page %d size isn't supported", msb->page_size);
> return -EINVAL;
> --
> 2.29.2
>
^ permalink raw reply [flat|nested] 3+ messages in thread
end of thread, other threads:[~2021-09-27 22:33 UTC | newest]
Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2021-09-27 9:44 [PATCH] memstick: avoid out-of-range warning Arnd Bergmann
2021-09-27 22:32 ` Ulf Hansson
2021-09-27 22:32 ` Ulf Hansson
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.