mirror of
https://gitlab.freedesktop.org/NetworkManager/NetworkManager.git
synced 2025-12-29 18:30:11 +01:00
all: ensure same signedness of arguments to MIN()/MAX()
Comparing integers of different signedness gives often unexpected results. Adjust usages of MIN()/MAX() to ensure that the arguments agree in signedness.
This commit is contained in:
parent
5671d73fb5
commit
6f4a60b6f2
8 changed files with 14 additions and 14 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, 32);
|
||||
ssid_len = 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, (7 * 24 * 3600));
|
||||
interval = MIN(interval, (7u * 24 * 3600));
|
||||
if (priv->interval != interval) {
|
||||
priv->interval = interval;
|
||||
changed = TRUE;
|
||||
|
|
|
|||
|
|
@ -738,15 +738,15 @@ 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 = 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. */
|
||||
|
|
@ -1031,17 +1031,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 = 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(
|
||||
|
|
|
|||
|
|
@ -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 = 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(15, strlen(parent_names[i]) + strlen(vlan_id_s)));
|
||||
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);
|
||||
|
|
|
|||
|
|
@ -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 = 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;
|
||||
|
|
|
|||
|
|
@ -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 = 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 = MIN(form_height + 2 * ((gint64) priv->padding), screen_height - 2);
|
||||
|
||||
if (!priv->fixed_x)
|
||||
priv->x = (screen_width - form_width) / 2;
|
||||
|
|
|
|||
|
|
@ -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 = MIN(nm_access_point_get_strength(ap), 100u);
|
||||
|
||||
/* Convert to strings */
|
||||
if (ssid) {
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue