diff mbox

[1/2] net: fix trace when debug is activated in slirp

Message ID 1299104702-18928-2-git-send-email-vpalatin@chromium.org
State New
Headers show

Commit Message

Vincent Palatin March 2, 2011, 10:25 p.m. UTC
make the code compile correctly when DEBUG is activated.

Signed-off-by: Vincent Palatin <vpalatin@chromium.org>
---
 slirp/bootp.c |    2 +-
 1 files changed, 1 insertions(+), 1 deletions(-)

Comments

Stefan Hajnoczi March 3, 2011, 9:18 a.m. UTC | #1
On Wed, Mar 2, 2011 at 10:25 PM, Vincent Palatin <vpalatin@chromium.org> wrote:
> make the code compile correctly when DEBUG is activated.
>
> Signed-off-by: Vincent Palatin <vpalatin@chromium.org>
> ---
>  slirp/bootp.c |    2 +-
>  1 files changed, 1 insertions(+), 1 deletions(-)
>
> diff --git a/slirp/bootp.c b/slirp/bootp.c
> index 0905c6d..1eb2ed1 100644
> --- a/slirp/bootp.c
> +++ b/slirp/bootp.c
> @@ -284,7 +284,7 @@ static void bootp_reply(Slirp *slirp, const struct bootp_t *bp)
>     } else {
>         static const char nak_msg[] = "requested address not available";
>
> -        DPRINTF("nak'ed addr=%08x\n", ntohl(preq_addr->s_addr));
> +        DPRINTF("nak'ed addr=%08x\n", ntohl(preq_addr.s_addr));

Looks good.

By the way, this is why it's nicer to rely on compiler dead code
elimination than #ifdefing out code:

#define DEBUG_ENABLED 0

static inline void dprintf(const char *fmt, ...)
{
    if (DEBUG_ENABLED) {
        va_list args;

        va_start(args, fmt);
        vfprintf(stderr, fmt, args);
        va_end(args);
    }
}

dprintf() callers will still have their arguments parsed and checked
by the compiler, even though it all compiles out when DEBUG_ENABLED is
0.

Also, QEMU tracing is often a better choice for new debug
instrumentation although for existing code there are lots of DPRINTF()
users today.

Stefan
Blue Swirl March 5, 2011, 12:18 p.m. UTC | #2
Thanks, applied both.

On Thu, Mar 3, 2011 at 12:25 AM, Vincent Palatin <vpalatin@chromium.org> wrote:
> make the code compile correctly when DEBUG is activated.
>
> Signed-off-by: Vincent Palatin <vpalatin@chromium.org>
> ---
>  slirp/bootp.c |    2 +-
>  1 files changed, 1 insertions(+), 1 deletions(-)
>
> diff --git a/slirp/bootp.c b/slirp/bootp.c
> index 0905c6d..1eb2ed1 100644
> --- a/slirp/bootp.c
> +++ b/slirp/bootp.c
> @@ -284,7 +284,7 @@ static void bootp_reply(Slirp *slirp, const struct bootp_t *bp)
>     } else {
>         static const char nak_msg[] = "requested address not available";
>
> -        DPRINTF("nak'ed addr=%08x\n", ntohl(preq_addr->s_addr));
> +        DPRINTF("nak'ed addr=%08x\n", ntohl(preq_addr.s_addr));
>
>         *q++ = RFC2132_MSG_TYPE;
>         *q++ = 1;
> --
> 1.7.3.1
>
>
>
diff mbox

Patch

diff --git a/slirp/bootp.c b/slirp/bootp.c
index 0905c6d..1eb2ed1 100644
--- a/slirp/bootp.c
+++ b/slirp/bootp.c
@@ -284,7 +284,7 @@  static void bootp_reply(Slirp *slirp, const struct bootp_t *bp)
     } else {
         static const char nak_msg[] = "requested address not available";
 
-        DPRINTF("nak'ed addr=%08x\n", ntohl(preq_addr->s_addr));
+        DPRINTF("nak'ed addr=%08x\n", ntohl(preq_addr.s_addr));
 
         *q++ = RFC2132_MSG_TYPE;
         *q++ = 1;