scripts: Reverted to lh type preference in prettyasserts.py

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.
This commit is contained in:
Christopher Haster
2024-12-12 01:25:00 -06:00
parent 4c87d59c7b
commit eeab0c41e8

View File

@@ -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__, \\")