From: Ramon Fried <rfried.dev@gmail.com>
To: "Philippe Mathieu-Daudé" <philmd@redhat.com>
Cc: Peter Maydell <peter.maydell@linaro.org>,
Jason Wang <jasowang@redhat.com>,
Alistair Francis <alistair@alistair23.me>,
qemu-devel@nongnu.org,
"open list:Xilinx Zynq" <qemu-arm@nongnu.org>,
"Edgar E. Iglesias" <edgar.iglesias@gmail.com>
Subject: Re: [Qemu-devel] [PATCH] net: cadence_gem: fix compilation error when debug is on
Date: Tue, 11 Jun 2019 14:28:07 +0300 [thread overview]
Message-ID: <CAGi-RUJEwpyzFg3qe18CuR+aO1NXX3O8sUBxKyP1ooncFpcOrA@mail.gmail.com> (raw)
In-Reply-To: <04cd3c78-9d8e-8958-1cdf-f65ab7d91dc7@redhat.com>
On Tue, Jun 11, 2019 at 11:34 AM Philippe Mathieu-Daudé <philmd@redhat.com>
wrote:
> Hi Ramon,
>
> On 6/9/19 12:08 PM, Ramon Fried wrote:
> > defining CADENCE_GEM_ERR_DEBUG causes compilation
> > errors, fix that.
> >
> > Signed-off-by: Ramon Fried <rfried.dev@gmail.com>
> > ---
> > 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..5cc5a71524 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%lx\n", MIN(bytes_to_copy,
> rxbufsize),
> > + rx_desc_get_buffer(s, s->rx_desc[q]));
>
> Your patch fails on 32-bit hosts:
>
> ./hw/net/cadence_gem.c:987:18: error: format '%lx' expects argument of
> type 'long unsigned int', but argument 4 has type 'uint64_t {aka long
> long unsigned int}' [-Werror=format=]
> DB_PRINT("copy %d bytes to 0x%lx\n", MIN(bytes_to_copy,
> rxbufsize),
> ^
> ./hw/net/cadence_gem.c:39:24: note: in definition of macro 'DB_PRINT'
> fprintf(stderr, ## __VA_ARGS__); \
> ^
> ./hw/net/cadence_gem.c: In function 'gem_transmit':
> ./hw/net/cadence_gem.c:1160:26: error: format '%lx' expects argument of
> type 'long unsigned int', but argument 5 has type 'unsigned int'
> [-Werror=format=]
> DB_PRINT("TX descriptor @ 0x%x too large: size 0x%x
> space " \
> ^
> ./hw/net/cadence_gem.c:39:24: note: in definition of macro 'DB_PRINT'
> fprintf(stderr, ## __VA_ARGS__); \
> ^
> cc1: all warnings being treated as errors
>
> QEMU provides "HWADDR_PRIx" format for addresses, see for example few
> lines earlier:
>
> DB_PRINT("read descriptor 0x%" HWADDR_PRIx "\n", packet_desc_addr);
>
>
> >
> > /* 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%lx\n", (unsigned)packet_desc_addr,
>
> Here the correct format seems to be "%zd" (difference of sizeof).
>
> > (unsigned)tx_desc_get_length(desc),
> > sizeof(tx_packet) - (p - tx_packet));
> > break;
> >
>
> Nowadays QEMU prefers to move from the old DB_PRINT() macros to the
> trace events API, see for example this commit:
>
>
> https://git.qemu.org/?p=qemu.git;a=commitdiff;h=da1804d17a9ed7f060c072fbc4889db5fbc9c7d2;hp=a4f667b6714916683408b983cfe0a615a725775f
>
> The first line you changed would be replaced by a trace event, while the
> second could be replaced by a qemu_log_mask() call (it is an error
> condition).
>
> Also I suggest to include "QEMU Trivial <qemu-trivial@nongnu.org>" in
> the list of recipients, so your patch might get reviewed/merged quicker.
>
> Regards,
>
> Phil.
>
Hi Phil,
Thanks for the review, I'll send v2 soon.
prev parent reply other threads:[~2019-06-11 12:41 UTC|newest]
Thread overview: 3+ messages / expand[flat|nested] mbox.gz Atom feed top
2019-06-09 10:08 [Qemu-devel] [PATCH] net: cadence_gem: fix compilation error when debug is on Ramon Fried
2019-06-11 8:34 ` Philippe Mathieu-Daudé
2019-06-11 11:28 ` Ramon Fried [this message]
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=CAGi-RUJEwpyzFg3qe18CuR+aO1NXX3O8sUBxKyP1ooncFpcOrA@mail.gmail.com \
--to=rfried.dev@gmail.com \
--cc=alistair@alistair23.me \
--cc=edgar.iglesias@gmail.com \
--cc=jasowang@redhat.com \
--cc=peter.maydell@linaro.org \
--cc=philmd@redhat.com \
--cc=qemu-arm@nongnu.org \
--cc=qemu-devel@nongnu.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
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).