diff mbox series

[v3] net: cadence_gem: fix compilation error when debug is on

Message ID 20190615051559.13767-1-rfried.dev@gmail.com (mailing list archive)
State New, archived
Headers show
Series [v3] net: cadence_gem: fix compilation error when debug is on | expand

Commit Message

Ramon Fried June 15, 2019, 5:15 a.m. UTC
defining CADENCE_GEM_ERR_DEBUG causes compilation
errors, fix that.

Signed-off-by: Ramon Fried <rfried.dev@gmail.com>
---
v2: change %lx to HWADDR_PRIx and %lx to %zdx
v3: change %zdx to %zx

 hw/net/cadence_gem.c | 6 +++---
 1 file changed, 3 insertions(+), 3 deletions(-)

Comments

Philippe Mathieu-Daudé June 15, 2019, 5:38 a.m. UTC | #1
Hi Ramon,

On 6/15/19 7:15 AM, Ramon Fried wrote:
> defining CADENCE_GEM_ERR_DEBUG causes compilation
> errors, fix that.
> 
> Signed-off-by: Ramon Fried <rfried.dev@gmail.com>
> ---
> v2: change %lx to HWADDR_PRIx and %lx to %zdx
> v3: change %zdx to %zx
> 
>  hw/net/cadence_gem.c | 6 +++---
>  1 file changed, 3 insertions(+), 3 deletions(-)
> 
> diff --git a/hw/net/cadence_gem.c b/hw/net/cadence_gem.c
> index 7f63411430..ecee22525c 100644
> --- a/hw/net/cadence_gem.c
> +++ b/hw/net/cadence_gem.c
> @@ -982,8 +982,8 @@ static ssize_t gem_receive(NetClientState *nc, const uint8_t *buf, size_t size)
>              return -1;
>          }
>  
> -        DB_PRINT("copy %d bytes to 0x%x\n", MIN(bytes_to_copy, rxbufsize),
> -                rx_desc_get_buffer(s->rx_desc[q]));
> +        DB_PRINT("copy %d bytes to 0x%" HWADDR_PRIx "\n", MIN(bytes_to_copy, rxbufsize),
> +                rx_desc_get_buffer(s, s->rx_desc[q]));
>  
>          /* Copy packet data to emulated DMA buffer */
>          address_space_write(&s->dma_as, rx_desc_get_buffer(s, s->rx_desc[q]) +
> @@ -1156,7 +1156,7 @@ static void gem_transmit(CadenceGEMState *s)
>              if (tx_desc_get_length(desc) > sizeof(tx_packet) -
>                                                 (p - tx_packet)) {
>                  DB_PRINT("TX descriptor @ 0x%x too large: size 0x%x space " \
> -                         "0x%x\n", (unsigned)packet_desc_addr,
> +                         "0x%zx\n", (unsigned)packet_desc_addr,
>                           (unsigned)tx_desc_get_length(desc),
>                           sizeof(tx_packet) - (p - tx_packet));
>                  break;
> 

I still get an error when trying to build on 32bit host with
CADENCE_GEM_ERR_DEBUG enabled (pre-existing to your patch):

  CC      hw/net/cadence_gem.o
./hw/net/cadence_gem.c: In function 'gem_receive':
./hw/net/cadence_gem.c:973:14: error: format '%ld' expects argument of
type 'long int', but argument 4 has type 'size_t {aka unsigned int}'
[-Werror=format=]
     DB_PRINT("config bufsize: %d packet size: %ld\n", rxbufsize, size);
              ^
./hw/net/cadence_gem.c:38:24: note: in definition of macro 'DB_PRINT'
     fprintf(stderr, ## __VA_ARGS__); \
                        ^
cc1: all warnings being treated as errors
./rules.mak:69: recipe for target 'hw/net/cadence_gem.o' failed
make: *** [hw/net/cadence_gem.o] Error 1

However the 64bit host is indeed fixed, so I'm fine with your patch:
Reviewed-by: Philippe Mathieu-Daudé <philmd@redhat.com>
Tested-by: Philippe Mathieu-Daudé <philmd@redhat.com>

Regards,

Phil.
Ramon Fried June 15, 2019, 6:16 a.m. UTC | #2
On June 15, 2019 8:38:35 AM GMT+03:00, "Philippe Mathieu-Daudé" <philmd@redhat.com> wrote:
>Hi Ramon,
>
>On 6/15/19 7:15 AM, Ramon Fried wrote:
>> defining CADENCE_GEM_ERR_DEBUG causes compilation
>> errors, fix that.
>> 
>> Signed-off-by: Ramon Fried <rfried.dev@gmail.com>
>> ---
>> v2: change %lx to HWADDR_PRIx and %lx to %zdx
>> v3: change %zdx to %zx
>> 
>>  hw/net/cadence_gem.c | 6 +++---
>>  1 file changed, 3 insertions(+), 3 deletions(-)
>> 
>> diff --git a/hw/net/cadence_gem.c b/hw/net/cadence_gem.c
>> index 7f63411430..ecee22525c 100644
>> --- a/hw/net/cadence_gem.c
>> +++ b/hw/net/cadence_gem.c
>> @@ -982,8 +982,8 @@ static ssize_t gem_receive(NetClientState *nc,
>const uint8_t *buf, size_t size)
>>              return -1;
>>          }
>>  
>> -        DB_PRINT("copy %d bytes to 0x%x\n", MIN(bytes_to_copy,
>rxbufsize),
>> -                rx_desc_get_buffer(s->rx_desc[q]));
>> +        DB_PRINT("copy %d bytes to 0x%" HWADDR_PRIx "\n",
>MIN(bytes_to_copy, rxbufsize),
>> +                rx_desc_get_buffer(s, s->rx_desc[q]));
>>  
>>          /* Copy packet data to emulated DMA buffer */
>>          address_space_write(&s->dma_as, rx_desc_get_buffer(s,
>s->rx_desc[q]) +
>> @@ -1156,7 +1156,7 @@ static void gem_transmit(CadenceGEMState *s)
>>              if (tx_desc_get_length(desc) > sizeof(tx_packet) -
>>                                                 (p - tx_packet)) {
>>                  DB_PRINT("TX descriptor @ 0x%x too large: size 0x%x
>space " \
>> -                         "0x%x\n", (unsigned)packet_desc_addr,
>> +                         "0x%zx\n", (unsigned)packet_desc_addr,
>>                           (unsigned)tx_desc_get_length(desc),
>>                           sizeof(tx_packet) - (p - tx_packet));
>>                  break;
>> 
>
>I still get an error when trying to build on 32bit host with
>CADENCE_GEM_ERR_DEBUG enabled (pre-existing to your patch):
>
>  CC      hw/net/cadence_gem.o
>./hw/net/cadence_gem.c: In function 'gem_receive':
>./hw/net/cadence_gem.c:973:14: error: format '%ld' expects argument of
>type 'long int', but argument 4 has type 'size_t {aka unsigned int}'
>[-Werror=format=]
>    DB_PRINT("config bufsize: %d packet size: %ld\n", rxbufsize, size);
>              ^
>./hw/net/cadence_gem.c:38:24: note: in definition of macro 'DB_PRINT'
>     fprintf(stderr, ## __VA_ARGS__); \
>                        ^
>cc1: all warnings being treated as errors
>./rules.mak:69: recipe for target 'hw/net/cadence_gem.o' failed
>make: *** [hw/net/cadence_gem.o] Error 1
>
>However the 64bit host is indeed fixed, so I'm fine with your patch:
>Reviewed-by: Philippe Mathieu-Daudé <philmd@redhat.com>
>Tested-by: Philippe Mathieu-Daudé <philmd@redhat.com>
>
>Regards,
>
>Phil.
Thanks!
Ramon Fried April 13, 2020, 5:55 p.m. UTC | #3
Hi.
Just noticed that this patch didn't hit master.
Got lost ?

Thanks,
Ramon.

On Sat, Jun 15, 2019 at 9:16 AM Ramon Fried <rfried.dev@gmail.com> wrote:
>
>
>
> On June 15, 2019 8:38:35 AM GMT+03:00, "Philippe Mathieu-Daudé" <philmd@redhat.com> wrote:
> >Hi Ramon,
> >
> >On 6/15/19 7:15 AM, Ramon Fried wrote:
> >> defining CADENCE_GEM_ERR_DEBUG causes compilation
> >> errors, fix that.
> >>
> >> Signed-off-by: Ramon Fried <rfried.dev@gmail.com>
> >> ---
> >> v2: change %lx to HWADDR_PRIx and %lx to %zdx
> >> v3: change %zdx to %zx
> >>
> >>  hw/net/cadence_gem.c | 6 +++---
> >>  1 file changed, 3 insertions(+), 3 deletions(-)
> >>
> >> diff --git a/hw/net/cadence_gem.c b/hw/net/cadence_gem.c
> >> index 7f63411430..ecee22525c 100644
> >> --- a/hw/net/cadence_gem.c
> >> +++ b/hw/net/cadence_gem.c
> >> @@ -982,8 +982,8 @@ static ssize_t gem_receive(NetClientState *nc,
> >const uint8_t *buf, size_t size)
> >>              return -1;
> >>          }
> >>
> >> -        DB_PRINT("copy %d bytes to 0x%x\n", MIN(bytes_to_copy,
> >rxbufsize),
> >> -                rx_desc_get_buffer(s->rx_desc[q]));
> >> +        DB_PRINT("copy %d bytes to 0x%" HWADDR_PRIx "\n",
> >MIN(bytes_to_copy, rxbufsize),
> >> +                rx_desc_get_buffer(s, s->rx_desc[q]));
> >>
> >>          /* Copy packet data to emulated DMA buffer */
> >>          address_space_write(&s->dma_as, rx_desc_get_buffer(s,
> >s->rx_desc[q]) +
> >> @@ -1156,7 +1156,7 @@ static void gem_transmit(CadenceGEMState *s)
> >>              if (tx_desc_get_length(desc) > sizeof(tx_packet) -
> >>                                                 (p - tx_packet)) {
> >>                  DB_PRINT("TX descriptor @ 0x%x too large: size 0x%x
> >space " \
> >> -                         "0x%x\n", (unsigned)packet_desc_addr,
> >> +                         "0x%zx\n", (unsigned)packet_desc_addr,
> >>                           (unsigned)tx_desc_get_length(desc),
> >>                           sizeof(tx_packet) - (p - tx_packet));
> >>                  break;
> >>
> >
> >I still get an error when trying to build on 32bit host with
> >CADENCE_GEM_ERR_DEBUG enabled (pre-existing to your patch):
> >
> >  CC      hw/net/cadence_gem.o
> >./hw/net/cadence_gem.c: In function 'gem_receive':
> >./hw/net/cadence_gem.c:973:14: error: format '%ld' expects argument of
> >type 'long int', but argument 4 has type 'size_t {aka unsigned int}'
> >[-Werror=format=]
> >    DB_PRINT("config bufsize: %d packet size: %ld\n", rxbufsize, size);
> >              ^
> >./hw/net/cadence_gem.c:38:24: note: in definition of macro 'DB_PRINT'
> >     fprintf(stderr, ## __VA_ARGS__); \
> >                        ^
> >cc1: all warnings being treated as errors
> >./rules.mak:69: recipe for target 'hw/net/cadence_gem.o' failed
> >make: *** [hw/net/cadence_gem.o] Error 1
> >
> >However the 64bit host is indeed fixed, so I'm fine with your patch:
> >Reviewed-by: Philippe Mathieu-Daudé <philmd@redhat.com>
> >Tested-by: Philippe Mathieu-Daudé <philmd@redhat.com>
> >
> >Regards,
> >
> >Phil.
> Thanks!
>
> --
> Sent from my Android device with K-9 Mail. Please excuse my brevity.
Ramon Fried April 13, 2020, 6:10 p.m. UTC | #4
False alarm, exact same patch was merged by someone else.

On Mon, Apr 13, 2020 at 8:55 PM Ramon Fried <rfried.dev@gmail.com> wrote:
>
> Hi.
> Just noticed that this patch didn't hit master.
> Got lost ?
>
> Thanks,
> Ramon.
>
> On Sat, Jun 15, 2019 at 9:16 AM Ramon Fried <rfried.dev@gmail.com> wrote:
> >
> >
> >
> > On June 15, 2019 8:38:35 AM GMT+03:00, "Philippe Mathieu-Daudé" <philmd@redhat.com> wrote:
> > >Hi Ramon,
> > >
> > >On 6/15/19 7:15 AM, Ramon Fried wrote:
> > >> defining CADENCE_GEM_ERR_DEBUG causes compilation
> > >> errors, fix that.
> > >>
> > >> Signed-off-by: Ramon Fried <rfried.dev@gmail.com>
> > >> ---
> > >> v2: change %lx to HWADDR_PRIx and %lx to %zdx
> > >> v3: change %zdx to %zx
> > >>
> > >>  hw/net/cadence_gem.c | 6 +++---
> > >>  1 file changed, 3 insertions(+), 3 deletions(-)
> > >>
> > >> diff --git a/hw/net/cadence_gem.c b/hw/net/cadence_gem.c
> > >> index 7f63411430..ecee22525c 100644
> > >> --- a/hw/net/cadence_gem.c
> > >> +++ b/hw/net/cadence_gem.c
> > >> @@ -982,8 +982,8 @@ static ssize_t gem_receive(NetClientState *nc,
> > >const uint8_t *buf, size_t size)
> > >>              return -1;
> > >>          }
> > >>
> > >> -        DB_PRINT("copy %d bytes to 0x%x\n", MIN(bytes_to_copy,
> > >rxbufsize),
> > >> -                rx_desc_get_buffer(s->rx_desc[q]));
> > >> +        DB_PRINT("copy %d bytes to 0x%" HWADDR_PRIx "\n",
> > >MIN(bytes_to_copy, rxbufsize),
> > >> +                rx_desc_get_buffer(s, s->rx_desc[q]));
> > >>
> > >>          /* Copy packet data to emulated DMA buffer */
> > >>          address_space_write(&s->dma_as, rx_desc_get_buffer(s,
> > >s->rx_desc[q]) +
> > >> @@ -1156,7 +1156,7 @@ static void gem_transmit(CadenceGEMState *s)
> > >>              if (tx_desc_get_length(desc) > sizeof(tx_packet) -
> > >>                                                 (p - tx_packet)) {
> > >>                  DB_PRINT("TX descriptor @ 0x%x too large: size 0x%x
> > >space " \
> > >> -                         "0x%x\n", (unsigned)packet_desc_addr,
> > >> +                         "0x%zx\n", (unsigned)packet_desc_addr,
> > >>                           (unsigned)tx_desc_get_length(desc),
> > >>                           sizeof(tx_packet) - (p - tx_packet));
> > >>                  break;
> > >>
> > >
> > >I still get an error when trying to build on 32bit host with
> > >CADENCE_GEM_ERR_DEBUG enabled (pre-existing to your patch):
> > >
> > >  CC      hw/net/cadence_gem.o
> > >./hw/net/cadence_gem.c: In function 'gem_receive':
> > >./hw/net/cadence_gem.c:973:14: error: format '%ld' expects argument of
> > >type 'long int', but argument 4 has type 'size_t {aka unsigned int}'
> > >[-Werror=format=]
> > >    DB_PRINT("config bufsize: %d packet size: %ld\n", rxbufsize, size);
> > >              ^
> > >./hw/net/cadence_gem.c:38:24: note: in definition of macro 'DB_PRINT'
> > >     fprintf(stderr, ## __VA_ARGS__); \
> > >                        ^
> > >cc1: all warnings being treated as errors
> > >./rules.mak:69: recipe for target 'hw/net/cadence_gem.o' failed
> > >make: *** [hw/net/cadence_gem.o] Error 1
> > >
> > >However the 64bit host is indeed fixed, so I'm fine with your patch:
> > >Reviewed-by: Philippe Mathieu-Daudé <philmd@redhat.com>
> > >Tested-by: Philippe Mathieu-Daudé <philmd@redhat.com>
> > >
> > >Regards,
> > >
> > >Phil.
> > Thanks!
> >
> > --
> > Sent from my Android device with K-9 Mail. Please excuse my brevity.
diff mbox series

Patch

diff --git a/hw/net/cadence_gem.c b/hw/net/cadence_gem.c
index 7f63411430..ecee22525c 100644
--- a/hw/net/cadence_gem.c
+++ b/hw/net/cadence_gem.c
@@ -982,8 +982,8 @@  static ssize_t gem_receive(NetClientState *nc, const uint8_t *buf, size_t size)
             return -1;
         }
 
-        DB_PRINT("copy %d bytes to 0x%x\n", MIN(bytes_to_copy, rxbufsize),
-                rx_desc_get_buffer(s->rx_desc[q]));
+        DB_PRINT("copy %d bytes to 0x%" HWADDR_PRIx "\n", MIN(bytes_to_copy, rxbufsize),
+                rx_desc_get_buffer(s, s->rx_desc[q]));
 
         /* Copy packet data to emulated DMA buffer */
         address_space_write(&s->dma_as, rx_desc_get_buffer(s, s->rx_desc[q]) +
@@ -1156,7 +1156,7 @@  static void gem_transmit(CadenceGEMState *s)
             if (tx_desc_get_length(desc) > sizeof(tx_packet) -
                                                (p - tx_packet)) {
                 DB_PRINT("TX descriptor @ 0x%x too large: size 0x%x space " \
-                         "0x%x\n", (unsigned)packet_desc_addr,
+                         "0x%zx\n", (unsigned)packet_desc_addr,
                          (unsigned)tx_desc_get_length(desc),
                          sizeof(tx_packet) - (p - tx_packet));
                 break;