chiark / gitweb /
sd-device: fix return codes on error
[elogind.git] / src / libelogind / sd-device / sd-device.c
index 9ef851a6bbfcd6ed53839fbc3ecab28b548b3c17..97da4a8eea0d33a981439ed82f450e5377680b0c 100644 (file)
@@ -500,6 +500,8 @@ int device_read_uevent_file(sd_device *device) {
         if (device->uevent_loaded || device->sealed)
                 return 0;
 
+        device->uevent_loaded = true;
+
         r = sd_device_get_syspath(device, &syspath);
         if (r < 0)
                 return r;
@@ -570,8 +572,6 @@ int device_read_uevent_file(sd_device *device) {
                         log_debug("sd-device: could not set 'MAJOR=%s' or 'MINOR=%s' from '%s': %s", major, minor, path, strerror(-r));
         }
 
-        device->uevent_loaded = true;
-
         return 0;
 }
 
@@ -1193,12 +1193,12 @@ int device_get_id_filename(sd_device *device, const char **ret) {
                                      streq(subsystem, "block") ? 'b' : 'c',
                                      major(devnum), minor(devnum));
                         if (r < 0)
-                                return -errno;
+                                return -ENOMEM;
                 } else if (ifindex > 0) {
                         /* use netdev ifindex -- n3 */
                         r = asprintf(&id, "n%u", ifindex);
                         if (r < 0)
-                                return -errno;
+                                return -ENOMEM;
                 } else {
                         /* use $subsys:$sysname -- pci:0000:00:1f.2
                          * sysname() has '!' translated, get it from devpath
@@ -1211,7 +1211,7 @@ int device_get_id_filename(sd_device *device, const char **ret) {
 
                         r = asprintf(&id, "+%s:%s", subsystem, sysname);
                         if (r < 0)
-                                return -errno;
+                                return -ENOMEM;
                 }
 
                 device->id_filename = id;
@@ -1243,6 +1243,8 @@ int device_read_db_aux(sd_device *device, bool force) {
         if (device->db_loaded || (!force && device->sealed))
                 return 0;
 
+        device->db_loaded = true;
+
         r = device_get_id_filename(device, &id);
         if (r < 0)
                 return r;
@@ -1311,8 +1313,6 @@ int device_read_db_aux(sd_device *device, bool force) {
                 }
         }
 
-        device->db_loaded = true;
-
         return 0;
 }