From eeab0c41e8e04f24b0cb227a64d0e5d9a7372202 Mon Sep 17 00:00:00 2001 From: Christopher Haster Date: Thu, 12 Dec 2024 01:25:00 -0600 Subject: [PATCH] scripts: Reverted to lh type preference in prettyasserts.py MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit This was flipped in b5e264b. Infering the type from the right-hand side is tempting here, but the right-hand side if often a constant, which gets a bit funky in C. Consider: assert(lfs->cfg->read != NULL); gcc: warning: ISO C forbids initialization between function pointer and ‘void *’ [-Wpedantic] assert(err < 0ULL); gcc: warning: comparison of unsigned expression in ‘< 0’ is always false [-Wtype-limits] Prefering the left-hand type should hopefully avoid these issues most of the time. --- scripts/prettyasserts.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/scripts/prettyasserts.py b/scripts/prettyasserts.py index dabe355a..70ddc27d 100755 --- a/scripts/prettyasserts.py +++ b/scripts/prettyasserts.py @@ -154,8 +154,8 @@ def write_header(f, limit=LIMIT): for op, cmp in sorted(CMP.items()): f.writeln("#define __PRETTY_ASSERT_INT_%s(lh, rh) do { \\" % ( cmp.upper())) - f.writeln(" __typeof__(rh) _lh = lh; \\") - f.writeln(" __typeof__(rh) _rh = rh; \\") + f.writeln(" __typeof__(lh) _lh = lh; \\") + f.writeln(" __typeof__(lh) _rh = rh; \\") f.writeln(" if (!(_lh %s _rh)) { \\" % op) f.writeln(" __pretty_assert_print( \\") f.writeln(" __FILE__, __LINE__, \\")