]> git.ipfire.org Git - thirdparty/systemd.git/commitdiff
sd-device: shorten code a bit
authorYu Watanabe <watanabe.yu+github@gmail.com>
Tue, 8 Mar 2022 05:24:48 +0000 (14:24 +0900)
committerLennart Poettering <lennart@poettering.net>
Fri, 18 Mar 2022 08:57:24 +0000 (09:57 +0100)
src/libsystemd/sd-device/device-private.c

index 8eb7198808c443e00960fa799f633214f3df8f6a..c383833740e622ed87d822617f9b23854373f39d 100644 (file)
@@ -1029,18 +1029,9 @@ int device_update_db(sd_device *device) {
          * set 'sticky' bit to indicate that we should not clean the
          * database when we transition from initramfs to the real root
          */
-        if (device->db_persist) {
-                r = fchmod(fileno(f), 01644);
-                if (r < 0) {
-                        r = -errno;
-                        goto fail;
-                }
-        } else {
-                r = fchmod(fileno(f), 0644);
-                if (r < 0) {
-                        r = -errno;
-                        goto fail;
-                }
+        if (fchmod(fileno(f), device->db_persist ? 01644 : 0644) < 0) {
+                r = -errno;
+                goto fail;
         }
 
         if (has_info) {
@@ -1077,8 +1068,7 @@ int device_update_db(sd_device *device) {
         if (r < 0)
                 goto fail;
 
-        r = rename(path_tmp, path);
-        if (r < 0) {
+        if (rename(path_tmp, path) < 0) {
                 r = -errno;
                 goto fail;
         }