Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

memstick: avoid out-of-range warning

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>
Link: https://lore.kernel.org/r/20210927094520.696665-1-arnd@kernel.org
Signed-off-by: Ulf Hansson <ulf.hansson@linaro.org>

authored by

Arnd Bergmann and committed by
Ulf Hansson
4853396f 7f00917a

+1 -1
+1 -1
drivers/memstick/core/ms_block.c
··· 1736 1736 msb->pages_in_block = boot_block->attr.block_size * 2; 1737 1737 msb->block_size = msb->page_size * msb->pages_in_block; 1738 1738 1739 - if (msb->page_size > PAGE_SIZE) { 1739 + if ((size_t)msb->page_size > PAGE_SIZE) { 1740 1740 /* this isn't supported by linux at all, anyway*/ 1741 1741 dbg("device page %d size isn't supported", msb->page_size); 1742 1742 return -EINVAL;