[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-Id: <20251119224140.8616-25-david.laight.linux@gmail.com>
Date: Wed, 19 Nov 2025 22:41:20 +0000
From: david.laight.linux@...il.com
To: linux-kernel@...r.kernel.org
Cc: Srinivas Kandagatla <srini@...nel.org>,
David Laight <david.laight.linux@...il.com>
Subject: [PATCH 24/44] drivers/nvmem: use min() instead of min_t()
From: David Laight <david.laight.linux@...il.com>
min_t(unsigned int, a, b) casts an 'unsigned long' to 'unsigned int'.
Use min(a, b) instead as it promotes any 'unsigned int' to 'unsigned long'
and so cannot discard significant bits.
In this case the 'unsigned long' value is small enough that the result
is ok.
Detected by an extra check added to min_t().
Signed-off-by: David Laight <david.laight.linux@...il.com>
---
drivers/nvmem/core.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/drivers/nvmem/core.c b/drivers/nvmem/core.c
index 387c88c55259..8d6e78343054 100644
--- a/drivers/nvmem/core.c
+++ b/drivers/nvmem/core.c
@@ -359,7 +359,7 @@ static ssize_t nvmem_cell_attr_read(struct file *filp, struct kobject *kobj,
goto destroy_cell;
}
- read_len = min_t(unsigned int, cell_sz - pos, count);
+ read_len = min(cell_sz - pos, count);
memcpy(buf, content + pos, read_len);
kfree(content);
--
2.39.5
Powered by blists - more mailing lists