mirror of
https://github.com/systemd/systemd
synced 2024-09-06 16:56:43 +00:00
sd-id128: return -ENOMEDIUM on null id
We currently return -ENOMEDIUM when /etc/machine-id is empty, and -EINVAL when it is all zeros. But -EINVAL is also used for invalid args. The distinction between empty and all-zero is not very important, let's use the same return code. Also document -ENOENT and -ENOMEDIUM since they can be a bit surprising.
This commit is contained in:
parent
63e2ebcdaa
commit
ea03f6ba0d
|
@ -116,9 +116,11 @@
|
||||||
<refsect1>
|
<refsect1>
|
||||||
<title>Return Value</title>
|
<title>Return Value</title>
|
||||||
|
|
||||||
<para>The two calls return 0 on success (in which case
|
<para>Those calls return 0 on success (in which case <parameter>ret</parameter> is filled in),
|
||||||
<parameter>ret</parameter> is filled in), or a negative
|
or a negative errno-style error code. In particular, <function>sd_id128_get_machine()</function>
|
||||||
errno-style error code.</para>
|
and <function>sd_id128_get_machine_app_specific()</function> return <constant>-ENOENT</constant>
|
||||||
|
if <filename>/etc/machine-id</filename> is missing, and <constant>-ENOMEDIUM</constant> if is
|
||||||
|
empty or all zeros.</para>
|
||||||
</refsect1>
|
</refsect1>
|
||||||
|
|
||||||
<refsect1>
|
<refsect1>
|
||||||
|
|
|
@ -98,7 +98,7 @@ _public_ int sd_id128_get_machine(sd_id128_t *ret) {
|
||||||
return r;
|
return r;
|
||||||
|
|
||||||
if (sd_id128_is_null(saved_machine_id))
|
if (sd_id128_is_null(saved_machine_id))
|
||||||
return -EINVAL;
|
return -ENOMEDIUM;
|
||||||
}
|
}
|
||||||
|
|
||||||
*ret = saved_machine_id;
|
*ret = saved_machine_id;
|
||||||
|
|
Loading…
Reference in a new issue