Re: [PATCH] loop: avoid out-of-range warning

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



Thanks!

On Mon, Sep 27, 2021 at 11:43 AM Arnd Bergmann <arnd@xxxxxxxxxx> wrote:
>
> From: Arnd Bergmann <arnd@xxxxxxxx>
>
> clang warns that the sanity check for page size always succeeds
> when building with 64KB pages:
>
> drivers/block/loop.c:282:27: error: result of comparison of constant 65536 with expression of type 'unsigned short' is always false [-Werror,-Wtautological-constant-out-of-range-compare]
>         if (bsize < 512 || bsize > PAGE_SIZE || !is_power_of_2(bsize))
>                            ~~~~~ ^ ~~~~~~~~~
>
> There is nothing wrong here, so just shut up the check by changing
> the type of the bsize argument.
>
> Fixes: 3448914e8cc5 ("loop: Add LOOP_CONFIGURE ioctl")
> Signed-off-by: Arnd Bergmann <arnd@xxxxxxxx>
Reviewed-by: Martijkn Coenen <maco@xxxxxxxxxxx>

> ---
>  drivers/block/loop.c | 2 +-
>  1 file changed, 1 insertion(+), 1 deletion(-)
>
> diff --git a/drivers/block/loop.c b/drivers/block/loop.c
> index 7bf4686af774..51315a93b399 100644
> --- a/drivers/block/loop.c
> +++ b/drivers/block/loop.c
> @@ -277,7 +277,7 @@ static void __loop_update_dio(struct loop_device *lo, bool dio)
>   * @bsize: size to validate
>   */
>  static int
> -loop_validate_block_size(unsigned short bsize)
> +loop_validate_block_size(unsigned int bsize)
>  {
>         if (bsize < 512 || bsize > PAGE_SIZE || !is_power_of_2(bsize))
>                 return -EINVAL;
> --
> 2.29.2
>



[Index of Archives]     [Linux RAID]     [Linux SCSI]     [Linux ATA RAID]     [IDE]     [Linux Wireless]     [Linux Kernel]     [ATH6KL]     [Linux Bluetooth]     [Linux Netdev]     [Kernel Newbies]     [Security]     [Git]     [Netfilter]     [Bugtraq]     [Yosemite News]     [MIPS Linux]     [ARM Linux]     [Linux Security]     [Device Mapper]

  Powered by Linux