[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: [PATCH] target/arm: Display helpful message when hflags mismatch
From: |
Philippe Mathieu-Daudé |
Subject: |
Re: [PATCH] target/arm: Display helpful message when hflags mismatch |
Date: |
Sun, 15 Dec 2019 05:56:44 +0100 |
User-agent: |
Mozilla/5.0 (X11; Linux x86_64; rv:68.0) Gecko/20100101 Thunderbird/68.2.2 |
On 12/12/19 1:36 AM, Richard Henderson wrote:
On 12/9/19 8:00 AM, Alex Bennée wrote:
-#ifdef CONFIG_DEBUG_TCG
- assert(flags == rebuild_hflags_internal(env));
-#endif
+ assert_hflags_rebuild_correctly(env);
I'm trying to recall why we don't just use:
g_assert_cmphex(flags, =, rebuild_hflags_internal(env))
s/=/==/ ;)
I think it came up in one of the reviews.
checkpatch.pl.
Because, I believe, there is an environment variable that causes this to *not*
abort on mismatch.
Indeed, see commit 6e9389563e5:
commit 6e9389563e56607f72562bdb72db452fcd7e7f74
Author: Dr. David Alan Gilbert <address@hidden>
Date: Thu Apr 27 17:55:26 2017 +0100
checkpatch: Disallow glib asserts in main code
Glib commit a6a875068779 (from 2013) made many of the glib assert
macros non-fatal if a flag is set.
This causes two problems:
a) Compilers moan that your code is unsafe even though you've
put an assert in before the point of use.
b) Someone evil could, in a library, call
g_test_set_nonfatal_assertions() and cause our assertions in
important places not to fail and potentially allow memory
overruns.
Ban most of the glib assertion functions (basically everything except
g_assert and g_assert_not_reached) except in tests/
This makes checkpatch gives an error such as:
ERROR: Use g_assert or g_assert_not_reached
#77: FILE: vl.c:4725:
+ g_assert_cmpstr("Chocolate", >, "Cheese");