All of lore.kernel.org
 help / color / mirror / Atom feed
From: Stefan Weil <sw@weilnetz.de>
To: Sergey Fedorov <sergey.fedorov@linaro.org>, qemu-devel@nongnu.org
Cc: QEMU Trivial <qemu-trivial@nongnu.org>,
	Sergey Fedorov <serge.fdrv@gmail.com>,
	Peter Maydell <peter.maydell@linaro.org>
Subject: Re: [Qemu-trivial] [PATCH] tci: Fix build with no '-DNDEBUG'
Date: Mon, 4 Apr 2016 13:56:46 +0200	[thread overview]
Message-ID: <5702567E.6060701@weilnetz.de> (raw)
In-Reply-To: <1459767918-796-1-git-send-email-sergey.fedorov@linaro.org>

Am 04.04.2016 um 13:05 schrieb Sergey Fedorov:
> From: Sergey Fedorov <serge.fdrv@gmail.com>
>
> assert() always evaluates its argument so there's no need to #ifdef the
> definitions which is only used for assert(). Actually, doing so
> generates a compilation warning which is treated as an error in QEMU
> build by default. Let compiler sort out and eliminate unnecessary
> local variables.
>
> Signed-off-by: Sergey Fedorov <serge.fdrv@gmail.com>
> Signed-off-by: Sergey Fedorov <sergey.fedorov@linaro.org>
> ---
>  tci.c | 2 --
>  1 file changed, 2 deletions(-)
>
> diff --git a/tci.c b/tci.c
> index 7cbb39ed4b6a..d709e008f3f9 100644
> --- a/tci.c
> +++ b/tci.c
> @@ -472,10 +472,8 @@ uintptr_t tcg_qemu_tb_exec(CPUArchState *env, uint8_t *tb_ptr)
>  
>      for (;;) {
>          TCGOpcode opc = tb_ptr[0];
> -#if !defined(NDEBUG)
>          uint8_t op_size = tb_ptr[1];
>          uint8_t *old_code_ptr = tb_ptr;
> -#endif
>          tcg_target_ulong t0;
>          tcg_target_ulong t1;
>          tcg_target_ulong t2;


This patch should not be applied.

From the Linux man page for assert: "the macro assert() generates no code".

Which variant of the assert macro evaluates its argument even when NDEBUG
is defined? On which system with which configuration did you see the
problem?

There is indeed a regression in the current code. Commit
d38ea87ac54af64ef611de434d07c12dc0399216 added an include statement
which includes assert.h before NDEBUG is defined. This is wrong and
needs a fix. Could you please try tci.c starting like this?

/* Defining NDEBUG disables assertions (which makes the code faster). */
#if !defined(CONFIG_DEBUG_TCG) && !defined(NDEBUG)
# define NDEBUG
#endif

#include "qemu/osdep.h"

Thanks,
Stefan


WARNING: multiple messages have this Message-ID (diff)
From: Stefan Weil <sw@weilnetz.de>
To: Sergey Fedorov <sergey.fedorov@linaro.org>, qemu-devel@nongnu.org
Cc: QEMU Trivial <qemu-trivial@nongnu.org>,
	Sergey Fedorov <serge.fdrv@gmail.com>,
	Peter Maydell <peter.maydell@linaro.org>
Subject: Re: [Qemu-devel] [PATCH] tci: Fix build with no '-DNDEBUG'
Date: Mon, 4 Apr 2016 13:56:46 +0200	[thread overview]
Message-ID: <5702567E.6060701@weilnetz.de> (raw)
In-Reply-To: <1459767918-796-1-git-send-email-sergey.fedorov@linaro.org>

Am 04.04.2016 um 13:05 schrieb Sergey Fedorov:
> From: Sergey Fedorov <serge.fdrv@gmail.com>
>
> assert() always evaluates its argument so there's no need to #ifdef the
> definitions which is only used for assert(). Actually, doing so
> generates a compilation warning which is treated as an error in QEMU
> build by default. Let compiler sort out and eliminate unnecessary
> local variables.
>
> Signed-off-by: Sergey Fedorov <serge.fdrv@gmail.com>
> Signed-off-by: Sergey Fedorov <sergey.fedorov@linaro.org>
> ---
>  tci.c | 2 --
>  1 file changed, 2 deletions(-)
>
> diff --git a/tci.c b/tci.c
> index 7cbb39ed4b6a..d709e008f3f9 100644
> --- a/tci.c
> +++ b/tci.c
> @@ -472,10 +472,8 @@ uintptr_t tcg_qemu_tb_exec(CPUArchState *env, uint8_t *tb_ptr)
>  
>      for (;;) {
>          TCGOpcode opc = tb_ptr[0];
> -#if !defined(NDEBUG)
>          uint8_t op_size = tb_ptr[1];
>          uint8_t *old_code_ptr = tb_ptr;
> -#endif
>          tcg_target_ulong t0;
>          tcg_target_ulong t1;
>          tcg_target_ulong t2;


This patch should not be applied.

>From the Linux man page for assert: "the macro assert() generates no code".

Which variant of the assert macro evaluates its argument even when NDEBUG
is defined? On which system with which configuration did you see the
problem?

There is indeed a regression in the current code. Commit
d38ea87ac54af64ef611de434d07c12dc0399216 added an include statement
which includes assert.h before NDEBUG is defined. This is wrong and
needs a fix. Could you please try tci.c starting like this?

/* Defining NDEBUG disables assertions (which makes the code faster). */
#if !defined(CONFIG_DEBUG_TCG) && !defined(NDEBUG)
# define NDEBUG
#endif

#include "qemu/osdep.h"

Thanks,
Stefan

  reply	other threads:[~2016-04-04 11:56 UTC|newest]

Thread overview: 10+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2016-04-04 11:05 [Qemu-trivial] [PATCH] tci: Fix build with no '-DNDEBUG' Sergey Fedorov
2016-04-04 11:05 ` [Qemu-devel] " Sergey Fedorov
2016-04-04 11:56 ` Stefan Weil [this message]
2016-04-04 11:56   ` Stefan Weil
2016-04-04 13:22   ` [Qemu-trivial] " Sergey Fedorov
2016-04-04 13:22     ` [Qemu-devel] " Sergey Fedorov
2016-04-04 17:53     ` [Qemu-trivial] " Stefan Weil
2016-04-04 17:53       ` [Qemu-devel] " Stefan Weil
2016-04-04 18:06       ` [Qemu-trivial] " Sergey Fedorov
2016-04-04 18:06         ` [Qemu-devel] " Sergey Fedorov

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=5702567E.6060701@weilnetz.de \
    --to=sw@weilnetz.de \
    --cc=peter.maydell@linaro.org \
    --cc=qemu-devel@nongnu.org \
    --cc=qemu-trivial@nongnu.org \
    --cc=serge.fdrv@gmail.com \
    --cc=sergey.fedorov@linaro.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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.