[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <ab2b4573-58ce-d895-0aae-69e3647e0a68@huawei.com>
Date: Tue, 27 Feb 2024 10:23:17 +0800
From: Zhihao Cheng <chengzhihao1@...wei.com>
To: Daniel Golle <daniel@...rotopia.org>, Richard Weinberger <richard@....at>,
Miquel Raynal <miquel.raynal@...tlin.com>, Vignesh Raghavendra
<vigneshr@...com>, <linux-mtd@...ts.infradead.org>,
<linux-kernel@...r.kernel.org>
Subject: Re: [PATCH] mtd: ubi: fix NVMEM over UBI volumes on 32-bit systems
在 2024/2/27 2:23, Daniel Golle 写道:
> A compiler warning related to sizeof(int) != 8 when calling do_div()
> is triggered when building on 32-bit platforms.
> Address this by using integer types having a well-defined size where
> appropriate.
>
> Fixes: 3ce485803da1 ("mtd: ubi: provide NVMEM layer over UBI volumes")
> Signed-off-by: Daniel Golle <daniel@...rotopia.org>
> ---
> drivers/mtd/ubi/nvmem.c | 5 ++++-
> 1 file changed, 4 insertions(+), 1 deletion(-)
>
> diff --git a/drivers/mtd/ubi/nvmem.c b/drivers/mtd/ubi/nvmem.c
> index b7a93c495d172..5820a170d2512 100644
> --- a/drivers/mtd/ubi/nvmem.c
> +++ b/drivers/mtd/ubi/nvmem.c
> @@ -23,14 +23,17 @@ struct ubi_nvmem {
> static int ubi_nvmem_reg_read(void *priv, unsigned int from,
> void *val, size_t bytes)
> {
> - int err = 0, lnum = from, offs, bytes_left = bytes, to_read;
> + uint32_t bytes_left, offs, to_read;
> struct ubi_nvmem *unv = priv;
> struct ubi_volume_desc *desc;
> + uint64_t lnum = from;
> + int err = 0;
>
> desc = ubi_open_volume(unv->ubi_num, unv->vol_id, UBI_READONLY);
> if (IS_ERR(desc))
> return PTR_ERR(desc);
>
> + bytes_left = bytes;
The 'bytes' is a size_t type, which has 64 bits on 64-bit platforms.
This assignment will lead a type truncation, so should we add a explicit
type conversion here to avoid compiler warning?
> offs = do_div(lnum, unv->usable_leb_size);
> while (bytes_left) {
> to_read = unv->usable_leb_size - offs;
>
Powered by blists - more mailing lists