From: Zbigniew Jędrzejewski-Szmek Date: Wed, 16 May 2018 11:55:12 +0000 (+0200) Subject: sd-id128: return -ENOMEDIUM on null id X-Git-Tag: v239~172^2~24 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=ea03f6ba0d66374594d716fc0e84e4d65906d2c3;p=thirdparty%2Fsystemd.git 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. --- diff --git a/man/sd_id128_get_machine.xml b/man/sd_id128_get_machine.xml index 3622bbd9f2c..827756d135d 100644 --- a/man/sd_id128_get_machine.xml +++ b/man/sd_id128_get_machine.xml @@ -116,9 +116,11 @@ Return Value - The two calls return 0 on success (in which case - ret is filled in), or a negative - errno-style error code. + Those calls return 0 on success (in which case ret is filled in), + or a negative errno-style error code. In particular, sd_id128_get_machine() + and sd_id128_get_machine_app_specific() return -ENOENT + if /etc/machine-id is missing, and -ENOMEDIUM if is + empty or all zeros. diff --git a/src/libsystemd/sd-id128/sd-id128.c b/src/libsystemd/sd-id128/sd-id128.c index af2ff8353ab..80548fdfcf9 100644 --- a/src/libsystemd/sd-id128/sd-id128.c +++ b/src/libsystemd/sd-id128/sd-id128.c @@ -98,7 +98,7 @@ _public_ int sd_id128_get_machine(sd_id128_t *ret) { return r; if (sd_id128_is_null(saved_machine_id)) - return -EINVAL; + return -ENOMEDIUM; } *ret = saved_machine_id;