2015-06-11 03:42:30

by Park, Chris

[permalink] [raw]
Subject: [PATCH] staging: wilc1000: fix warning while printing

size_t should print using %zu, but here it was use %lu.
we were getting warning while printing.

Signed-off-by: Chris Park <[email protected]>
---
drivers/staging/wilc1000/wilc_spi.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/drivers/staging/wilc1000/wilc_spi.c b/drivers/staging/wilc1000/wilc_spi.c
index 6d854fd..a43dc9b 100644
--- a/drivers/staging/wilc1000/wilc_spi.c
+++ b/drivers/staging/wilc1000/wilc_spi.c
@@ -404,7 +404,7 @@ static int spi_cmd_complete(uint8_t cmd, uint32_t adr, uint8_t *b, uint32_t sz,
#undef NUM_DUMMY_BYTES

if (len2 > (sizeof(wb) / sizeof(wb[0]))) {
- PRINT_ER("[wilc spi]: spi buffer size too small (%d) (%lu)\n",
+ PRINT_ER("[wilc spi]: spi buffer size too small (%d) (%zu)\n",
len2, (sizeof(wb) / sizeof(wb[0])));
result = N_FAIL;
return result;
--
1.9.1



2015-06-11 05:48:45

by Sudip Mukherjee

[permalink] [raw]
Subject: Re: [PATCH] staging: wilc1000: fix warning while printing

On Thu, Jun 11, 2015 at 12:42:23PM +0900, Chris Park wrote:
> size_t should print using %zu, but here it was use %lu.
> we were getting warning while printing.
thanks, I made it to %lu seeing warning in x86_64 but that started
warning in i386. Not this solves warning in both.

regards
sudip

2015-06-02 08:35:45

by Sudip Mukherjee

[permalink] [raw]
Subject: Re: [PATCH] staging: wilc1000: fix warning while printing

On Tue, Jun 02, 2015 at 10:29:17AM +0200, Konrad Zapalowicz wrote:
> On 06/02, Sudip Mukherjee wrote:
> > size_t should print using %zu, but here it was using %d and hence we
> > were getting warning while printing.
> >
> > Signed-off-by: Sudip Mukherjee <[email protected]>
> > ---
> >
> > I think it will be easy to remove the other warnings if all the typedefs
> > are removed first.
> >
> > drivers/staging/wilc1000/wilc_spi.c | 2 +-
> > drivers/staging/wilc1000/wilc_wfi_cfgoperations.c | 6 +++---
> > 2 files changed, 4 insertions(+), 4 deletions(-)
> >
> > diff --git a/drivers/staging/wilc1000/wilc_spi.c b/drivers/staging/wilc1000/wilc_spi.c
> > index d0e7610..6d854fd 100644
> > --- a/drivers/staging/wilc1000/wilc_spi.c
> > +++ b/drivers/staging/wilc1000/wilc_spi.c
> > @@ -404,7 +404,7 @@ static int spi_cmd_complete(uint8_t cmd, uint32_t adr, uint8_t *b, uint32_t sz,
> > #undef NUM_DUMMY_BYTES
> >
> > if (len2 > (sizeof(wb) / sizeof(wb[0]))) {
> > - PRINT_ER("[wilc spi]: spi buffer size too small (%d) (%d)\n",
> > + PRINT_ER("[wilc spi]: spi buffer size too small (%d) (%lu)\n",
>
> Hi, it seems that the above line should use %zu too. Am I correct or I'm
> missing something?
oops. my mistake. %lu is correct but i missed mentioning the warning
about long unsigned int in the commit message.

regards
sudip

2015-06-02 08:58:44

by Konrad Zapalowicz

[permalink] [raw]
Subject: Re: [PATCH] staging: wilc1000: fix warning while printing

On 06/02, Sudip Mukherjee wrote:
> On Tue, Jun 02, 2015 at 10:29:17AM +0200, Konrad Zapalowicz wrote:
> > On 06/02, Sudip Mukherjee wrote:
> > > size_t should print using %zu, but here it was using %d and hence we
> > > were getting warning while printing.
> > >
> > > Signed-off-by: Sudip Mukherjee <[email protected]>
> > > ---
> > >
> > > I think it will be easy to remove the other warnings if all the typedefs
> > > are removed first.
> > >
> > > drivers/staging/wilc1000/wilc_spi.c | 2 +-
> > > drivers/staging/wilc1000/wilc_wfi_cfgoperations.c | 6 +++---
> > > 2 files changed, 4 insertions(+), 4 deletions(-)
> > >
> > > diff --git a/drivers/staging/wilc1000/wilc_spi.c b/drivers/staging/wilc1000/wilc_spi.c
> > > index d0e7610..6d854fd 100644
> > > --- a/drivers/staging/wilc1000/wilc_spi.c
> > > +++ b/drivers/staging/wilc1000/wilc_spi.c
> > > @@ -404,7 +404,7 @@ static int spi_cmd_complete(uint8_t cmd, uint32_t adr, uint8_t *b, uint32_t sz,
> > > #undef NUM_DUMMY_BYTES
> > >
> > > if (len2 > (sizeof(wb) / sizeof(wb[0]))) {
> > > - PRINT_ER("[wilc spi]: spi buffer size too small (%d) (%d)\n",
> > > + PRINT_ER("[wilc spi]: spi buffer size too small (%d) (%lu)\n",
> >
> > Hi, it seems that the above line should use %zu too. Am I correct or I'm
> > missing something?
> oops. my mistake. %lu is correct but i missed mentioning the warning
> about long unsigned int in the commit message.

Why %lu here and %zu in other places? I mean that it is the same size_t
or I'm missing something?

- konrad

> regards
> sudip

2015-06-02 09:01:58

by Sudip Mukherjee

[permalink] [raw]
Subject: Re: [PATCH] staging: wilc1000: fix warning while printing

On Tue, Jun 02, 2015 at 10:58:40AM +0200, Konrad Zapalowicz wrote:
> On 06/02, Sudip Mukherjee wrote:
> > On Tue, Jun 02, 2015 at 10:29:17AM +0200, Konrad Zapalowicz wrote:
> > > On 06/02, Sudip Mukherjee wrote:
> > > > size_t should print using %zu, but here it was using %d and hence we
> > > > were getting warning while printing.
> > > >
> > > > Signed-off-by: Sudip Mukherjee <[email protected]>
> > > > ---
> > > >
> > > > I think it will be easy to remove the other warnings if all the typedefs
> > > > are removed first.
> > > >
> > > > drivers/staging/wilc1000/wilc_spi.c | 2 +-
> > > > drivers/staging/wilc1000/wilc_wfi_cfgoperations.c | 6 +++---
> > > > 2 files changed, 4 insertions(+), 4 deletions(-)
> > > >
> > > > diff --git a/drivers/staging/wilc1000/wilc_spi.c b/drivers/staging/wilc1000/wilc_spi.c
> > > > index d0e7610..6d854fd 100644
> > > > --- a/drivers/staging/wilc1000/wilc_spi.c
> > > > +++ b/drivers/staging/wilc1000/wilc_spi.c
> > > > @@ -404,7 +404,7 @@ static int spi_cmd_complete(uint8_t cmd, uint32_t adr, uint8_t *b, uint32_t sz,
> > > > #undef NUM_DUMMY_BYTES
> > > >
> > > > if (len2 > (sizeof(wb) / sizeof(wb[0]))) {
> > > > - PRINT_ER("[wilc spi]: spi buffer size too small (%d) (%d)\n",
> > > > + PRINT_ER("[wilc spi]: spi buffer size too small (%d) (%lu)\n",
> > >
> > > Hi, it seems that the above line should use %zu too. Am I correct or I'm
> > > missing something?
> > oops. my mistake. %lu is correct but i missed mentioning the warning
> > about long unsigned int in the commit message.
>
> Why %lu here and %zu in other places? I mean that it is the same size_t
> or I'm missing something?
no, this is unsigned long int.
The warning here was:
drivers/staging/wilc1000/wilc_spi.c:407:3: warning: format ‘%d’ expects argument of type ‘int’, but argument 3 has type ‘long unsigned int’ [-Wformat]

so size_t used %zu and unsigned long int should use %lu

regards
sudip
>
> - konrad
>
> > regards
> > sudip