diff options
author | Thomas Haller <thaller@redhat.com> | 2023-11-15 09:33:31 +0100 |
---|---|---|
committer | Thomas Haller <thaller@redhat.com> | 2023-11-15 09:33:31 +0100 |
commit | 1bf97d8b2ff6303b0783e62f2c9ef30b1cad11d6 (patch) | |
tree | 8d54dc9f9f5f48f40fbd0c301d02d19b85c0fd51 | |
parent | c04c95540712ed49593188bf1a2c22a35928dbf7 (diff) | |
parent | 21c979eb1793e89ef19d96d746f6971a0c05be03 (diff) |
all: merge branch 'th/minmax'
https://gitlab.freedesktop.org/NetworkManager/NetworkManager/-/merge_requests/1778
41 files changed, 161 insertions, 128 deletions
diff --git a/src/core/devices/nm-device-ethernet.c b/src/core/devices/nm-device-ethernet.c index 5d58b69d67..e82d0350d5 100644 --- a/src/core/devices/nm-device-ethernet.c +++ b/src/core/devices/nm-device-ethernet.c @@ -1431,7 +1431,7 @@ act_stage2_config(NMDevice *device, NMDeviceStateReason *out_failure_reason) mtu = nm_setting_ppp_get_mtu(s_ppp); mru = nm_setting_ppp_get_mru(s_ppp); - mxu = MAX(mru, mtu); + mxu = NM_MAX(mru, mtu); if (mxu) { _LOGD(LOGD_PPP, "set MTU to %u (PPP interface MRU %u, MTU %u)", diff --git a/src/core/devices/wifi/nm-iwd-manager.c b/src/core/devices/wifi/nm-iwd-manager.c index 3db52d4b6f..76a342e206 100644 --- a/src/core/devices/wifi/nm-iwd-manager.c +++ b/src/core/devices/wifi/nm-iwd-manager.c @@ -1902,7 +1902,7 @@ nm_iwd_manager_get_ap_mirror_connection(NMIwdManager *self, NMWifiAP *ap) NM80211ApSecurityFlags sec_flags = nm_wifi_ap_get_wpa_flags(ap) | nm_wifi_ap_get_rsn_flags(ap); ssid_bytes = g_bytes_get_data(nm_wifi_ap_get_ssid(ap), &ssid_len); - ssid_len = MIN(ssid_len, 32); + ssid_len = NM_MIN(ssid_len, 32u); memcpy(name_buf, ssid_bytes, ssid_len); name_buf[ssid_len] = '\0'; diff --git a/src/core/ndisc/nm-fake-ndisc.c b/src/core/ndisc/nm-fake-ndisc.c index f305e7713f..f0b6dcf6ae 100644 --- a/src/core/ndisc/nm-fake-ndisc.c +++ b/src/core/ndisc/nm-fake-ndisc.c @@ -239,7 +239,7 @@ receive_ra(gpointer user_data) priv->receive_ra_id = 0; /* preserve the "most managed" level on updates. */ - dhcp_level = MAX(rdata->public.dhcp_level, ra->dhcp_level); + dhcp_level = NM_MAX(rdata->public.dhcp_level, ra->dhcp_level); if (rdata->public.dhcp_level != dhcp_level) { rdata->public.dhcp_level = dhcp_level; diff --git a/src/core/ndisc/nm-lndp-ndisc.c b/src/core/ndisc/nm-lndp-ndisc.c index 63dde5a5b8..932366ff50 100644 --- a/src/core/ndisc/nm-lndp-ndisc.c +++ b/src/core/ndisc/nm-lndp-ndisc.c @@ -161,7 +161,7 @@ receive_ra(struct ndp *ndp, struct ndp_msg *msg, gpointer user_data) * let's keep the "most managed" level. */ G_STATIC_ASSERT_EXPR(NM_NDISC_DHCP_LEVEL_MANAGED > NM_NDISC_DHCP_LEVEL_OTHERCONF); G_STATIC_ASSERT_EXPR(NM_NDISC_DHCP_LEVEL_OTHERCONF > NM_NDISC_DHCP_LEVEL_NONE); - dhcp_level = MAX(dhcp_level, rdata->public.dhcp_level); + dhcp_level = NM_MAX(dhcp_level, rdata->public.dhcp_level); if (dhcp_level != rdata->public.dhcp_level) { rdata->public.dhcp_level = dhcp_level; diff --git a/src/core/nm-connectivity.c b/src/core/nm-connectivity.c index 76223cf121..15dc31aa24 100644 --- a/src/core/nm-connectivity.c +++ b/src/core/nm-connectivity.c @@ -1295,7 +1295,7 @@ update_config(NMConnectivity *self, NMConfigData *config_data) priv->uri_valid = new_uri_valid; interval = nm_config_data_get_connectivity_interval(config_data); - interval = MIN(interval, (7 * 24 * 3600)); + interval = NM_MIN(interval, (7u * 24 * 3600)); if (priv->interval != interval) { priv->interval = interval; changed = TRUE; diff --git a/src/core/nm-core-utils.c b/src/core/nm-core-utils.c index a6c20ad851..9d3bb9582e 100644 --- a/src/core/nm-core-utils.c +++ b/src/core/nm-core-utils.c @@ -738,19 +738,20 @@ nm_utils_kill_child_sync(pid_t pid, if (!was_waiting) { nm_log_dbg(log_domain, - LOG_NAME_FMT ": waiting up to %ld milliseconds for process to terminate " + LOG_NAME_FMT ": waiting up to %lu milliseconds for process to terminate " "normally after sending %s...", LOG_NAME_ARGS, - (long) MAX(wait_before_kill_msec, 0), + (unsigned long) wait_before_kill_msec, _kc_signal_to_string(sig)); was_waiting = TRUE; } - sleep_time = MIN(wait_until - now, sleep_duration_usec); + sleep_time = NM_MIN(wait_until - now, (gint64) sleep_duration_usec); if (loop_count < 20) { /* At the beginning we expect the process to die fast. * Limit the sleep time, the limit doubles with every iteration. */ - sleep_time = MIN(sleep_time, (((guint64) 1) << loop_count) * G_USEC_PER_SEC / 2000); + sleep_time = + NM_MIN(sleep_time, (((guint64) 1) << loop_count) * G_USEC_PER_SEC / 2000); loop_count++; } g_usleep(sleep_time); @@ -1031,17 +1032,17 @@ nm_utils_kill_process_sync(pid_t pid, loop_count = 0; /* reset the loop_count. Now we really expect the process to die quickly. */ } else - sleep_time = MIN(wait_until_sigkill - now, sleep_duration_usec); + sleep_time = NM_MIN(wait_until_sigkill - now, (gint64) sleep_duration_usec); } if (!was_waiting) { if (wait_until_sigkill != 0) { nm_log_dbg(log_domain, LOG_NAME_PROCESS_FMT - ": waiting up to %ld milliseconds for process to disappear before " + ": waiting up to %lu milliseconds for process to disappear before " "sending KILL signal after sending %s...", LOG_NAME_ARGS, - (long) wait_before_kill_msec, + (unsigned long) wait_before_kill_msec, _kc_signal_to_string(sig)); } else if (max_wait_until != 0) { nm_log_dbg( @@ -1064,7 +1065,7 @@ nm_utils_kill_process_sync(pid_t pid, if (loop_count < 20) { /* At the beginning we expect the process to die fast. * Limit the sleep time, the limit doubles with every iteration. */ - sleep_time = MIN(sleep_time, (((guint64) 1) << loop_count) * G_USEC_PER_SEC / 2000); + sleep_time = NM_MIN(sleep_time, (((guint64) 1) << loop_count) * G_USEC_PER_SEC / 2000); loop_count++; } g_usleep(sleep_time); @@ -3567,7 +3568,7 @@ nm_utils_ipv6_addr_set_stable_privacy_with_host_id(NMUtilsStableType stable_type sum = g_checksum_new(G_CHECKSUM_SHA256); - host_id_len = MIN(host_id_len, G_MAXUINT32); + host_id_len = NM_MIN(host_id_len, G_MAXUINT32); if (stable_type != NM_UTILS_STABLE_TYPE_UUID) { guint8 stable_type_uint8; @@ -3742,7 +3743,7 @@ _hw_addr_gen_stable_eth(NMUtilsStableType stable_type, sum = g_checksum_new(G_CHECKSUM_SHA256); - host_id_len = MIN(host_id_len, G_MAXUINT32); + host_id_len = NM_MIN(host_id_len, G_MAXUINT32); nm_assert(stable_type < (NMUtilsStableType) 255); stable_type_uint8 = stable_type; @@ -4255,8 +4256,8 @@ read_device_factory_paths_sort_fcn(gconstpointer a, gconstpointer b) const struct plugin_info *db = b; time_t ta, tb; - ta = MAX(da->st.st_mtime, da->st.st_ctime); - tb = MAX(db->st.st_mtime, db->st.st_ctime); + ta = NM_MAX(da->st.st_mtime, da->st.st_ctime); + tb = NM_MAX(db->st.st_mtime, db->st.st_ctime); if (ta < tb) return 1; @@ -5418,7 +5419,7 @@ nm_utils_shorten_hostname(const char *hostname, char **shortened) l = (dot - hostname); else l = strlen(hostname); - l = MIN(l, (gsize) NM_HOST_NAME_MAX); + l = NM_MIN(l, (gsize) NM_HOST_NAME_MAX); s = g_strndup(hostname, l); diff --git a/src/core/nm-dbus-manager.c b/src/core/nm-dbus-manager.c index 0bde5971d8..7e6757f016 100644 --- a/src/core/nm-dbus-manager.c +++ b/src/core/nm-dbus-manager.c @@ -1644,8 +1644,8 @@ _new_unix_process(GDBusMethodInvocation *context, /* polkit glib library stores uid and pid as int. There might be some * pitfalls if the id ever happens to be larger then that. Just assert against * it here. */ - g_return_val_if_fail(uid <= MIN(G_MAXINT, G_MAXINT32), NULL); - g_return_val_if_fail(pid > 0 && pid <= MIN(G_MAXINT, G_MAXINT32), NULL); + g_return_val_if_fail(uid <= NM_MIN(G_MAXINT, G_MAXINT32), NULL); + g_return_val_if_fail(pid > 0 && pid <= NM_MIN(G_MAXINT, G_MAXINT32), NULL); self = nm_auth_subject_new_unix_process(dbus_sender, pid, uid); diff --git a/src/core/nm-l3-config-data.c b/src/core/nm-l3-config-data.c index f7f81d93a7..347332933a 100644 --- a/src/core/nm-l3-config-data.c +++ b/src/core/nm-l3-config-data.c @@ -1642,7 +1642,7 @@ nm_l3_config_data_get_dns_priority(const NML3ConfigData *self, int addr_family, case AF_UNSPEC: if (NM_FLAGS_ANY(self->flags, NM_L3_CONFIG_DAT_FLAGS_HAS_DNS_PRIORITY_4)) { if (NM_FLAGS_ANY(self->flags, NM_L3_CONFIG_DAT_FLAGS_HAS_DNS_PRIORITY_6)) { - NM_SET_OUT(out_prio, MIN(self->dns_priority_4, self->dns_priority_6)); + NM_SET_OUT(out_prio, NM_MIN(self->dns_priority_4, self->dns_priority_6)); return TRUE; } NM_SET_OUT(out_prio, self->dns_priority_4); diff --git a/src/core/nm-policy.c b/src/core/nm-policy.c index 2873847df3..feea97b114 100644 --- a/src/core/nm-policy.c +++ b/src/core/nm-policy.c @@ -1766,7 +1766,7 @@ _connection_autoconnect_retries_set(NMPolicy *self, nm_assert(retry_time != 0); priv->reset_connections_retries_idle_source = nm_g_timeout_add_seconds_source( - MAX(0, retry_time - nm_utils_get_monotonic_timestamp_sec()), + NM_MAX(0, retry_time - nm_utils_get_monotonic_timestamp_sec()), reset_connections_retries, self); } diff --git a/src/core/supplicant/nm-supplicant-interface.c b/src/core/supplicant/nm-supplicant-interface.c index e7bdfd49df..eb7a40a548 100644 --- a/src/core/supplicant/nm-supplicant-interface.c +++ b/src/core/supplicant/nm-supplicant-interface.c @@ -689,7 +689,7 @@ _bss_info_properties_changed(NMSupplicantInterface *self, v_v = nm_g_variant_lookup_value(properties, "SSID", G_VARIANT_TYPE_BYTESTRING); if (v_v) { arr_data = g_variant_get_fixed_array(v_v, &arr_len, 1); - arr_len = MIN(32, arr_len); + arr_len = NM_MIN(32u, arr_len); /* Stupid ieee80211 layer uses <hidden> */ if (arr_data && arr_len @@ -1380,7 +1380,7 @@ _get_capability(NMSupplicantInterfacePrivate *priv, NMSupplCapType type) case NM_SUPPL_CAP_TYPE_AP: iface_value = NM_SUPPL_CAP_MASK_GET(priv->iface_capabilities, type); value = NM_SUPPL_CAP_MASK_GET(priv->global_capabilities, type); - value = MAX(iface_value, value); + value = NM_MAX(iface_value, value); break; case NM_SUPPL_CAP_TYPE_FT: value = NM_SUPPL_CAP_MASK_GET(priv->global_capabilities, type); diff --git a/src/core/tests/test-core-with-expect.c b/src/core/tests/test-core-with-expect.c index 015101262c..680843fc74 100644 --- a/src/core/tests/test-core-with-expect.c +++ b/src/core/tests/test-core-with-expect.c @@ -617,7 +617,7 @@ test_nmp_utils_new_vlan_name(void) g_assert(ifname && ifname[0]); g_assert_cmpint(strlen(ifname), ==, - MIN(15, strlen(parent_names[i]) + strlen(vlan_id_s))); + NM_MIN(15u, strlen(parent_names[i]) + strlen(vlan_id_s))); g_assert(g_str_has_suffix(ifname, vlan_id_s)); g_assert(ifname[strlen(ifname) - strlen(vlan_id_s)] == '.'); g_assert(strncmp(ifname, parent_names[i], strlen(ifname) - strlen(vlan_id_s)) == 0); diff --git a/src/libnm-core-aux-intern/nm-auth-subject.c b/src/libnm-core-aux-intern/nm-auth-subject.c index 48fcf08fde..c381bdba38 100644 --- a/src/libnm-core-aux-intern/nm-auth-subject.c +++ b/src/libnm-core-aux-intern/nm-auth-subject.c @@ -363,9 +363,9 @@ constructed(GObject *object) case NM_AUTH_SUBJECT_TYPE_UNIX_PROCESS: /* Ensure pid and uid to be representable as int32. * DBUS treats them as uint32, polkit library as int. */ - if (priv->unix_process.pid > MIN(G_MAXINT, G_MAXINT32)) + if (priv->unix_process.pid > NM_MIN(G_MAXINT, G_MAXINT32)) break; - if (priv->unix_process.uid > MIN(G_MAXINT, G_MAXINT32)) { + if (priv->unix_process.uid > NM_MIN(G_MAXINT, G_MAXINT32)) { /* for uid==-1, libpolkit-gobject-1 detects the user based on the process id. * Don't bother and require the user id as parameter. */ break; diff --git a/src/libnm-core-impl/nm-team-utils.c b/src/libnm-core-impl/nm-team-utils.c index 1aae11e49d..6f2f5dd298 100644 --- a/src/libnm-core-impl/nm-team-utils.c +++ b/src/libnm-core-impl/nm-team-utils.c @@ -2812,9 +2812,9 @@ nm_team_setting_new(gboolean is_port, const char *js_str) gsize l; G_STATIC_ASSERT_EXPR(sizeof(*self) == sizeof(self->_data_priv)); - G_STATIC_ASSERT_EXPR(sizeof(*self) - == NM_CONST_MAX(nm_offsetofend(NMTeamSetting, d.master), - nm_offsetofend(NMTeamSetting, d.port))); + G_STATIC_ASSERT_EXPR( + sizeof(*self) + == NM_MAX(nm_offsetofend(NMTeamSetting, d.master), nm_offsetofend(NMTeamSetting, d.port))); l = is_port ? nm_offsetofend(NMTeamSetting, d.port) : nm_offsetofend(NMTeamSetting, d.master); diff --git a/src/libnm-core-impl/nm-team-utils.h b/src/libnm-core-impl/nm-team-utils.h index 06fa6cc8b8..722fa18825 100644 --- a/src/libnm-core-impl/nm-team-utils.h +++ b/src/libnm-core-impl/nm-team-utils.h @@ -48,7 +48,8 @@ typedef enum { NM_TEAM_ATTRIBUTE_PORT_LACP_KEY, _NM_TEAM_ATTRIBUTE_PORT_NUM, - _NM_TEAM_ATTRIBUTE_NUM = MAX(_NM_TEAM_ATTRIBUTE_MASTER_NUM, _NM_TEAM_ATTRIBUTE_PORT_NUM), + _NM_TEAM_ATTRIBUTE_NUM = + NM_MAX_CONST(_NM_TEAM_ATTRIBUTE_MASTER_NUM, _NM_TEAM_ATTRIBUTE_PORT_NUM), } NMTeamAttribute; diff --git a/src/libnm-core-impl/nm-utils.c b/src/libnm-core-impl/nm-utils.c index 2bd8936da7..c476d18661 100644 --- a/src/libnm-core-impl/nm-utils.c +++ b/src/libnm-core-impl/nm-utils.c @@ -669,7 +669,7 @@ nm_utils_escape_ssid(const guint8 *ssid, gsize len) return escaped; } - len = MIN(len, (guint32) NM_IW_ESSID_MAX_SIZE); + len = NM_MIN(len, (guint32) NM_IW_ESSID_MAX_SIZE); while (len--) { if (*s == '\0') { *d++ = '\\'; @@ -1518,7 +1518,7 @@ nm_utils_ip4_routes_to_variant(GPtrArray *routes) array[1] = nm_ip_route_get_prefix(route); nm_ip_route_get_next_hop_binary(route, &array[2]); /* The old routes format uses "0" for default, not "-1" */ - array[3] = MAX(0, nm_ip_route_get_metric(route)); + array[3] = NM_MAX(0, nm_ip_route_get_metric(route)); g_variant_builder_add(&builder, "@au", nm_g_variant_new_au(array, 4)); } diff --git a/src/libnm-core-impl/nm-vpn-editor-plugin.c b/src/libnm-core-impl/nm-vpn-editor-plugin.c index 6c9aff43c6..6181368a5e 100644 --- a/src/libnm-core-impl/nm-vpn-editor-plugin.c +++ b/src/libnm-core-impl/nm-vpn-editor-plugin.c @@ -209,7 +209,7 @@ nm_vpn_editor_plugin_get_vt(NMVpnEditorPlugin *plugin, NMVpnEditorPluginVT *vt, if (!p_vt) p_vt_size = 0; g_return_val_if_fail(p_vt_size, 0); - memcpy(vt, p_vt, MIN(vt_size, p_vt_size)); + memcpy(vt, p_vt, NM_MIN(vt_size, p_vt_size)); } return p_vt_size; diff --git a/src/libnm-core-impl/nm-vpn-plugin-info.c b/src/libnm-core-impl/nm-vpn-plugin-info.c index aaeefe5ed1..588df91726 100644 --- a/src/libnm-core-impl/nm-vpn-plugin-info.c +++ b/src/libnm-core-impl/nm-vpn-plugin-info.c @@ -181,8 +181,8 @@ _sort_files(LoadDirInfo *a, LoadDirInfo *b) { time_t ta, tb; - ta = MAX(a->stat.st_mtime, a->stat.st_ctime); - tb = MAX(b->stat.st_mtime, b->stat.st_ctime); + ta = NM_MAX(a->stat.st_mtime, a->stat.st_ctime); + tb = NM_MAX(b->stat.st_mtime, b->stat.st_ctime); if (ta < tb) return 1; if (ta > tb) diff --git a/src/libnm-glib-aux/nm-dedup-multi.h b/src/libnm-glib-aux/nm-dedup-multi.h index 87a2b81583..ebc5d0a167 100644 --- a/src/libnm-glib-aux/nm-dedup-multi.h +++ b/src/libnm-glib-aux/nm-dedup-multi.h @@ -37,7 +37,7 @@ typedef enum _NMDedupMultiIdxMode { /*****************************************************************************/ -#define _NMDedupMultiObj_Align (MAX(_nm_alignof(void *), _nm_alignof(gint64))) +#define _NMDedupMultiObj_Align (NM_MAX_CONST(_nm_alignof(void *), _nm_alignof(gint64))) struct _NMDedupMultiObj { union { diff --git a/src/libnm-glib-aux/nm-glib.h b/src/libnm-glib-aux/nm-glib.h index 9c90d4299d..8d1208cf08 100644 --- a/src/libnm-glib-aux/nm-glib.h +++ b/src/libnm-glib-aux/nm-glib.h @@ -766,4 +766,10 @@ _nm_deprecated("Don't use this API") void _nm_forbidden_glib_api_n(gconstpointer /*****************************************************************************/ +/* Use either NM_MIN()/NM_MAX() or (if that doesn't work) use NM_MIN_CONST()/NM_MAX_CONST(). */ +#undef MIN +#undef MAX + +/*****************************************************************************/ + #endif /* __NM_GLIB_H__ */ diff --git a/src/libnm-glib-aux/nm-shared-utils.c b/src/libnm-glib-aux/nm-shared-utils.c index 34f5ce4185..99bb8d6e18 100644 --- a/src/libnm-glib-aux/nm-shared-utils.c +++ b/src/libnm-glib-aux/nm-shared-utils.c @@ -6962,10 +6962,10 @@ _poll_done_cb(GObject *source, GAsyncResult *result, gpointer user_data) else wait_ms = 0; if (poll_task_data->sleep_timeout_ms > 0) - wait_ms = MAX(wait_ms, poll_task_data->sleep_timeout_ms); + wait_ms = NM_MAX(wait_ms, poll_task_data->sleep_timeout_ms); poll_task_data->source_next_poll = - nm_g_source_attach(nm_g_timeout_source_new(MAX(1, wait_ms), + nm_g_source_attach(nm_g_timeout_source_new(NM_MAX(1, wait_ms), G_PRIORITY_DEFAULT, _poll_start_cb, poll_task_data, diff --git a/src/libnm-glib-aux/nm-test-utils.h b/src/libnm-glib-aux/nm-test-utils.h index de6fd0f1b0..627151fa21 100644 --- a/src/libnm-glib-aux/nm-test-utils.h +++ b/src/libnm-glib-aux/nm-test-utils.h @@ -1803,7 +1803,7 @@ nmtst_inet_from_string(int addr_family, const char *str) static inline const char * nmtst_inet_to_string(int addr_family, gconstpointer addr) { - static _nm_thread_local char buf[NM_CONST_MAX(INET6_ADDRSTRLEN, INET_ADDRSTRLEN)]; + static _nm_thread_local char buf[NM_MAX(INET6_ADDRSTRLEN, INET_ADDRSTRLEN)]; g_assert(NM_IN_SET(addr_family, AF_INET, AF_INET6)); g_assert(addr); diff --git a/src/libnm-glib-aux/tests/test-shared-general.c b/src/libnm-glib-aux/tests/test-shared-general.c index 416d26384f..55f8cbb1d1 100644 --- a/src/libnm-glib-aux/tests/test-shared-general.c +++ b/src/libnm-glib-aux/tests/test-shared-general.c @@ -67,6 +67,20 @@ test_nm_static_assert(void) /*****************************************************************************/ static void +test_max(void) +{ + /* Check that NM_MAX() of constant expressions is itself a constant. We + * build with -Wvla, so this is a constant! */ + char buf1[NM_MAX(55, 40)]; + char buf2[NM_MAX(1, NM_MAX(40, 55))]; + + G_STATIC_ASSERT(sizeof(buf1) == 55); + G_STATIC_ASSERT(sizeof(buf2) == 55); +} + +/*****************************************************************************/ + +static void test_gpid(void) { const int *int_ptr; @@ -2624,6 +2638,7 @@ main(int argc, char **argv) nmtst_init(&argc, &argv, TRUE); g_test_add_func("/general/test_nm_static_assert", test_nm_static_assert); + g_test_add_func("/general/test_max", test_max); g_test_add_func("/general/test_gpid", test_gpid); g_test_add_func("/general/test_monotonic_timestamp", test_monotonic_timestamp); g_test_add_func("/general/test_timespect_to", test_timespect_to); diff --git a/src/libnm-platform/nm-linux-platform.c b/src/libnm-platform/nm-linux-platform.c index 0880e91977..a04dc3a939 100644 --- a/src/libnm-platform/nm-linux-platform.c +++ b/src/libnm-platform/nm-linux-platform.c @@ -163,7 +163,7 @@ typedef enum _nm_packed { G_STATIC_ASSERT(RTA_MAX == (__RTA_MAX - 1)); #define RTA_PREF 20 #undef RTA_MAX -#define RTA_MAX (MAX((__RTA_MAX - 1), RTA_PREF)) +#define RTA_MAX (NM_MAX_CONST((__RTA_MAX - 1), RTA_PREF)) #ifndef MACVLAN_FLAG_NOPROMISC #define MACVLAN_FLAG_NOPROMISC 1 @@ -1096,7 +1096,7 @@ _addrtime_extend_lifetime(guint32 lifetime, guint32 seconds) return lifetime; v = (guint64) lifetime + (guint64) seconds; - return MIN(v, NM_PLATFORM_LIFETIME_PERMANENT - 1); + return NM_MIN(v, NM_PLATFORM_LIFETIME_PERMANENT - 1); } /* The rtnl_addr object contains relative lifetimes @valid and @preferred diff --git a/src/libnm-platform/nm-platform-utils.c b/src/libnm-platform/nm-platform-utils.c index fc68fbb148..6074c3421f 100644 --- a/src/libnm-platform/nm-platform-utils.c +++ b/src/libnm-platform/nm-platform-utils.c @@ -2177,7 +2177,7 @@ nmp_utils_new_vlan_name(const char *parent_iface, guint32 vlan_id) ifname = g_new(char, IFNAMSIZ); parent_len = strlen(parent_iface); - parent_len = MIN(parent_len, IFNAMSIZ - 1 - id_len); + parent_len = NM_MIN(parent_len, IFNAMSIZ - 1 - id_len); memcpy(ifname, parent_iface, parent_len); g_snprintf(&ifname[parent_len], IFNAMSIZ - parent_len, ".%u", vlan_id); @@ -2256,7 +2256,7 @@ nmp_utils_lifetime_get(guint32 timestamp, t_preferred = nmp_utils_lifetime_rebase_relative_time_on_now(timestamp, preferred, now); - NM_SET_OUT(out_preferred, MIN(t_preferred, t_lifetime)); + NM_SET_OUT(out_preferred, NM_MIN(t_preferred, t_lifetime)); /* Assert that non-permanent addresses have a (positive) @timestamp. nmp_utils_lifetime_rebase_relative_time_on_now() * treats addresses with timestamp 0 as *now*. Addresses passed to _address_get_lifetime() always diff --git a/src/libnm-platform/nm-platform.c b/src/libnm-platform/nm-platform.c index 68d41daa98..a4751113da 100644 --- a/src/libnm-platform/nm-platform.c +++ b/src/libnm-platform/nm-platform.c @@ -8651,7 +8651,7 @@ nm_platform_ip4_route_hash_update(const NMPlatformIP4Route *obj, obj->ifindex, nm_platform_ip4_route_get_n_nexthops(obj), obj->gateway, - (guint8) MAX(obj->weight, 1u)); + (guint8) NM_MAX(obj->weight, 1u)); } } break; @@ -8666,7 +8666,7 @@ nm_platform_ip4_route_hash_update(const NMPlatformIP4Route *obj, obj->metric, nm_platform_ip4_route_get_n_nexthops(obj), obj->gateway, - (guint8) MAX(obj->weight, 1u), + (guint8) NM_MAX(obj->weight, 1u), nmp_utils_ip_config_source_round_trip_rtprot(obj->rt_source), _ip_route_scope_inv_get_normalized(obj), obj->tos, @@ -8764,7 +8764,7 @@ nm_platform_ip4_route_cmp(const NMPlatformIP4Route *a, NM_CMP_FIELD_UNSAFE(a, b, table_any); NM_CMP_DIRECT(nm_platform_ip_route_get_effective_table(NM_PLATFORM_IP_ROUTE_CAST(a)), nm_platform_ip_route_get_effective_table(NM_PLATFORM_IP_ROUTE_CAST(b))); - NM_CMP_DIRECT_IP4_ADDR_SAME_PREFIX(a->network, b->network, MIN(a->plen, b->plen)); + NM_CMP_DIRECT_IP4_ADDR_SAME_PREFIX(a->network, b->network, NM_MIN(a->plen, b->plen)); NM_CMP_FIELD(a, b, plen); NM_CMP_FIELD_UNSAFE(a, b, metric_any); NM_CMP_FIELD(a, b, metric); @@ -8819,7 +8819,7 @@ nm_platform_ip4_route_cmp(const NMPlatformIP4Route *a, NM_CMP_FIELD(a, b, table_coerced); NM_CMP_FIELD(a, b, ifindex); if (cmp_type == NM_PLATFORM_IP_ROUTE_CMP_TYPE_SEMANTICALLY) - NM_CMP_DIRECT_IP4_ADDR_SAME_PREFIX(a->network, b->network, MIN(a->plen, b->plen)); + NM_CMP_DIRECT_IP4_ADDR_SAME_PREFIX(a->network, b->network, NM_MIN(a->plen, b->plen)); else NM_CMP_FIELD(a, b, network); NM_CMP_FIELD(a, b, plen); @@ -8991,11 +8991,11 @@ nm_platform_ip6_route_cmp(const NMPlatformIP6Route *a, NM_CMP_FIELD_UNSAFE(a, b, table_any); NM_CMP_DIRECT(nm_platform_ip_route_get_effective_table(NM_PLATFORM_IP_ROUTE_CAST(a)), nm_platform_ip_route_get_effective_table(NM_PLATFORM_IP_ROUTE_CAST(b))); - NM_CMP_DIRECT_IP6_ADDR_SAME_PREFIX(&a->network, &b->network, MIN(a->plen, b->plen)); + NM_CMP_DIRECT_IP6_ADDR_SAME_PREFIX(&a->network, &b->network, NM_MIN(a->plen, b->plen)); NM_CMP_FIELD(a, b, plen); NM_CMP_FIELD_UNSAFE(a, b, metric_any); NM_CMP_FIELD(a, b, metric); - NM_CMP_DIRECT_IP6_ADDR_SAME_PREFIX(&a->src, &b->src, MIN(a->src_plen, b->src_plen)); + NM_CMP_DIRECT_IP6_ADDR_SAME_PREFIX(&a->src, &b->src, NM_MIN(a->src_plen, b->src_plen)); NM_CMP_FIELD(a, b, src_plen); if (cmp_type == NM_PLATFORM_IP_ROUTE_CMP_TYPE_ID) { NM_CMP_FIELD(a, b, ifindex); @@ -9014,7 +9014,7 @@ nm_platform_ip6_route_cmp(const NMPlatformIP6Route *a, NM_CMP_FIELD(a, b, table_coerced); NM_CMP_FIELD(a, b, ifindex); if (cmp_type == NM_PLATFORM_IP_ROUTE_CMP_TYPE_SEMANTICALLY) - NM_CMP_DIRECT_IP6_ADDR_SAME_PREFIX(&a->network, &b->network, MIN(a->plen, b->plen)); + NM_CMP_DIRECT_IP6_ADDR_SAME_PREFIX(&a->network, &b->network, NM_MIN(a->plen, b->plen)); else NM_CMP_FIELD_IN6ADDR(a, b, network); NM_CMP_FIELD(a, b, plen); @@ -9023,7 +9023,7 @@ nm_platform_ip6_route_cmp(const NMPlatformIP6Route *a, NM_CMP_FIELD_IN6ADDR(a, b, gateway); NM_CMP_FIELD_IN6ADDR(a, b, pref_src); if (cmp_type == NM_PLATFORM_IP_ROUTE_CMP_TYPE_SEMANTICALLY) { - NM_CMP_DIRECT_IP6_ADDR_SAME_PREFIX(&a->src, &b->src, MIN(a->src_plen, b->src_plen)); + NM_CMP_DIRECT_IP6_ADDR_SAME_PREFIX(&a->src, &b->src, NM_MIN(a->src_plen, b->src_plen)); NM_CMP_FIELD(a, b, src_plen); NM_CMP_DIRECT(nmp_utils_ip_config_source_round_trip_rtprot(a->rt_source), nmp_utils_ip_config_source_round_trip_rtprot(b->rt_source)); diff --git a/src/libnm-platform/nmp-plobj.c b/src/libnm-platform/nmp-plobj.c index d3643ae1c1..70664634e6 100644 --- a/src/libnm-platform/nmp-plobj.c +++ b/src/libnm-platform/nmp-plobj.c @@ -424,7 +424,7 @@ nm_platform_ip4_address_to_string(const NMPlatformIP4Address *address, char *buf (address->lifetime == address->preferred) ? str_lft_p : (_lifetime_to_string(address->timestamp, - address->lifetime ? MIN(address->preferred, address->lifetime) + address->lifetime ? NM_MIN(address->preferred, address->lifetime) : NM_PLATFORM_LIFETIME_PERMANENT, now, str_pref, @@ -522,7 +522,7 @@ nm_platform_ip6_address_to_string(const NMPlatformIP6Address *address, char *buf (address->lifetime == address->preferred) ? str_lft_p : (_lifetime_to_string(address->timestamp, - address->lifetime ? MIN(address->preferred, address->lifetime) + address->lifetime ? NM_MIN(address->preferred, address->lifetime) : NM_PLATFORM_LIFETIME_PERMANENT, now, str_pref, diff --git a/src/libnm-platform/nmp-plobj.h b/src/libnm-platform/nmp-plobj.h index 35c81509c1..ad18573f8e 100644 --- a/src/libnm-platform/nmp-plobj.h +++ b/src/libnm-platform/nmp-plobj.h @@ -17,7 +17,7 @@ * also "packed" is specified. That's what we want. * https://gcc.gnu.org/onlinedocs/gcc/Common-Type-Attributes.html#Common-Type-Attributes. */ -#define _NMPlatformObject_Align (MAX(_nm_alignof(void *), _nm_alignof(gint64))) +#define _NMPlatformObject_Align (NM_MAX_CONST(_nm_alignof(void *), _nm_alignof(gint64))) struct _NMPlatformObject { /* the object type has no fields of its own, it is only used to having diff --git a/src/libnm-platform/wifi/nm-wifi-utils-wext.c b/src/libnm-platform/wifi/nm-wifi-utils-wext.c index 8ebf6bef80..16503430bc 100644 --- a/src/libnm-platform/wifi/nm-wifi-utils-wext.c +++ b/src/libnm-platform/wifi/nm-wifi-utils-wext.c @@ -548,7 +548,7 @@ wifi_wext_set_mesh_ssid(NMWifiUtils *data, const guint8 *ssid, gsize len) return FALSE; memset(buf, 0, sizeof(buf)); - memcpy(buf, ssid, MIN(sizeof(buf) - 1, len)); + memcpy(buf, ssid, NM_MIN(sizeof(buf) - 1, len)); wrq.u.essid.pointer = (caddr_t) buf; wrq.u.essid.length = len; @@ -758,7 +758,7 @@ nm_wifi_utils_wext_new(int ifindex, gboolean check_scan) wext->max_qual.noise = range.max_qual.noise; wext->max_qual.updated = range.max_qual.updated; - wext->num_freqs = MIN(range.num_frequency, IW_MAX_FREQUENCIES); + wext->num_freqs = NM_MIN(range.num_frequency, (guint) IW_MAX_FREQUENCIES); for (i = 0; i < wext->num_freqs; i++) { wext->freqs[i] = iw_freq_to_uint32(&range.freq[i]); freq_valid = TRUE; diff --git a/src/libnm-std-aux/nm-std-aux.h b/src/libnm-std-aux/nm-std-aux.h index 46d8f2025e..3b39a01940 100644 --- a/src/libnm-std-aux/nm-std-aux.h +++ b/src/libnm-std-aux/nm-std-aux.h @@ -392,46 +392,63 @@ nm_mult_clamped_u(unsigned a, unsigned b) return c; } -/* glib's MIN()/MAX() macros don't have function-like behavior, in that they evaluate - * the argument possibly twice. - * - * Taken from systemd's MIN()/MAX() macros. */ - -#define NM_MIN(a, b) __NM_MIN(NM_UNIQ, a, NM_UNIQ, b) -#define __NM_MIN(aq, a, bq, b) \ - ({ \ - typeof(a) NM_UNIQ_T(A, aq) = (a); \ - typeof(b) NM_UNIQ_T(B, bq) = (b); \ - \ - G_STATIC_ASSERT(_NM_INT_SAME_SIGNEDNESS(NM_UNIQ_T(A, aq), NM_UNIQ_T(B, bq))); \ - \ - ((NM_UNIQ_T(A, aq) < NM_UNIQ_T(B, bq)) ? NM_UNIQ_T(A, aq) : NM_UNIQ_T(B, bq)); \ +/* In a few places where a constant expression is required, NM_MIN() doesn't work. + * In that case, use NM_MIN_CONST(). */ +#define NM_MIN_CONST(a, b) \ + ((NM_STATIC_ASSERT_EXPR_1(_NM_INT_SAME_SIGNEDNESS((a), (b)) && __builtin_constant_p((a)) \ + && __builtin_constant_p((b))) \ + && ((a) <= (b))) \ + ? (a) \ + : (b)) + +#define _NM_MIN_V(aq, a, bq, b) \ + ({ \ + typeof(a) NM_UNIQ_T(A, aq) = (a); \ + typeof(b) NM_UNIQ_T(B, bq) = (b); \ + \ + ((NM_UNIQ_T(A, aq) <= NM_UNIQ_T(B, bq)) ? NM_UNIQ_T(A, aq) : NM_UNIQ_T(B, bq)); \ }) -#define NM_MAX(a, b) __NM_MAX(NM_UNIQ, a, NM_UNIQ, b) -#define __NM_MAX(aq, a, bq, b) \ - ({ \ - typeof(a) NM_UNIQ_T(A, aq) = (a); \ - typeof(b) NM_UNIQ_T(B, bq) = (b); \ - \ - G_STATIC_ASSERT(_NM_INT_SAME_SIGNEDNESS(NM_UNIQ_T(A, aq), NM_UNIQ_T(B, bq))); \ - \ - ((NM_UNIQ_T(A, aq) > NM_UNIQ_T(B, bq)) ? NM_UNIQ_T(A, aq) : NM_UNIQ_T(B, bq)); \ +#define NM_MIN(a, b) \ + __builtin_choose_expr(__builtin_constant_p((a)) && __builtin_constant_p((b)) \ + && NM_STATIC_ASSERT_EXPR_1(_NM_INT_SAME_SIGNEDNESS((a), (b))), \ + (((a) <= (b)) ? (a) : (b)), \ + _NM_MIN_V(NM_UNIQ, a, NM_UNIQ, b)) + +#define NM_MAX_CONST(a, b) \ + ((NM_STATIC_ASSERT_EXPR_1(_NM_INT_SAME_SIGNEDNESS((a), (b)) && __builtin_constant_p((a)) \ + && __builtin_constant_p((b))) \ + && ((a) >= (b))) \ + ? (a) \ + : (b)) + +#define _NM_MAX_V(aq, a, bq, b) \ + ({ \ + typeof(a) NM_UNIQ_T(A, aq) = (a); \ + typeof(b) NM_UNIQ_T(B, bq) = (b); \ + \ + ((NM_UNIQ_T(A, aq) >= NM_UNIQ_T(B, bq)) ? NM_UNIQ_T(A, aq) : NM_UNIQ_T(B, bq)); \ }) +#define NM_MAX(a, b) \ + __builtin_choose_expr(__builtin_constant_p((a)) && __builtin_constant_p((b)) \ + && NM_STATIC_ASSERT_EXPR_1(_NM_INT_SAME_SIGNEDNESS((a), (b))), \ + (((a) >= (b)) ? (a) : (b)), \ + _NM_MAX_V(NM_UNIQ, a, NM_UNIQ, b)) + #define NM_CLAMP(x, low, high) __NM_CLAMP(NM_UNIQ, x, NM_UNIQ, low, NM_UNIQ, high) -#define __NM_CLAMP(xq, x, lowq, low, highq, high) \ - ({ \ - typeof(x) NM_UNIQ_T(X, xq) = (x); \ - typeof(low) NM_UNIQ_T(LOW, lowq) = (low); \ - typeof(high) NM_UNIQ_T(HIGH, highq) = (high); \ - \ - G_STATIC_ASSERT(_NM_INT_SAME_SIGNEDNESS(NM_UNIQ_T(X, xq), NM_UNIQ_T(LOW, lowq))); \ - G_STATIC_ASSERT(_NM_INT_SAME_SIGNEDNESS(NM_UNIQ_T(X, xq), NM_UNIQ_T(HIGH, highq))); \ - \ - ((NM_UNIQ_T(X, xq) > NM_UNIQ_T(HIGH, highq)) ? NM_UNIQ_T(HIGH, highq) \ - : (NM_UNIQ_T(X, xq) < NM_UNIQ_T(LOW, lowq)) ? NM_UNIQ_T(LOW, lowq) \ - : NM_UNIQ_T(X, xq)); \ +#define __NM_CLAMP(xq, x, lowq, low, highq, high) \ + ({ \ + typeof(x) NM_UNIQ_T(X, xq) = (x); \ + typeof(low) NM_UNIQ_T(LOW, lowq) = (low); \ + typeof(high) NM_UNIQ_T(HIGH, highq) = (high); \ + \ + NM_STATIC_ASSERT(_NM_INT_SAME_SIGNEDNESS(NM_UNIQ_T(X, xq), NM_UNIQ_T(LOW, lowq))); \ + NM_STATIC_ASSERT(_NM_INT_SAME_SIGNEDNESS(NM_UNIQ_T(X, xq), NM_UNIQ_T(HIGH, highq))); \ + \ + ((NM_UNIQ_T(X, xq) > NM_UNIQ_T(HIGH, highq)) ? NM_UNIQ_T(HIGH, highq) \ + : (NM_UNIQ_T(X, xq) < NM_UNIQ_T(LOW, lowq)) ? NM_UNIQ_T(LOW, lowq) \ + : NM_UNIQ_T(X, xq)); \ }) #define NM_MAX_WITH_CMP(cmp, a, b) \ @@ -442,13 +459,6 @@ nm_mult_clamped_u(unsigned a, unsigned b) (((cmp(_a, _b)) >= 0) ? _a : _b); \ }) -/* evaluates to (void) if _A or _B are not constant or of different types */ -#define NM_CONST_MAX(_A, _B) \ - (__builtin_choose_expr((__builtin_constant_p(_A) && __builtin_constant_p(_B) \ - && __builtin_types_compatible_p(typeof(_A), typeof(_B))), \ - ((_A) > (_B)) ? (_A) : (_B), \ - ((void) 0))) - /* Determine whether @x is a power of two (@x being an integer type). * Basically, this returns TRUE, if @x has exactly one bit set. * For negative values and zero, this always returns FALSE. */ @@ -1302,15 +1312,15 @@ nm_ptr_to_uintptr(const void *p) /*****************************************************************************/ -#define NM_CMP_DIRECT(a, b) \ - do { \ - typeof(a) _a = (a); \ - typeof(b) _b = (b); \ - \ - G_STATIC_ASSERT(_NM_INT_SAME_SIGNEDNESS(_a, _b)); \ - \ - if (_a != _b) \ - return (_a < _b) ? -1 : 1; \ +#define NM_CMP_DIRECT(a, b) \ + do { \ + typeof(a) _a = (a); \ + typeof(b) _b = (b); \ + \ + NM_STATIC_ASSERT(_NM_INT_SAME_SIGNEDNESS(_a, _b)); \ + \ + if (_a != _b) \ + return (_a < _b) ? -1 : 1; \ } while (0) #define NM_CMP_DIRECT_UNSAFE(a, b) \ diff --git a/src/libnm-systemd-core/src/libsystemd-network/sd-dhcp6-client.c b/src/libnm-systemd-core/src/libsystemd-network/sd-dhcp6-client.c index a2605b718c..0e6f21f47b 100644 --- a/src/libnm-systemd-core/src/libsystemd-network/sd-dhcp6-client.c +++ b/src/libnm-systemd-core/src/libsystemd-network/sd-dhcp6-client.c @@ -824,7 +824,7 @@ int dhcp6_client_send_message(sd_dhcp6_client *client) { /* RFC 8415 Section 21.9. * A client MUST include an Elapsed Time option in messages to indicate how long the client has * been trying to complete a DHCP message exchange. */ - elapsed_usec = MIN(usec_sub_unsigned(time_now, client->transaction_start) / USEC_PER_MSEC / 10, (usec_t) UINT16_MAX); + elapsed_usec = NM_MIN(usec_sub_unsigned(time_now, client->transaction_start) / USEC_PER_MSEC / 10, (usec_t) UINT16_MAX); elapsed_time = htobe16(elapsed_usec); r = dhcp6_option_append(&buf, &offset, SD_DHCP6_OPTION_ELAPSED_TIME, sizeof(elapsed_time), &elapsed_time); if (r < 0) @@ -1052,7 +1052,7 @@ static int client_enter_bound_state(sd_dhcp6_client *client) { goto error; lifetime_t2 = client_timeout_compute_random(lifetime_t2); - lifetime_t1 = client_timeout_compute_random(MIN(lifetime_t1, lifetime_t2)); + lifetime_t1 = client_timeout_compute_random(NM_MIN(lifetime_t1, lifetime_t2)); if (lifetime_t1 == USEC_INFINITY) { log_dhcp6_client(client, "Infinite T1"); diff --git a/src/libnmt-newt/nmt-newt-button-box.c b/src/libnmt-newt/nmt-newt-button-box.c index f3c8b27e3b..de17d5a873 100644 --- a/src/libnmt-newt/nmt-newt-button-box.c +++ b/src/libnmt-newt/nmt-newt-button-box.c @@ -218,12 +218,12 @@ size_request_buttons(NmtNewtButtonBox *bbox, GPtrArray *buttons, int *width, int *width += child_width; if (i > 0) *width += 1; - *height = MAX(*height, child_height); + *height = NM_MAX(*height, child_height); } else { *height += child_height; if (i > 0) *height += 1; - *width = MAX(*width, child_width); + *width = NM_MAX(*width, child_width); } } } diff --git a/src/libnmt-newt/nmt-newt-form.c b/src/libnmt-newt/nmt-newt-form.c index 6e0589cc5b..3565799c6a 100644 --- a/src/libnmt-newt/nmt-newt-form.c +++ b/src/libnmt-newt/nmt-newt-form.c @@ -182,9 +182,9 @@ nmt_newt_form_build(NmtNewtForm *form) newtGetScreenSize(&screen_width, &screen_height); if (!priv->fixed_width) - priv->width = MIN(form_width + 2 * priv->padding, screen_width - 2); + priv->width = NM_MIN(form_width + 2 * ((gint64) priv->padding), screen_width - 2); if (!priv->fixed_height) - priv->height = MIN(form_height + 2 * priv->padding, screen_height - 2); + priv->height = NM_MIN(form_height + 2 * ((gint64) priv->padding), screen_height - 2); if (!priv->fixed_x) priv->x = (screen_width - form_width) / 2; diff --git a/src/libnmt-newt/nmt-newt-section.c b/src/libnmt-newt/nmt-newt-section.c index eb551273a3..e0c404f0e3 100644 --- a/src/libnmt-newt/nmt-newt-section.c +++ b/src/libnmt-newt/nmt-newt-section.c @@ -249,7 +249,7 @@ nmt_newt_section_size_request(NmtNewtWidget *widget, int *width, int *height) nmt_newt_widget_size_request(priv->header, &priv->hwidth_req, &priv->hheight_req); nmt_newt_widget_size_request(priv->body, &priv->bwidth_req, &priv->bheight_req); - *width = MAX(priv->hwidth_req, priv->bwidth_req) + 2; + *width = NM_MAX(priv->hwidth_req, priv->bwidth_req) + 2; if (priv->open) *height = priv->hheight_req + priv->bheight_req + (priv->show_border ? 1 : 0); else diff --git a/src/libnmt-newt/nmt-newt-textbox.c b/src/libnmt-newt/nmt-newt-textbox.c index 24aae9f9e7..bf9b6a2948 100644 --- a/src/libnmt-newt/nmt-newt-textbox.c +++ b/src/libnmt-newt/nmt-newt-textbox.c @@ -95,7 +95,7 @@ nmt_newt_textbox_set_text(NmtNewtTextbox *textbox, const char *text) priv->width = width; } g_free(lines); - priv->height = MIN(i, 1); + priv->height = NM_MIN(i, 1); g_object_notify(G_OBJECT(textbox), "text"); nmt_newt_widget_needs_rebuild(NMT_NEWT_WIDGET(textbox)); diff --git a/src/libnmt-newt/nmt-newt-utils.c b/src/libnmt-newt/nmt-newt-utils.c index 14825fab0a..e021981cc2 100644 --- a/src/libnmt-newt/nmt-newt-utils.c +++ b/src/libnmt-newt/nmt-newt-utils.c @@ -65,7 +65,7 @@ nmt_newt_dialog_g_log_handler(const char *log_domain, */ newtGetScreenSize(&screen_width, &screen_height); - text = newtTextboxReflowed(-1, -1, full_message, MAX(70, screen_width - 10), 0, 0, 0); + text = newtTextboxReflowed(-1, -1, full_message, NM_MAX(70, screen_width - 10), 0, 0, 0); g_free(full_message); ok = newtButton(-1, -1, "OK"); diff --git a/src/nm-online/nm-online.c b/src/nm-online/nm-online.c index bba3cd5cc6..b1de621e67 100644 --- a/src/nm-online/nm-online.c +++ b/src/nm-online/nm-online.c @@ -76,7 +76,7 @@ _print_progress(gboolean wait_startup, int progress_next_step_i, gint64 remainin g_print("\r%s", _("Connecting")); for (i = 0; i < PROGRESS_STEPS; i++) putchar(i < j ? '.' : ' '); - g_print(" %4lds", (long) (MAX(0, remaining_ms + 999) / 1000)); + g_print(" %4lds", (long) (NM_MAX(0, remaining_ms + 999) / 1000)); if (retval != EXIT_NONE) { const char *result; diff --git a/src/nmcli/devices.c b/src/nmcli/devices.c index a085baac62..40ef536e14 100644 --- a/src/nmcli/devices.c +++ b/src/nmcli/devices.c @@ -1347,7 +1347,7 @@ fill_output_access_point(NMAccessPoint *ap, const APInfo *info) mode = nm_access_point_get_mode(ap); bitrate = nm_access_point_get_max_bitrate(ap); bandwidth = nm_access_point_get_bandwidth(ap); - strength = MIN(nm_access_point_get_strength(ap), 100); + strength = NM_MIN(nm_access_point_get_strength(ap), 100u); /* Convert to strings */ if (ssid) { diff --git a/src/nmtui/nmt-connect-connection-list.c b/src/nmtui/nmt-connect-connection-list.c index 5d771b618e..329494cc1b 100644 --- a/src/nmtui/nmt-connect-connection-list.c +++ b/src/nmtui/nmt-connect-connection-list.c @@ -480,7 +480,7 @@ nmt_connect_connection_list_rebuild(NmtConnectConnectionList *list) for (citer = nmtdev->conns; citer; citer = citer->next) { nmtconn = citer->data; - max_width = MAX(max_width, nmt_newt_text_width(nmtconn->name)); + max_width = NM_MAX(max_width, nmt_newt_text_width(nmtconn->name)); } } diff --git a/src/nmtui/nmt-editor-grid.c b/src/nmtui/nmt-editor-grid.c index 9b76e3fe22..bdcc02e259 100644 --- a/src/nmtui/nmt-editor-grid.c +++ b/src/nmtui/nmt-editor-grid.c @@ -326,10 +326,10 @@ nmt_editor_grid_size_request(NmtNewtWidget *widget, int *width, int *height) if (rows[i].label) { nmt_newt_widget_size_request(rows[i].label, &lwidth, &lheight); lwidth += priv->indent; - state->col_widths[0] = MAX(state->col_widths[0], lwidth); + state->col_widths[0] = NM_MAX(state->col_widths[0], lwidth); nmt_newt_widget_size_request(rows[i].widget, &wwidth, &wheight); - state->col_widths[1] = MAX(state->col_widths[1], wwidth); + state->col_widths[1] = NM_MAX(state->col_widths[1], wwidth); priv->row_heights[i] = wheight; add_padding = TRUE; @@ -340,8 +340,8 @@ nmt_editor_grid_size_request(NmtNewtWidget *widget, int *width, int *height) if (rows[i].extra) { nmt_newt_widget_size_request(rows[i].extra, &ewidth, &eheight); - state->col_widths[2] = MAX(state->col_widths[2], ewidth); - priv->row_heights[i] = MAX(priv->row_heights[i], eheight); + state->col_widths[2] = NM_MAX(state->col_widths[2], ewidth); + priv->row_heights[i] = NM_MAX(priv->row_heights[i], eheight); } *height += priv->row_heights[i]; diff --git a/src/nmtui/nmt-route-table.c b/src/nmtui/nmt-route-table.c index 4dc28d7ca5..04c37f3a37 100644 --- a/src/nmtui/nmt-route-table.c +++ b/src/nmtui/nmt-route-table.c @@ -185,8 +185,8 @@ nmt_route_table_init(NmtRouteTable *table) metric_width = nmt_newt_text_width(text); nmt_newt_grid_add(NMT_NEWT_GRID(header), metric_label, 2, 0); - priv->ip_entry_width = MAX(20, MAX(dest_prefix_width, next_hop_width)); - priv->metric_entry_width = MAX(7, metric_width); + priv->ip_entry_width = NM_MAX(20, NM_MAX(dest_prefix_width, next_hop_width)); + priv->metric_entry_width = NM_MAX(7, metric_width); nmt_newt_widget_set_padding(dest_prefix_label, 0, diff --git a/src/nmtui/nmtui-connect.c b/src/nmtui/nmtui-connect.c index 0dfbf6ac20..4f90adf324 100644 --- a/src/nmtui/nmtui-connect.c +++ b/src/nmtui/nmtui-connect.c @@ -326,8 +326,8 @@ listbox_active_changed(GObject *object, GParamSpec *pspec, gpointer button) deactivate = _("Deactivate"); deactivate_width = nmt_newt_text_width(deactivate); - activate_padding = MAX(0, deactivate_width - activate_width); - deactivate_padding = MAX(0, activate_width - deactivate_width); + activate_padding = NM_MAX(0, deactivate_width - activate_width); + deactivate_padding = NM_MAX(0, activate_width - deactivate_width); } has_selection = nmt_connect_connection_list_get_selection(list, NULL, NULL, NULL, &ac); |