summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorThomas Haller <thaller@redhat.com>2019-05-21 18:13:53 +0200
committerThomas Haller <thaller@redhat.com>2019-06-13 16:10:53 +0200
commitc165c6a671f03a2e48549f247435d953710ce7dc (patch)
treefb1f75bb01be1b1399c1155662fafaf18611439e
parentb1f5e971f3c81a56c781004a43efdd77f635b696 (diff)
downloadNetworkManager-c165c6a671f03a2e48549f247435d953710ce7dc.tar.gz
libnm: don't assert against %NULL string in nm_utils_is_uuid()
For a "is" check, it's inconvenient to assert against the parameter being %NULL. We should accept %NULL and just say that it's not a valid uuid. This relaxes previous API.
-rw-r--r--libnm-core/nm-utils.c8
1 files changed, 6 insertions, 2 deletions
diff --git a/libnm-core/nm-utils.c b/libnm-core/nm-utils.c
index 5322a8d747..dc0b5b814e 100644
--- a/libnm-core/nm-utils.c
+++ b/libnm-core/nm-utils.c
@@ -4713,11 +4713,14 @@ nm_utils_iface_valid_name (const char *name)
/**
* nm_utils_is_uuid:
- * @str: a string that might be a UUID
+ * @str: (allow-none): a string that might be a UUID
*
* Checks if @str is a UUID
*
* Returns: %TRUE if @str is a UUID, %FALSE if not
+ *
+ * In older versions, nm_utils_is_uuid() did not accept %NULL as @str
+ * argument. Don't pass %NULL if you run against older versions of libnm.
*/
gboolean
nm_utils_is_uuid (const char *str)
@@ -4725,7 +4728,8 @@ nm_utils_is_uuid (const char *str)
const char *p = str;
int num_dashes = 0;
- g_return_val_if_fail (str, FALSE);
+ if (!p)
+ return FALSE;
while (*p) {
if (*p == '-')