From b5e264bec400b17b0741f574d1d5bf63d038a273 Mon Sep 17 00:00:00 2001 From: Christopher Haster Date: Thu, 4 Jan 2024 22:52:46 -0600 Subject: [PATCH] Fixed issue with pointer comparisons in prettyasserts.py We end up passing intmax_t pointers around, but without a cast. This results in a warning. Adding a cast fixes the warning. This is in the printing logic, not the actual comparison, so hiding warnings with this cast is not a concern here. I also flipped the type we compare with to use the right-hand side. The pretty-assert code already treats the right-hand as the "expected" value (I wonder if this is an english language quirk), so I think it makes sense to use the right-hand side as the "expected" type. --- scripts/prettyasserts.py | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/scripts/prettyasserts.py b/scripts/prettyasserts.py index 3c115a28..8f741f16 100755 --- a/scripts/prettyasserts.py +++ b/scripts/prettyasserts.py @@ -144,15 +144,15 @@ 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__(lh) _lh = lh; \\") - f.writeln(" __typeof__(lh) _rh = rh; \\") + f.writeln(" __typeof__(rh) _lh = lh; \\") + f.writeln(" __typeof__(rh) _rh = rh; \\") f.writeln(" if (!(_lh %s _rh)) { \\" % op) f.writeln(" __pretty_assert_fail( \\") f.writeln(" __FILE__, __LINE__, \\") f.writeln(" __pretty_assert_print_int, \"%s\", \\" % cmp) - f.writeln(" &(intmax_t){_lh}, 0, \\") - f.writeln(" &(intmax_t){_rh}, 0); \\") + f.writeln(" &(intmax_t){(intmax_t)_lh}, 0, \\") + f.writeln(" &(intmax_t){(intmax_t)_rh}, 0); \\") f.writeln(" } \\") f.writeln("} while (0)") for op, cmp in sorted(CMP.items()):