]> git.ipfire.org Git - thirdparty/systemd.git/commitdiff
sd-device: use appropriate error code
authorYu Watanabe <watanabe.yu+github@gmail.com>
Thu, 18 Feb 2021 14:38:04 +0000 (23:38 +0900)
committerYu Watanabe <watanabe.yu+github@gmail.com>
Sat, 20 Feb 2021 19:40:23 +0000 (04:40 +0900)
src/libsystemd/sd-device/sd-device.c

index 8aa47f2fdd3bcbf0fc05676e8327e0556b6404a2..61cc79083a5388aea00ecc8255e7a2bb0e68eaa4 100644 (file)
@@ -1914,13 +1914,13 @@ _public_ int sd_device_get_sysattr_value(sd_device *device, const char *sysattr,
                                 return r;
                 } else
                         return -EINVAL;
-        } else if (S_ISDIR(statbuf.st_mode)) {
+        } else if (S_ISDIR(statbuf.st_mode))
                 /* skip directories */
-                return -EINVAL;
-        } else if (!(statbuf.st_mode & S_IRUSR)) {
+                return -EISDIR;
+        else if (!(statbuf.st_mode & S_IRUSR))
                 /* skip non-readable files */
                 return -EPERM;
-        else {
+        else {
                 /* read attribute value */
                 r = read_full_virtual_file(path, &value, NULL);
                 if (r < 0)