all/trivial: rename _nm_utils_strv_equal()/_nm_utils_strv_cmp_n() to have no leading underscore
The underscore somehow indicated that these would be an internal function. Which they are in the sense that they are in "shared/nm-glib-aux/". But they part of our internal helper functions, and in our code base their use is no discouraged or "private. Also, next I'll replace the function call with a macro, so, I will have a need for the underscore name. Rename.
This commit is contained in:
@@ -524,7 +524,7 @@ _team_attr_data_cmp(const TeamAttrData *attr_data,
|
|||||||
v_ptrarray_a = *((const GPtrArray *const *) val_a);
|
v_ptrarray_a = *((const GPtrArray *const *) val_a);
|
||||||
v_ptrarray_b = *((const GPtrArray *const *) val_b);
|
v_ptrarray_b = *((const GPtrArray *const *) val_b);
|
||||||
NM_CMP_RETURN(
|
NM_CMP_RETURN(
|
||||||
_nm_utils_strv_cmp_n(v_ptrarray_a ? (const char *const *) v_ptrarray_a->pdata : NULL,
|
nm_utils_strv_cmp_n(v_ptrarray_a ? (const char *const *) v_ptrarray_a->pdata : NULL,
|
||||||
v_ptrarray_a ? v_ptrarray_a->len : 0u,
|
v_ptrarray_a ? v_ptrarray_a->len : 0u,
|
||||||
v_ptrarray_b ? (const char *const *) v_ptrarray_b->pdata : NULL,
|
v_ptrarray_b ? (const char *const *) v_ptrarray_b->pdata : NULL,
|
||||||
v_ptrarray_b ? v_ptrarray_b->len : 0u));
|
v_ptrarray_b ? v_ptrarray_b->len : 0u));
|
||||||
@@ -1136,11 +1136,10 @@ _team_setting_value_master_runner_tx_hash_set_list(NMTeamSetting * self,
|
|||||||
gboolean changed;
|
gboolean changed;
|
||||||
guint i;
|
guint i;
|
||||||
|
|
||||||
if (_nm_utils_strv_cmp_n(self->d.master.runner_tx_hash
|
if (nm_utils_strv_cmp_n(self->d.master.runner_tx_hash
|
||||||
? (const char *const *) self->d.master.runner_tx_hash->pdata
|
? (const char *const *) self->d.master.runner_tx_hash->pdata
|
||||||
: NULL,
|
: NULL,
|
||||||
self->d.master.runner_tx_hash ? self->d.master.runner_tx_hash->len
|
self->d.master.runner_tx_hash ? self->d.master.runner_tx_hash->len : 0u,
|
||||||
: 0u,
|
|
||||||
arr,
|
arr,
|
||||||
len)
|
len)
|
||||||
== 0) {
|
== 0) {
|
||||||
|
@@ -330,7 +330,7 @@ _do_test_nm_utils_strsplit_set_f_one(NMUtilsStrsplitSetFlags flags,
|
|||||||
}
|
}
|
||||||
g_assert(words_g[words_len] == NULL);
|
g_assert(words_g[words_len] == NULL);
|
||||||
g_assert_cmpint(NM_PTRARRAY_LEN(words_g), ==, words_len);
|
g_assert_cmpint(NM_PTRARRAY_LEN(words_g), ==, words_len);
|
||||||
g_assert(_nm_utils_strv_cmp_n(exp_words, words_len, NM_CAST_STRV_CC(words_g), -1) == 0);
|
g_assert(nm_utils_strv_cmp_n(exp_words, words_len, NM_CAST_STRV_CC(words_g), -1) == 0);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -354,7 +354,7 @@ _do_test_nm_utils_strsplit_set_f_one(NMUtilsStrsplitSetFlags flags,
|
|||||||
g_assert_cmpstr(exp_words[i], ==, words[i]);
|
g_assert_cmpstr(exp_words[i], ==, words[i]);
|
||||||
g_assert(words[words_len] == NULL);
|
g_assert(words[words_len] == NULL);
|
||||||
|
|
||||||
g_assert(_nm_utils_strv_cmp_n(exp_words, words_len, words, -1) == 0);
|
g_assert(nm_utils_strv_cmp_n(exp_words, words_len, words, -1) == 0);
|
||||||
|
|
||||||
s1 = words[0];
|
s1 = words[0];
|
||||||
g_assert(s1 >= (char *) &words[words_len + 1]);
|
g_assert(s1 >= (char *) &words[words_len + 1]);
|
||||||
@@ -515,7 +515,7 @@ _do_test_nm_utils_strsplit_set_simple(NMUtilsStrsplitSetFlags flags,
|
|||||||
g_assert_cmpint(words_len, >, 0);
|
g_assert_cmpint(words_len, >, 0);
|
||||||
n_tokens = NM_PTRARRAY_LEN(tokens);
|
n_tokens = NM_PTRARRAY_LEN(tokens);
|
||||||
|
|
||||||
if (_nm_utils_strv_cmp_n(exp_words, words_len, tokens, -1) != 0) {
|
if (nm_utils_strv_cmp_n(exp_words, words_len, tokens, -1) != 0) {
|
||||||
gsize i;
|
gsize i;
|
||||||
|
|
||||||
g_print(">>> split \"%s\" (flags %x) got %zu tokens (%zu expected)\n",
|
g_print(">>> split \"%s\" (flags %x) got %zu tokens (%zu expected)\n",
|
||||||
@@ -10058,7 +10058,7 @@ _strsplit_quoted_assert_strv(const char * topic,
|
|||||||
g_assert(strv1);
|
g_assert(strv1);
|
||||||
g_assert(strv2);
|
g_assert(strv2);
|
||||||
|
|
||||||
if (_nm_utils_strv_equal((char **) strv1, (char **) strv2))
|
if (nm_utils_strv_equal((char **) strv1, (char **) strv2))
|
||||||
return;
|
return;
|
||||||
|
|
||||||
for (i = 0; strv1[i]; i++) {
|
for (i = 0; strv1[i]; i++) {
|
||||||
|
@@ -3997,7 +3997,7 @@ _nm_utils_strv_sort(const char **strv, gssize len)
|
|||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* _nm_utils_strv_cmp_n:
|
* nm_utils_strv_cmp_n:
|
||||||
* @strv1: a string array
|
* @strv1: a string array
|
||||||
* @len1: the length of @strv1, or -1 for NULL terminated array.
|
* @len1: the length of @strv1, or -1 for NULL terminated array.
|
||||||
* @strv2: a string array
|
* @strv2: a string array
|
||||||
@@ -4020,7 +4020,7 @@ _nm_utils_strv_sort(const char **strv, gssize len)
|
|||||||
* Returns: 0 if the arrays are equal (using strcmp).
|
* Returns: 0 if the arrays are equal (using strcmp).
|
||||||
**/
|
**/
|
||||||
int
|
int
|
||||||
_nm_utils_strv_cmp_n(const char *const *strv1, gssize len1, const char *const *strv2, gssize len2)
|
nm_utils_strv_cmp_n(const char *const *strv1, gssize len1, const char *const *strv2, gssize len2)
|
||||||
{
|
{
|
||||||
gsize n, n2;
|
gsize n, n2;
|
||||||
|
|
||||||
|
@@ -1627,12 +1627,12 @@ void _nm_utils_strv_sort(const char **strv, gssize len);
|
|||||||
#define nm_utils_strv_sort(strv, len) _nm_utils_strv_sort(NM_CAST_STRV_MC(strv), len)
|
#define nm_utils_strv_sort(strv, len) _nm_utils_strv_sort(NM_CAST_STRV_MC(strv), len)
|
||||||
|
|
||||||
int
|
int
|
||||||
_nm_utils_strv_cmp_n(const char *const *strv1, gssize len1, const char *const *strv2, gssize len2);
|
nm_utils_strv_cmp_n(const char *const *strv1, gssize len1, const char *const *strv2, gssize len2);
|
||||||
|
|
||||||
static inline gboolean
|
static inline gboolean
|
||||||
_nm_utils_strv_equal(char **strv1, char **strv2)
|
nm_utils_strv_equal(char **strv1, char **strv2)
|
||||||
{
|
{
|
||||||
return _nm_utils_strv_cmp_n((const char *const *) strv1, -1, (const char *const *) strv2, -1)
|
return nm_utils_strv_cmp_n((const char *const *) strv1, -1, (const char *const *) strv2, -1)
|
||||||
== 0;
|
== 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -1849,11 +1849,11 @@ nm_strv_ptrarray_contains(const GPtrArray *strv, const char *str)
|
|||||||
static inline int
|
static inline int
|
||||||
nm_strv_ptrarray_cmp(const GPtrArray *a, const GPtrArray *b)
|
nm_strv_ptrarray_cmp(const GPtrArray *a, const GPtrArray *b)
|
||||||
{
|
{
|
||||||
/* _nm_utils_strv_cmp_n() will treat NULL and empty arrays the same.
|
/* nm_utils_strv_cmp_n() will treat NULL and empty arrays the same.
|
||||||
* That means, an empty strv array can both be represented by NULL
|
* That means, an empty strv array can both be represented by NULL
|
||||||
* and an array of length zero.
|
* and an array of length zero.
|
||||||
* If you need to distinguish between these case, do that yourself. */
|
* If you need to distinguish between these case, do that yourself. */
|
||||||
return _nm_utils_strv_cmp_n((const char *const *) nm_g_ptr_array_pdata(a),
|
return nm_utils_strv_cmp_n((const char *const *) nm_g_ptr_array_pdata(a),
|
||||||
nm_g_ptr_array_len(a),
|
nm_g_ptr_array_len(a),
|
||||||
(const char *const *) nm_g_ptr_array_pdata(b),
|
(const char *const *) nm_g_ptr_array_pdata(b),
|
||||||
nm_g_ptr_array_len(b));
|
nm_g_ptr_array_len(b));
|
||||||
|
@@ -364,8 +364,8 @@ test_strv_cmp(void)
|
|||||||
_strv_cmp_fuzz_input((a1), _l1, &_a1_free_shallow, &_a1_free_deep, &_a1, &_a1x); \
|
_strv_cmp_fuzz_input((a1), _l1, &_a1_free_shallow, &_a1_free_deep, &_a1, &_a1x); \
|
||||||
_strv_cmp_fuzz_input((a2), _l2, &_a2_free_shallow, &_a2_free_deep, &_a2, &_a2x); \
|
_strv_cmp_fuzz_input((a2), _l2, &_a2_free_shallow, &_a2_free_deep, &_a2, &_a2x); \
|
||||||
\
|
\
|
||||||
_c1 = _nm_utils_strv_cmp_n(_a1, _l1, _a2, _l2); \
|
_c1 = nm_utils_strv_cmp_n(_a1, _l1, _a2, _l2); \
|
||||||
_c2 = _nm_utils_strv_cmp_n(_a2, _l2, _a1, _l1); \
|
_c2 = nm_utils_strv_cmp_n(_a2, _l2, _a1, _l1); \
|
||||||
if (equal) { \
|
if (equal) { \
|
||||||
g_assert_cmpint(_c1, ==, 0); \
|
g_assert_cmpint(_c1, ==, 0); \
|
||||||
g_assert_cmpint(_c2, ==, 0); \
|
g_assert_cmpint(_c2, ==, 0); \
|
||||||
@@ -376,8 +376,8 @@ test_strv_cmp(void)
|
|||||||
\
|
\
|
||||||
/* Compare with self. _strv_cmp_fuzz_input() randomly swapped the arguments (_a1 and _a1x).
|
/* Compare with self. _strv_cmp_fuzz_input() randomly swapped the arguments (_a1 and _a1x).
|
||||||
* Either way, the arrays must compare equal to their semantically equal alternative. */ \
|
* Either way, the arrays must compare equal to their semantically equal alternative. */ \
|
||||||
g_assert_cmpint(_nm_utils_strv_cmp_n(_a1, _l1, _a1x, _l1), ==, 0); \
|
g_assert_cmpint(nm_utils_strv_cmp_n(_a1, _l1, _a1x, _l1), ==, 0); \
|
||||||
g_assert_cmpint(_nm_utils_strv_cmp_n(_a2, _l2, _a2x, _l2), ==, 0); \
|
g_assert_cmpint(nm_utils_strv_cmp_n(_a2, _l2, _a2x, _l2), ==, 0); \
|
||||||
\
|
\
|
||||||
_strv_cmp_free_deep(_a1_free_deep, _l1); \
|
_strv_cmp_free_deep(_a1_free_deep, _l1); \
|
||||||
_strv_cmp_free_deep(_a2_free_deep, _l2); \
|
_strv_cmp_free_deep(_a2_free_deep, _l2); \
|
||||||
@@ -952,7 +952,7 @@ again:
|
|||||||
else
|
else
|
||||||
g_assert(!data);
|
g_assert(!data);
|
||||||
|
|
||||||
g_assert(_nm_utils_strv_cmp_n((const char *const *) strv->pdata,
|
g_assert(nm_utils_strv_cmp_n((const char *const *) strv->pdata,
|
||||||
strv->len,
|
strv->len,
|
||||||
(const char *const *) strv2->pdata,
|
(const char *const *) strv2->pdata,
|
||||||
strv2->len)
|
strv2->len)
|
||||||
@@ -1051,7 +1051,7 @@ test_strv_dup_packed(void)
|
|||||||
g_assert(strv_cpy);
|
g_assert(strv_cpy);
|
||||||
g_assert(NM_PTRARRAY_LEN(strv_cpy) == strv_len);
|
g_assert(NM_PTRARRAY_LEN(strv_cpy) == strv_len);
|
||||||
if (strv_cpy)
|
if (strv_cpy)
|
||||||
g_assert(_nm_utils_strv_equal((char **) strv_cpy, (char **) strv_src));
|
g_assert(nm_utils_strv_equal((char **) strv_cpy, (char **) strv_src));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@@ -264,7 +264,7 @@ set_arp_targets(NMDevice *device, const char *cur_arp_ip_target, const char *new
|
|||||||
if (cur_len == 0 && new_len == 0)
|
if (cur_len == 0 && new_len == 0)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
if (_nm_utils_strv_equal((char **) cur_strv, (char **) new_strv))
|
if (nm_utils_strv_equal((char **) cur_strv, (char **) new_strv))
|
||||||
return;
|
return;
|
||||||
|
|
||||||
for (i = 0; i < cur_len; i++)
|
for (i = 0; i < cur_len; i++)
|
||||||
|
@@ -407,7 +407,7 @@ nm_wifi_p2p_peer_update_from_properties(NMWifiP2PPeer *peer, const NMSupplicantP
|
|||||||
|
|
||||||
/* We currently only use the groups information internally to check if
|
/* We currently only use the groups information internally to check if
|
||||||
* the peer is still joined. */
|
* the peer is still joined. */
|
||||||
if (!_nm_utils_strv_equal((char **) priv->groups, (char **) peer_info->groups)) {
|
if (!nm_utils_strv_equal((char **) priv->groups, (char **) peer_info->groups)) {
|
||||||
g_free(priv->groups);
|
g_free(priv->groups);
|
||||||
priv->groups = nm_utils_strv_dup_packed(peer_info->groups, -1);
|
priv->groups = nm_utils_strv_dup_packed(peer_info->groups, -1);
|
||||||
changed |= TRUE;
|
changed |= TRUE;
|
||||||
|
@@ -1345,8 +1345,8 @@ global_dns_equal(NMGlobalDnsConfig *old, NMGlobalDnsConfig *new)
|
|||||||
if (!old || !new)
|
if (!old || !new)
|
||||||
return FALSE;
|
return FALSE;
|
||||||
|
|
||||||
if (!_nm_utils_strv_equal(old->options, new->options)
|
if (!nm_utils_strv_equal(old->options, new->options)
|
||||||
|| !_nm_utils_strv_equal(old->searches, new->searches))
|
|| !nm_utils_strv_equal(old->searches, new->searches))
|
||||||
return FALSE;
|
return FALSE;
|
||||||
|
|
||||||
if ((!old->domains || !new->domains) && old->domains != new->domains)
|
if ((!old->domains || !new->domains) && old->domains != new->domains)
|
||||||
@@ -1364,8 +1364,8 @@ global_dns_equal(NMGlobalDnsConfig *old, NMGlobalDnsConfig *new)
|
|||||||
domain_old = value_old;
|
domain_old = value_old;
|
||||||
domain_new = value_new;
|
domain_new = value_new;
|
||||||
|
|
||||||
if (!_nm_utils_strv_equal(domain_old->options, domain_new->options)
|
if (!nm_utils_strv_equal(domain_old->options, domain_new->options)
|
||||||
|| !_nm_utils_strv_equal(domain_old->servers, domain_new->servers))
|
|| !nm_utils_strv_equal(domain_old->servers, domain_new->servers))
|
||||||
return FALSE;
|
return FALSE;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Reference in New Issue
Block a user