libnm,glib-aux: move nm_utils_uuid_is_null() to "nm-uuid.h"

This commit is contained in:
Thomas Haller 2021-05-02 14:17:32 +02:00
parent 73b9883c6f
commit dd1a618745
No known key found for this signature in database
GPG key ID: 29C2366E4DFC5728
6 changed files with 24 additions and 22 deletions

View file

@ -2455,7 +2455,7 @@ again:
(guint8 *) &uuid,
sizeof(uuid),
NULL)) {
if (!nm_utils_uuid_is_null(&uuid)) {
if (!nm_uuid_is_null(&uuid)) {
/* an all-zero machine-id is not valid. */
is_fake = FALSE;
}

View file

@ -3043,21 +3043,6 @@ _nm_utils_sriov_vf_from_strparts(const char *index,
/*****************************************************************************/
gboolean
nm_utils_uuid_is_null(const NMUuid *uuid)
{
int i;
if (!uuid)
return TRUE;
for (i = 0; i < (int) G_N_ELEMENTS(uuid->uuid); i++) {
if (uuid->uuid[i])
return FALSE;
}
return TRUE;
}
/**
* nm_utils_uuid_generate_buf_:
* @buf: input buffer, must contain at least 37 bytes

View file

@ -7859,10 +7859,10 @@ test_nm_utils_uuid_generate_from_strings(void)
g_assert_cmpmem(&uuid0, sizeof(uuid0), _uuid("00000000-0000-0000-0000-000000000000"), 16);
g_assert(nm_utils_uuid_is_null(NULL));
g_assert(nm_utils_uuid_is_null(&uuid0));
g_assert(nm_utils_uuid_is_null(_uuid("00000000-0000-0000-0000-000000000000")));
g_assert(!nm_utils_uuid_is_null(_uuid("10000000-0000-0000-0000-000000000000")));
g_assert(nm_uuid_is_null(NULL));
g_assert(nm_uuid_is_null(&uuid0));
g_assert(nm_uuid_is_null(_uuid("00000000-0000-0000-0000-000000000000")));
g_assert(!nm_uuid_is_null(_uuid("10000000-0000-0000-0000-000000000000")));
_test_uuid("b07c334a-399b-32de-8d50-58e4e08f98e3", "", 0, NULL);
_test_uuid("b8a426cb-bcb5-30a3-bd8f-6786fea72df9", "\0", 1, "");

View file

@ -352,8 +352,6 @@ gboolean _nm_utils_check_module_file(const char * name,
/*****************************************************************************/
gboolean nm_utils_uuid_is_null(const NMUuid *uuid);
#define NM_UTILS_UUID_TYPE_LEGACY 0
#define NM_UTILS_UUID_TYPE_VERSION3 3
#define NM_UTILS_UUID_TYPE_VERSION5 5

View file

@ -125,3 +125,20 @@ nm_uuid_generate_random(NMUuid *out_uuid)
return out_uuid;
}
/*****************************************************************************/
gboolean
nm_uuid_is_null(const NMUuid *uuid)
{
int i;
if (!uuid)
return TRUE;
for (i = 0; i < (int) G_N_ELEMENTS(uuid->uuid); i++) {
if (uuid->uuid[i])
return FALSE;
}
return TRUE;
}

View file

@ -29,4 +29,6 @@ nm_uuid_parse(const char *str, NMUuid *out_uuid)
NMUuid *nm_uuid_generate_random(NMUuid *out_uuid);
gboolean nm_uuid_is_null(const NMUuid *uuid);
#endif /* __NM_UUID_H__ */