* [PATCH v3] mtd: ubi: fix NVMEM over UBI volumes on 32-bit systems
@ 2024-02-29 3:47 Daniel Golle
2024-02-29 4:04 ` Zhihao Cheng
2024-02-29 6:01 ` Randy Dunlap
0 siblings, 2 replies; 3+ messages in thread
From: Daniel Golle @ 2024-02-29 3:47 UTC (permalink / raw)
To: Richard Weinberger, Zhihao Cheng, Miquel Raynal,
Vignesh Raghavendra, Daniel Golle, linux-mtd, linux-kernel
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.
Fixes: 3ce485803da1 ("mtd: ubi: provide NVMEM layer over UBI volumes")
Signed-off-by: Daniel Golle <daniel@makrotopia.org>
---
v3: use size_t also for 'to_read' variable to avoid truncation
(no problem in practise beyond the compiler warning)
v2: use size_t for 'bytes_left' variable to match parameter type
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..8aeb9c428e510 100644
--- a/drivers/mtd/ubi/nvmem.c
+++ b/drivers/mtd/ubi/nvmem.c
@@ -23,9 +23,12 @@ 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;
+ size_t to_read, bytes_left = bytes;
struct ubi_nvmem *unv = priv;
struct ubi_volume_desc *desc;
+ uint32_t offs;
+ uint64_t lnum = from;
+ int err = 0;
desc = ubi_open_volume(unv->ubi_num, unv->vol_id, UBI_READONLY);
if (IS_ERR(desc))
--
2.44.0
^ permalink raw reply [flat|nested] 3+ messages in thread* Re: [PATCH v3] mtd: ubi: fix NVMEM over UBI volumes on 32-bit systems
2024-02-29 3:47 [PATCH v3] mtd: ubi: fix NVMEM over UBI volumes on 32-bit systems Daniel Golle
@ 2024-02-29 4:04 ` Zhihao Cheng
2024-02-29 6:01 ` Randy Dunlap
1 sibling, 0 replies; 3+ messages in thread
From: Zhihao Cheng @ 2024-02-29 4:04 UTC (permalink / raw)
To: Daniel Golle, Richard Weinberger, Miquel Raynal,
Vignesh Raghavendra, linux-mtd, linux-kernel
在 2024/2/29 11:47, 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.
>
> Fixes: 3ce485803da1 ("mtd: ubi: provide NVMEM layer over UBI volumes")
> Signed-off-by: Daniel Golle <daniel@makrotopia.org>
> ---
> v3: use size_t also for 'to_read' variable to avoid truncation
> (no problem in practise beyond the compiler warning)
> v2: use size_t for 'bytes_left' variable to match parameter type
>
> drivers/mtd/ubi/nvmem.c | 5 ++++-
> 1 file changed, 4 insertions(+), 1 deletion(-)
>
Reviewed-by: Zhihao Cheng <chengzhihao1@huawei.com>
> diff --git a/drivers/mtd/ubi/nvmem.c b/drivers/mtd/ubi/nvmem.c
> index b7a93c495d172..8aeb9c428e510 100644
> --- a/drivers/mtd/ubi/nvmem.c
> +++ b/drivers/mtd/ubi/nvmem.c
> @@ -23,9 +23,12 @@ 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;
> + size_t to_read, bytes_left = bytes;
> struct ubi_nvmem *unv = priv;
> struct ubi_volume_desc *desc;
> + uint32_t offs;
> + uint64_t lnum = from;
> + int err = 0;
>
> desc = ubi_open_volume(unv->ubi_num, unv->vol_id, UBI_READONLY);
> if (IS_ERR(desc))
>
^ permalink raw reply [flat|nested] 3+ messages in thread* Re: [PATCH v3] mtd: ubi: fix NVMEM over UBI volumes on 32-bit systems
2024-02-29 3:47 [PATCH v3] mtd: ubi: fix NVMEM over UBI volumes on 32-bit systems Daniel Golle
2024-02-29 4:04 ` Zhihao Cheng
@ 2024-02-29 6:01 ` Randy Dunlap
1 sibling, 0 replies; 3+ messages in thread
From: Randy Dunlap @ 2024-02-29 6:01 UTC (permalink / raw)
To: Daniel Golle, Richard Weinberger, Zhihao Cheng, Miquel Raynal,
Vignesh Raghavendra, linux-mtd, linux-kernel
On 2/28/24 19:47, Daniel Golle wrote:
> 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.
>
> Fixes: 3ce485803da1 ("mtd: ubi: provide NVMEM layer over UBI volumes")
> Signed-off-by: Daniel Golle <daniel@makrotopia.org>
> ---
> v3: use size_t also for 'to_read' variable to avoid truncation
> (no problem in practise beyond the compiler warning)
> v2: use size_t for 'bytes_left' variable to match parameter type
>
> drivers/mtd/ubi/nvmem.c | 5 ++++-
> 1 file changed, 4 insertions(+), 1 deletion(-)
>
Works for me. Thanks.
Tested-by: Randy Dunlap <rdunlap@infradead.org>
--
#Randy
^ permalink raw reply [flat|nested] 3+ messages in thread
end of thread, other threads:[~2024-02-29 6:01 UTC | newest]
Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2024-02-29 3:47 [PATCH v3] mtd: ubi: fix NVMEM over UBI volumes on 32-bit systems Daniel Golle
2024-02-29 4:04 ` Zhihao Cheng
2024-02-29 6:01 ` Randy Dunlap
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox
all inboxes | Powered by JetHome®