mirror of
https://gitlab.freedesktop.org/NetworkManager/NetworkManager
synced 2024-07-21 10:14:41 +00:00
shared: change NM_SWAP() macro to take pointer arguments
This makes the macro more function like. Also, taking a pointer makes it a bit clearer that this possibly changes the value. Of course, it's not a big difference to before, but this form seems slightly preferable to me.
This commit is contained in:
parent
ae55b98e02
commit
6bf5f014c8
|
@ -3823,7 +3823,7 @@ test_setting_compare_addresses (void)
|
|||
nm_ip_address_unref (a);
|
||||
|
||||
if (nmtst_get_rand_uint32 () % 2)
|
||||
NM_SWAP (s1, s2);
|
||||
NM_SWAP (&s1, &s2);
|
||||
|
||||
success = nm_setting_compare (s1, s2, NM_SETTING_COMPARE_FLAG_EXACT);
|
||||
g_assert (!success);
|
||||
|
@ -3855,7 +3855,7 @@ test_setting_compare_routes (void)
|
|||
nm_ip_route_unref (r);
|
||||
|
||||
if (nmtst_get_rand_uint32 () % 2)
|
||||
NM_SWAP (s1, s2);
|
||||
NM_SWAP (&s1, &s2);
|
||||
|
||||
success = nm_setting_compare (s1, s2, NM_SETTING_COMPARE_FLAG_EXACT);
|
||||
g_assert (!success);
|
||||
|
@ -7152,7 +7152,7 @@ _team_config_equal_check (const char *conf1,
|
|||
gboolean is_same;
|
||||
|
||||
if (nmtst_get_rand_bool ())
|
||||
NM_SWAP (conf1, conf2);
|
||||
NM_SWAP (&conf1, &conf2);
|
||||
|
||||
if (!nm_streq0 (conf1, conf2)) {
|
||||
_team_config_equal_check (conf1, conf1, port_config, TRUE);
|
||||
|
|
|
@ -312,7 +312,7 @@ _strv_cmp_fuzz_input (const char *const*in,
|
|||
if (nmtst_get_rand_bool ()) {
|
||||
/* randomly swap the original and the clone. That means, out_s1 is either
|
||||
* the input argument (as-is) or the sementically equal clone. */
|
||||
NM_SWAP (*out_s1, *out_s2);
|
||||
NM_SWAP (out_s1, out_s2);
|
||||
}
|
||||
if (nmtst_get_rand_bool ()) {
|
||||
/* randomly make s1 and s2 the same. This is for testing that
|
||||
|
|
|
@ -216,13 +216,15 @@
|
|||
|
||||
/*****************************************************************************/
|
||||
|
||||
#define NM_SWAP(a, b) \
|
||||
#define NM_SWAP(p_a, p_b) \
|
||||
do { \
|
||||
typeof (a) _tmp; \
|
||||
typeof (*(p_a)) *const _p_a = (p_a); \
|
||||
typeof (*(p_a)) *const _p_b = (p_b); \
|
||||
typeof (*(p_a)) _tmp; \
|
||||
\
|
||||
_tmp = (a); \
|
||||
(a) = (b); \
|
||||
(b) = _tmp; \
|
||||
_tmp = *_p_a; \
|
||||
*_p_a = *_p_b; \
|
||||
*_p_b = _tmp; \
|
||||
} while (0)
|
||||
|
||||
/*****************************************************************************/
|
||||
|
|
|
@ -2207,14 +2207,14 @@ nmtst_assert_setting_is_equal (gconstpointer /* const NMSetting * */ a,
|
|||
g_assert (NM_IS_SETTING (b));
|
||||
|
||||
if (NM_FLAGS_HAS (r, 0x4))
|
||||
NM_SWAP (a, b);
|
||||
NM_SWAP (&a, &b);
|
||||
|
||||
g_assert (nm_setting_compare ((NMSetting *) a,
|
||||
(NMSetting *) b,
|
||||
flags));
|
||||
|
||||
if (NM_FLAGS_HAS (r, 0x8))
|
||||
NM_SWAP (a, b);
|
||||
NM_SWAP (&a, &b);
|
||||
|
||||
g_assert (nm_setting_diff ((NMSetting *) a,
|
||||
(NMSetting *) b,
|
||||
|
|
|
@ -3772,7 +3772,7 @@ ip6_address_scope_cmp (gconstpointer p_a, gconstpointer p_b, gpointer increasing
|
|||
const NMPlatformIP6Address *b;
|
||||
|
||||
if (!increasing)
|
||||
NM_SWAP (p_a, p_b);
|
||||
NM_SWAP (&p_a, &p_b);
|
||||
|
||||
a = NMP_OBJECT_CAST_IP6_ADDRESS (*(const NMPObject *const*) p_a);
|
||||
b = NMP_OBJECT_CAST_IP6_ADDRESS (*(const NMPObject *const*) p_b);
|
||||
|
|
|
@ -1245,7 +1245,7 @@ again_uid_range:
|
|||
rr->uid_range.end = nmtst_rand_select (0u, uids.uid, uids.euid);
|
||||
if (rr->uid_range_has) {
|
||||
if (rr->uid_range.end < rr->uid_range.start)
|
||||
NM_SWAP (rr->uid_range.start, rr->uid_range.end);
|
||||
NM_SWAP (&rr->uid_range.start, &rr->uid_range.end);
|
||||
if ( rr->uid_range.start == ((guint32) -1)
|
||||
|| rr->uid_range.end == ((guint32) -1))
|
||||
goto again_uid_range;
|
||||
|
@ -1265,7 +1265,7 @@ again_uid_range:
|
|||
range->start = nmtst_rand_select (1u, 0xFFFEu, ((p ) % 0xFFFEu) + 1);
|
||||
range->end = nmtst_rand_select (1u, 0xFFFEu, ((p >> 16) % 0xFFFEu) + 1, range->start);
|
||||
if (range->end < range->start)
|
||||
NM_SWAP (range->start, range->end);
|
||||
NM_SWAP (&range->start, &range->end);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -1032,7 +1032,7 @@ _test_connection_sort_autoconnect_priority_one (NMConnection **list, gboolean sh
|
|||
if (shuffle) {
|
||||
for (i = count - 1; i > 0; i--) {
|
||||
j = g_rand_int (nmtst_get_rand ()) % (i + 1);
|
||||
NM_SWAP (connections->pdata[i], connections->pdata[j]);
|
||||
NM_SWAP (&connections->pdata[i], &connections->pdata[j]);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -246,7 +246,7 @@ test_nm_ip6_config_addresses_sort_check (NMIP6Config *config, NMSettingIP6Config
|
|||
for (i = 0; i < addr_count; i++) {
|
||||
int j = g_rand_int_range (nmtst_get_rand (), i, addr_count);
|
||||
|
||||
NM_SWAP (idx[i], idx[j]);
|
||||
NM_SWAP (&idx[i], &idx[j]);
|
||||
nm_ip6_config_add_address (copy, _nmtst_ip6_config_get_address (config, idx[i]));
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in a new issue