From 052fc200c8ded19105e0e7631e1384914b1324c4 Mon Sep 17 00:00:00 2001 From: Christopher Haster Date: Tue, 9 Sep 2025 21:59:11 -0500 Subject: [PATCH] util: More parens in LFS3_MIN/MAX Previously this had a very naive number of parens, which led to a very confusing night trying to debug some code that looked roughly like this: LFS3_MAX(1, (false) ? 64 : 256) => 1 ??? Fixed by adding more parens. --- lfs3_util.h | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/lfs3_util.h b/lfs3_util.h index 8545042c..6a9be290 100644 --- a/lfs3_util.h +++ b/lfs3_util.h @@ -317,8 +317,8 @@ // // Compile time min/max -#define LFS3_MIN(a, b) ((a < b) ? a : b) -#define LFS3_MAX(a, b) ((a > b) ? a : b) +#define LFS3_MIN(a, b) (((a) < (b)) ? (a) : (b)) +#define LFS3_MAX(a, b) (((a) > (b)) ? (a) : (b)) // Min/max functions for unsigned 32-bit numbers static inline uint32_t lfs3_min(uint32_t a, uint32_t b) {