summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--man/sd_id128_to_string.xml12
-rw-r--r--src/libsystemd/sd-id128/sd-id128.c4
2 files changed, 7 insertions, 9 deletions
diff --git a/man/sd_id128_to_string.xml b/man/sd_id128_to_string.xml
index e70c80892e..927d1ad5f2 100644
--- a/man/sd_id128_to_string.xml
+++ b/man/sd_id128_to_string.xml
@@ -74,13 +74,11 @@
lowercase hexadecimal digits and be terminated by a
<constant>NUL</constant> byte.</para>
- <para><function>sd_id128_from_string()</function> implements the
- reverse operation: it takes a 33 character string with 32
- hexadecimal digits (either lowercase or uppercase, terminated by
- <constant>NUL</constant>) and parses them back into a 128-bit ID
- returned in <parameter>ret</parameter>. Alternatively, this call
- can also parse a 37-character string with a 128-bit ID formatted
- as RFC UUID.</para>
+ <para><function>sd_id128_from_string()</function> implements the reverse operation: it takes a 33 character string
+ with 32 hexadecimal digits (either lowercase or uppercase, terminated by <constant>NUL</constant>) and parses them
+ back into a 128-bit ID returned in <parameter>ret</parameter>. Alternatively, this call can also parse a
+ 37-character string with a 128-bit ID formatted as RFC UUID. If <parameter>ret</parameter> is passed as NULL the
+ function will validate the passed ID string, but not actually return it in parsed form.</para>
<para>For more information about the <literal>sd_id128_t</literal>
type see
diff --git a/src/libsystemd/sd-id128/sd-id128.c b/src/libsystemd/sd-id128/sd-id128.c
index 1470e4c01a..9f47d04e61 100644
--- a/src/libsystemd/sd-id128/sd-id128.c
+++ b/src/libsystemd/sd-id128/sd-id128.c
@@ -52,7 +52,6 @@ _public_ int sd_id128_from_string(const char s[], sd_id128_t *ret) {
bool is_guid = false;
assert_return(s, -EINVAL);
- assert_return(ret, -EINVAL);
for (n = 0, i = 0; n < 16;) {
int a, b;
@@ -90,7 +89,8 @@ _public_ int sd_id128_from_string(const char s[], sd_id128_t *ret) {
if (s[i] != 0)
return -EINVAL;
- *ret = t;
+ if (ret)
+ *ret = t;
return 0;
}