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:
Thomas Haller 2020-10-12 21:50:43 +02:00
parent dc54a946ac
commit cbcfc58794
No known key found for this signature in database
GPG key ID: 29C2366E4DFC5728
8 changed files with 39 additions and 40 deletions

View file

@ -524,10 +524,10 @@ _team_attr_data_cmp(const TeamAttrData *attr_data,
v_ptrarray_a = *((const GPtrArray *const *) val_a);
v_ptrarray_b = *((const GPtrArray *const *) val_b);
NM_CMP_RETURN(
_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_b ? (const char *const *) v_ptrarray_b->pdata : NULL,
v_ptrarray_b ? v_ptrarray_b->len : 0u));
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_b ? (const char *const *) v_ptrarray_b->pdata : NULL,
v_ptrarray_b ? v_ptrarray_b->len : 0u));
} else
nm_assert_not_reached();
return 0;
@ -1136,13 +1136,12 @@ _team_setting_value_master_runner_tx_hash_set_list(NMTeamSetting * self,
gboolean changed;
guint i;
if (_nm_utils_strv_cmp_n(self->d.master.runner_tx_hash
? (const char *const *) self->d.master.runner_tx_hash->pdata
: NULL,
self->d.master.runner_tx_hash ? self->d.master.runner_tx_hash->len
: 0u,
arr,
len)
if (nm_utils_strv_cmp_n(self->d.master.runner_tx_hash
? (const char *const *) self->d.master.runner_tx_hash->pdata
: NULL,
self->d.master.runner_tx_hash ? self->d.master.runner_tx_hash->len : 0u,
arr,
len)
== 0) {
changed = FALSE;
goto out;

View file

@ -330,7 +330,7 @@ _do_test_nm_utils_strsplit_set_f_one(NMUtilsStrsplitSetFlags flags,
}
g_assert(words_g[words_len] == NULL);
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(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];
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);
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;
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(strv2);
if (_nm_utils_strv_equal((char **) strv1, (char **) strv2))
if (nm_utils_strv_equal((char **) strv1, (char **) strv2))
return;
for (i = 0; strv1[i]; i++) {

View file

@ -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
* @len1: the length of @strv1, or -1 for NULL terminated 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).
**/
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;

View file

@ -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)
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
_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;
}
@ -1849,14 +1849,14 @@ nm_strv_ptrarray_contains(const GPtrArray *strv, const char *str)
static inline int
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
* and an array of length zero.
* 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),
nm_g_ptr_array_len(a),
(const char *const *) nm_g_ptr_array_pdata(b),
nm_g_ptr_array_len(b));
return nm_utils_strv_cmp_n((const char *const *) nm_g_ptr_array_pdata(a),
nm_g_ptr_array_len(a),
(const char *const *) nm_g_ptr_array_pdata(b),
nm_g_ptr_array_len(b));
}
/*****************************************************************************/

View file

@ -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((a2), _l2, &_a2_free_shallow, &_a2_free_deep, &_a2, &_a2x); \
\
_c1 = _nm_utils_strv_cmp_n(_a1, _l1, _a2, _l2); \
_c2 = _nm_utils_strv_cmp_n(_a2, _l2, _a1, _l1); \
_c1 = nm_utils_strv_cmp_n(_a1, _l1, _a2, _l2); \
_c2 = nm_utils_strv_cmp_n(_a2, _l2, _a1, _l1); \
if (equal) { \
g_assert_cmpint(_c1, ==, 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).
* 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(_a2, _l2, _a2x, _l2), ==, 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); \
\
_strv_cmp_free_deep(_a1_free_deep, _l1); \
_strv_cmp_free_deep(_a2_free_deep, _l2); \
@ -952,10 +952,10 @@ again:
else
g_assert(!data);
g_assert(_nm_utils_strv_cmp_n((const char *const *) strv->pdata,
strv->len,
(const char *const *) strv2->pdata,
strv2->len)
g_assert(nm_utils_strv_cmp_n((const char *const *) strv->pdata,
strv->len,
(const char *const *) strv2->pdata,
strv2->len)
== 0);
}
}
@ -1051,7 +1051,7 @@ test_strv_dup_packed(void)
g_assert(strv_cpy);
g_assert(NM_PTRARRAY_LEN(strv_cpy) == strv_len);
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));
}
}

View file

@ -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)
return;
if (_nm_utils_strv_equal((char **) cur_strv, (char **) new_strv))
if (nm_utils_strv_equal((char **) cur_strv, (char **) new_strv))
return;
for (i = 0; i < cur_len; i++)

View file

@ -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
* 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);
priv->groups = nm_utils_strv_dup_packed(peer_info->groups, -1);
changed |= TRUE;

View file

@ -1345,8 +1345,8 @@ global_dns_equal(NMGlobalDnsConfig *old, NMGlobalDnsConfig *new)
if (!old || !new)
return FALSE;
if (!_nm_utils_strv_equal(old->options, new->options)
|| !_nm_utils_strv_equal(old->searches, new->searches))
if (!nm_utils_strv_equal(old->options, new->options)
|| !nm_utils_strv_equal(old->searches, new->searches))
return FALSE;
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_new = value_new;
if (!_nm_utils_strv_equal(domain_old->options, domain_new->options)
|| !_nm_utils_strv_equal(domain_old->servers, domain_new->servers))
if (!nm_utils_strv_equal(domain_old->options, domain_new->options)
|| !nm_utils_strv_equal(domain_old->servers, domain_new->servers))
return FALSE;
}