qemu-devel.nongnu.org archive mirror
 help / color / mirror / Atom feed
From: Richard Henderson <richard.henderson@linaro.org>
To: "Thomas Huth" <thuth@redhat.com>,
	"Philippe Mathieu-Daudé" <philmd@linaro.org>,
	qemu-devel@nongnu.org
Subject: Re: [PATCH 3/5] bulk: Replace [g_]assert(0) -> g_assert_not_reached()
Date: Tue, 21 Feb 2023 20:29:01 -1000	[thread overview]
Message-ID: <b0ed61bd-5146-c142-8ad0-2df61632b42e@linaro.org> (raw)
In-Reply-To: <f0eb7a7c-8505-ee8d-af5f-259c2627958b@redhat.com>

On 2/21/23 18:06, Thomas Huth wrote:
>>   int postcopy_wake_shared(struct PostCopyFD *pcfd,
>>                            uint64_t client_addr,
>>                            RAMBlock *rb)
>>   {
>> -    assert(0);
>> -    return -1;
>> +    g_assert_not_reached();
>>   }
>>   #endif
> 
> If we ever reconsider to allow compiling with G_DISABLE_ASSERT again,

... and we shouldn't [1] ...

> this will fail to compile since the return is missing now, so this is kind of ugly ... would it make sense to replace this with g_assert_true(0) instead? Or use abort() directly?

With g_assert_true(0), definitely not.
That is a testing-only item which can be disabled at runtime.

With abort(), no, since g_assert_not_reached() prints file:line.
Indeed, I was suggesting the opposite -- to replace abort() without error_report() with 
g_assert_not_reached().


r~


[1] Allowing G_DISABLE_ASSERT and/or NDEBUG would only require that we invent 
qemu-specific replacements with either (1) do exactly the same thing or, (2) interact with 
__builtin_unreachable() or __builtin_trap(), so that we tell the compiler exactly what's 
going on with the expressions and flow control.



  reply	other threads:[~2023-02-22  6:29 UTC|newest]

Thread overview: 22+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2023-02-21 23:25 [PATCH 0/5] bulk: Replace assert(0) -> g_assert_not_reached() Philippe Mathieu-Daudé
2023-02-21 23:25 ` [PATCH 1/5] target/ppc: fix warning with clang-15 Philippe Mathieu-Daudé
2023-02-21 23:25 ` [PATCH 2/5] scripts/checkpatch.pl: Do not allow assert(0) Philippe Mathieu-Daudé
2023-02-22  0:08   ` Richard Henderson
2023-02-22  3:53   ` Thomas Huth
2023-02-23 14:51     ` Philippe Mathieu-Daudé
2023-02-21 23:25 ` [PATCH 3/5] bulk: Replace [g_]assert(0) -> g_assert_not_reached() Philippe Mathieu-Daudé
2023-02-22  0:08   ` Richard Henderson
2023-02-22  4:06   ` Thomas Huth
2023-02-22  6:29     ` Richard Henderson [this message]
2023-02-22 11:54       ` Thomas Huth
2023-02-22 11:56   ` Thomas Huth
2023-02-22 13:02     ` Philippe Mathieu-Daudé
2023-02-21 23:25 ` [PATCH 4/5] block/vvfat: Remove pointless check of NDEBUG Philippe Mathieu-Daudé
2023-02-22  0:09   ` Richard Henderson
2023-02-21 23:25 ` [PATCH 5/5] hw: Remove mentions " Philippe Mathieu-Daudé
2023-02-22  0:10   ` Richard Henderson
2023-02-22 12:05   ` Michael S. Tsirkin
2023-02-22 16:11     ` Philippe Mathieu-Daudé
2023-02-22 16:28       ` Michael S. Tsirkin
2023-02-22 18:43         ` Richard Henderson
2023-02-22 20:23           ` Michael S. Tsirkin

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=b0ed61bd-5146-c142-8ad0-2df61632b42e@linaro.org \
    --to=richard.henderson@linaro.org \
    --cc=philmd@linaro.org \
    --cc=qemu-devel@nongnu.org \
    --cc=thuth@redhat.com \
    /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).