linux-riscv.lists.infradead.org archive mirror
 help / color / mirror / Atom feed
* [PATCH] nvmem: jz4780-efuse: fix build warnings on ARCH=x86_64 or riscv
@ 2020-03-06 19:17 H. Nikolaus Schaller
  2020-03-09 13:52 ` Srinivas Kandagatla
  0 siblings, 1 reply; 2+ messages in thread
From: H. Nikolaus Schaller @ 2020-03-06 19:17 UTC (permalink / raw)
  To: PrasannaKumar Muralidharan, Srinivas Kandagatla, Paul Walmsley,
	Palmer Dabbelt, Albert Ou
  Cc: Stephen Rothwell, kbuild test robot, malat, H. Nikolaus Schaller,
	linux-kernel, paul, linux-riscv, letux-kernel

kbuild-robot did find a type error in the min(a, b)
function used by this driver if built for x86_64 or riscv.

Althought it is very unlikely that this driver is built
for those platforms it could be used as a template
for something else and therefore should be correct.

The problem is that we implicitly cast a size_t to
unsigned int inside the implementation of the min() function.

Since size_t may differ on different compilers and
plaforms there may be warnings or not.

So let's use only size_t variables on all platforms.

Reported-by: kbuild test robot <lkp@intel.com>
Reported-by: Stephen Rothwell <sfr@canb.auug.org.au>
Cc: srinivas.kandagatla@linaro.org
Cc: prasannatsmkumar@gmail.com
Cc: malat@debian.org
Cc: paul@crapouillou.net
Signed-off-by: H. Nikolaus Schaller <hns@goldelico.com>
---
 drivers/nvmem/jz4780-efuse.c | 6 +++---
 1 file changed, 3 insertions(+), 3 deletions(-)

diff --git a/drivers/nvmem/jz4780-efuse.c b/drivers/nvmem/jz4780-efuse.c
index 51d140980b1e..512e1872ba36 100644
--- a/drivers/nvmem/jz4780-efuse.c
+++ b/drivers/nvmem/jz4780-efuse.c
@@ -72,9 +72,9 @@ static int jz4780_efuse_read(void *context, unsigned int offset,
 	struct jz4780_efuse *efuse = context;
 
 	while (bytes > 0) {
-		unsigned int start = offset & ~(JZ_EFU_READ_SIZE - 1);
-		unsigned int chunk = min(bytes, (start + JZ_EFU_READ_SIZE)
-					 - offset);
+		size_t start = offset & ~(JZ_EFU_READ_SIZE - 1);
+		size_t chunk = min(bytes, (start + JZ_EFU_READ_SIZE)
+				    - offset);
 		char buf[JZ_EFU_READ_SIZE];
 		unsigned int tmp;
 		u32 ctrl;
-- 
2.23.0



^ permalink raw reply related	[flat|nested] 2+ messages in thread

* Re: [PATCH] nvmem: jz4780-efuse: fix build warnings on ARCH=x86_64 or riscv
  2020-03-06 19:17 [PATCH] nvmem: jz4780-efuse: fix build warnings on ARCH=x86_64 or riscv H. Nikolaus Schaller
@ 2020-03-09 13:52 ` Srinivas Kandagatla
  0 siblings, 0 replies; 2+ messages in thread
From: Srinivas Kandagatla @ 2020-03-09 13:52 UTC (permalink / raw)
  To: H. Nikolaus Schaller, PrasannaKumar Muralidharan, Paul Walmsley,
	Palmer Dabbelt, Albert Ou
  Cc: Stephen Rothwell, kbuild test robot, malat, linux-kernel, paul,
	linux-riscv, letux-kernel



On 06/03/2020 19:17, H. Nikolaus Schaller wrote:
> kbuild-robot did find a type error in the min(a, b)
> function used by this driver if built for x86_64 or riscv.
> 
> Althought it is very unlikely that this driver is built
> for those platforms it could be used as a template
> for something else and therefore should be correct.
> 
> The problem is that we implicitly cast a size_t to
> unsigned int inside the implementation of the min() function.
> 
> Since size_t may differ on different compilers and
> plaforms there may be warnings or not.
> 
> So let's use only size_t variables on all platforms.
> 
> Reported-by: kbuild test robot <lkp@intel.com>
> Reported-by: Stephen Rothwell <sfr@canb.auug.org.au>
> Cc: srinivas.kandagatla@linaro.org
> Cc: prasannatsmkumar@gmail.com
> Cc: malat@debian.org
> Cc: paul@crapouillou.net
> Signed-off-by: H. Nikolaus Schaller <hns@goldelico.com>
> ---
>   drivers/nvmem/jz4780-efuse.c | 6 +++---
>   1 file changed, 3 insertions(+), 3 deletions(-)
> 

Applied thanks,
srini


^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2020-03-09 13:53 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2020-03-06 19:17 [PATCH] nvmem: jz4780-efuse: fix build warnings on ARCH=x86_64 or riscv H. Nikolaus Schaller
2020-03-09 13:52 ` Srinivas Kandagatla

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).