From bbeabb495e1bd2df3d938b850fbce4e61a61d9fa Mon Sep 17 00:00:00 2001 From: Aleksander Morgado Date: Thu, 30 Jan 2020 18:54:23 +0100 Subject: helpers: new macro to CLAMP high threshold only MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Useful when clamping a unsigned integer with low threshold set to 0, which would give us compiler warnings with -Wtype-limits when using CLAMP(), e.g.: via/mm-broadband-modem-via.c: In function ‘handle_evdo_quality_change’: /usr/include/glib-2.0/glib/gmacros.h:811:63: error: comparison of unsigned expression < 0 is always false [-Werror=type-limits] 811 | #define CLAMP(x, low, high) (((x) > (high)) ? (high) : (((x) < (low)) ? (low) : (x))) | ^ via/mm-broadband-modem-via.c:284:19: note: in expansion of macro ‘CLAMP’ 284 | quality = CLAMP (quality, 0, 100); | ^~~~~ --- plugins/simtech/mm-broadband-modem-simtech.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'plugins/simtech/mm-broadband-modem-simtech.c') diff --git a/plugins/simtech/mm-broadband-modem-simtech.c b/plugins/simtech/mm-broadband-modem-simtech.c index 21781dc9..246ce682 100644 --- a/plugins/simtech/mm-broadband-modem-simtech.c +++ b/plugins/simtech/mm-broadband-modem-simtech.c @@ -116,7 +116,7 @@ simtech_signal_changed (MMPortSerialAt *port, return; if (quality != 99) - quality = CLAMP (quality, 0, 31) * 100 / 31; + quality = MM_CLAMP_HIGH (quality, 31) * 100 / 31; else quality = 0; -- cgit v1.2.3-70-g09d2