sd-device: shorten code a bit

This commit is contained in:
Yu Watanabe
2022-03-18 09:57:24 +01:00
committed by Lennart Poettering
parent 29e6f70b8d
commit 827f865063
+4 -14
View 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;
}