aboutsummaryrefslogtreecommitdiff
path: root/plugins/option
diff options
context:
space:
mode:
authorAleksander Morgado <aleksander@aleksander.es>2020-01-30 18:54:23 +0100
committerAleksander Morgado <aleksander@aleksander.es>2020-01-31 15:18:35 +0100
commitbbeabb495e1bd2df3d938b850fbce4e61a61d9fa (patch)
treec2074f172166da03b5a20a4044a1ac2759523b2c /plugins/option
parentb856f3625db670346a248967a53d6d0119e725b7 (diff)
helpers: new macro to CLAMP high threshold only
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); | ^~~~~
Diffstat (limited to 'plugins/option')
-rw-r--r--plugins/option/mm-broadband-modem-option.c6
1 files changed, 3 insertions, 3 deletions
diff --git a/plugins/option/mm-broadband-modem-option.c b/plugins/option/mm-broadband-modem-option.c
index 82ec58d0..268cb531 100644
--- a/plugins/option/mm-broadband-modem-option.c
+++ b/plugins/option/mm-broadband-modem-option.c
@@ -808,7 +808,7 @@ option_signal_changed (MMPortSerialAt *port,
MMBroadbandModemOption *self)
{
gchar *str;
- gint quality = 0;
+ guint quality = 0;
str = g_match_info_fetch (match_info, 1);
if (str) {
@@ -821,10 +821,10 @@ option_signal_changed (MMPortSerialAt *port,
quality = 0;
} else {
/* Normalize the quality */
- quality = CLAMP (quality, 0, 31) * 100 / 31;
+ quality = MM_CLAMP_HIGH (quality, 31) * 100 / 31;
}
- mm_iface_modem_update_signal_quality (MM_IFACE_MODEM (self), (guint)quality);
+ mm_iface_modem_update_signal_quality (MM_IFACE_MODEM (self), quality);
}
static void