]> git.ipfire.org Git - thirdparty/systemd.git/commitdiff
sd-device: do not set errno needlessly
authorYu Watanabe <watanabe.yu+github@gmail.com>
Fri, 11 Jul 2025 03:04:28 +0000 (12:04 +0900)
committerYu Watanabe <watanabe.yu+github@gmail.com>
Fri, 11 Jul 2025 03:22:58 +0000 (12:22 +0900)
src/libsystemd/sd-device/sd-device.c

index 850eff9d028940eee3129266adbf530c59d0e119..8c6a1a091879f2034e863d05a0cb3e5a6b6673d6 100644 (file)
@@ -2219,17 +2219,12 @@ static int device_sysattrs_read_all(sd_device *device) {
 
 _public_ const char *sd_device_get_sysattr_first(sd_device *device) {
         void *v;
-        int r;
 
         assert_return(device, NULL);
 
-        if (!device->sysattrs_read) {
-                r = device_sysattrs_read_all(device);
-                if (r < 0) {
-                        errno = -r;
-                        return NULL;
-                }
-        }
+        if (!device->sysattrs_read &&
+            device_sysattrs_read_all(device) < 0)
+                return NULL;
 
         device->sysattrs_iterator = ITERATOR_FIRST;