mirror of
https://gitlab.freedesktop.org/NetworkManager/NetworkManager.git
synced 2026-05-05 16:58:02 +02:00
glib-aux: minor cleanup in nm_uuid_is_valid_nm()
This commit is contained in:
parent
1b7300ace9
commit
2d5489dcbb
1 changed files with 21 additions and 12 deletions
|
|
@ -181,22 +181,30 @@ nm_uuid_is_valid_nm(const char *str,
|
||||||
NMUuid uuid;
|
NMUuid uuid;
|
||||||
gboolean is_normalized;
|
gboolean is_normalized;
|
||||||
|
|
||||||
|
/* @out_normalized_str is only set, if normalization was necessary
|
||||||
|
* and possible. The caller cannot request @out_normalized_str, without
|
||||||
|
* also getting @out_normalized. */
|
||||||
|
nm_assert(!out_normalized_str || out_normalized);
|
||||||
|
|
||||||
if (!str)
|
if (!str)
|
||||||
return FALSE;
|
return FALSE;
|
||||||
|
|
||||||
if (nm_uuid_parse_full(str, &uuid, &is_normalized)) {
|
if (nm_uuid_parse_full(str, &uuid, &is_normalized)) {
|
||||||
if (is_normalized) {
|
/* Note that:
|
||||||
/* @str is a normalized (lower-case), valid UUID. Nothing to normalize,
|
* @is_normalized means that "str" contains a normalized UUID
|
||||||
* and return success. */
|
* @out_normalized: indicates whether str requires normalization
|
||||||
NM_SET_OUT(out_normalized, FALSE);
|
* and whether @out_normalized_str was set to contain the normalized
|
||||||
return TRUE;
|
* UUID.
|
||||||
|
* With this, we get the slightly odd assignment: */
|
||||||
|
NM_SET_OUT(out_normalized, !is_normalized);
|
||||||
|
|
||||||
|
if (!is_normalized && out_normalized_str) {
|
||||||
|
/* we need to normalize the UUID */
|
||||||
|
nm_uuid_unparse(&uuid, out_normalized_str);
|
||||||
}
|
}
|
||||||
|
|
||||||
/* @str is a valid UUID, but not normalized. That means that it's
|
/* regardless whether normalization was necessary, the UUID is
|
||||||
* upper case. Normalize the UUID. */
|
* essentially valid. */
|
||||||
NM_SET_OUT(out_normalized, TRUE);
|
|
||||||
if (out_normalized_str)
|
|
||||||
nm_uuid_unparse(&uuid, out_normalized_str);
|
|
||||||
return TRUE;
|
return TRUE;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -299,13 +307,14 @@ nm_uuid_generate_from_string(NMUuid * uuid,
|
||||||
case NM_UUID_TYPE_VERSION3:
|
case NM_UUID_TYPE_VERSION3:
|
||||||
case NM_UUID_TYPE_VERSION5:
|
case NM_UUID_TYPE_VERSION5:
|
||||||
{
|
{
|
||||||
NMUuid ns_uuid = {};
|
NMUuid ns_uuid;
|
||||||
|
|
||||||
if (type_args) {
|
if (type_args) {
|
||||||
/* type_args can be a name space UUID. Interpret it as (char *) */
|
/* type_args can be a name space UUID. Interpret it as (char *) */
|
||||||
if (!nm_uuid_parse(type_args, &ns_uuid))
|
if (!nm_uuid_parse(type_args, &ns_uuid))
|
||||||
g_return_val_if_reached(NULL);
|
g_return_val_if_reached(NULL);
|
||||||
}
|
} else
|
||||||
|
ns_uuid = (NMUuid){};
|
||||||
|
|
||||||
if (uuid_type == NM_UUID_TYPE_VERSION3) {
|
if (uuid_type == NM_UUID_TYPE_VERSION3) {
|
||||||
nm_crypto_md5_hash((guint8 *) s,
|
nm_crypto_md5_hash((guint8 *) s,
|
||||||
|
|
|
||||||
Loading…
Add table
Reference in a new issue