mirror of
https://gitlab.freedesktop.org/NetworkManager/NetworkManager.git
synced 2026-01-04 19:10:17 +01:00
all: use NM_MIN() instead of MIN()
This commit is contained in:
parent
559d071f8d
commit
b4dd83975e
19 changed files with 38 additions and 37 deletions
|
|
@ -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, 32u);
|
||||
ssid_len = NM_MIN(ssid_len, 32u);
|
||||
memcpy(name_buf, ssid_bytes, ssid_len);
|
||||
name_buf[ssid_len] = '\0';
|
||||
|
||||
|
|
|
|||
|
|
@ -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, (7u * 24 * 3600));
|
||||
interval = NM_MIN(interval, (7u * 24 * 3600));
|
||||
if (priv->interval != interval) {
|
||||
priv->interval = interval;
|
||||
changed = TRUE;
|
||||
|
|
|
|||
|
|
@ -746,11 +746,12 @@ nm_utils_kill_child_sync(pid_t pid,
|
|||
was_waiting = TRUE;
|
||||
}
|
||||
|
||||
sleep_time = MIN(wait_until - now, (gint64) 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,7 +1032,7 @@ 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, (gint64) sleep_duration_usec);
|
||||
sleep_time = NM_MIN(wait_until_sigkill - now, (gint64) sleep_duration_usec);
|
||||
}
|
||||
|
||||
if (!was_waiting) {
|
||||
|
|
@ -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;
|
||||
|
|
@ -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);
|
||||
|
||||
|
|
|
|||
|
|
@ -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);
|
||||
|
||||
|
|
|
|||
|
|
@ -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);
|
||||
|
|
|
|||
|
|
@ -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(32u, arr_len);
|
||||
arr_len = NM_MIN(32u, arr_len);
|
||||
|
||||
/* Stupid ieee80211 layer uses <hidden> */
|
||||
if (arr_data && arr_len
|
||||
|
|
|
|||
|
|
@ -617,7 +617,7 @@ test_nmp_utils_new_vlan_name(void)
|
|||
g_assert(ifname && ifname[0]);
|
||||
g_assert_cmpint(strlen(ifname),
|
||||
==,
|
||||
MIN(15u, 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);
|
||||
|
|
|
|||
|
|
@ -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;
|
||||
|
|
|
|||
|
|
@ -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++ = '\\';
|
||||
|
|
|
|||
|
|
@ -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;
|
||||
|
|
|
|||
|
|
@ -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
|
||||
|
|
|
|||
|
|
@ -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
|
||||
|
|
|
|||
|
|
@ -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));
|
||||
|
|
|
|||
|
|
@ -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,
|
||||
|
|
|
|||
|
|
@ -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, (guint) 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;
|
||||
|
|
|
|||
|
|
@ -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");
|
||||
|
|
|
|||
|
|
@ -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 * ((gint64) 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 * ((gint64) 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;
|
||||
|
|
|
|||
|
|
@ -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));
|
||||
|
|
|
|||
|
|
@ -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), 100u);
|
||||
strength = NM_MIN(nm_access_point_get_strength(ap), 100u);
|
||||
|
||||
/* Convert to strings */
|
||||
if (ssid) {
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue