On Wed, Mar 2, 2011 at 10:25 PM, Vincent Palatin <vpala...@chromium.org> wrote:
> make the code compile correctly when DEBUG is activated.
>
> Signed-off-by: Vincent Palatin <vpala...@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

Reply via email to