]> git.ipfire.org Git - thirdparty/systemd.git/commitdiff
Use "return log_error_errno" in more places"
authorZbigniew Jędrzejewski-Szmek <zbyszek@in.waw.pl>
Sat, 23 Jul 2016 00:27:45 +0000 (20:27 -0400)
committerZbigniew Jędrzejewski-Szmek <zbyszek@in.waw.pl>
Sat, 23 Jul 2016 01:25:09 +0000 (21:25 -0400)
src/coredump/coredump.c
src/fstab-generator/fstab-generator.c
src/gpt-auto-generator/gpt-auto-generator.c
src/login/logind-user.c
src/nspawn/nspawn-seccomp.c
src/nspawn/nspawn-setuid.c
src/shared/conf-parser.c
src/systemctl/systemctl.c
src/tmpfiles/tmpfiles.c

index e5719e67c3ac41ff3e6684867060bea793153a0a..043d785dd4efe6d34b2af53b961a99535422a9d2 100644 (file)
@@ -157,10 +157,8 @@ static int fix_acl(int fd, uid_t uid) {
 
         if (acl_create_entry(&acl, &entry) < 0 ||
             acl_set_tag_type(entry, ACL_USER) < 0 ||
-            acl_set_qualifier(entry, &uid) < 0) {
-                log_error_errno(errno, "Failed to patch ACL: %m");
-                return -errno;
-        }
+            acl_set_qualifier(entry, &uid) < 0)
+                return log_error_errno(errno, "Failed to patch ACL: %m");
 
         if (acl_get_permset(entry, &permset) < 0 ||
             acl_add_perm(permset, ACL_READ) < 0)
index 5aeca7e2d5678d7720dc22cd28aa187310ea70d0..33af553d0d5c8231b8e3ce4758f0bcb9a3e87ba2 100644 (file)
@@ -85,13 +85,12 @@ static int add_swap(
                 return log_oom();
 
         f = fopen(unit, "wxe");
-        if (!f) {
-                if (errno == EEXIST)
-                        log_error("Failed to create swap unit file %s, as it already exists. Duplicate entry in /etc/fstab?", unit);
-                else
-                        log_error_errno(errno, "Failed to create unit file %s: %m", unit);
-                return -errno;
-        }
+        if (!f)
+                return log_error_errno(errno,
+                                       errno == EEXIST ?
+                                       "Failed to create swap unit file %s, as it already exists. Duplicate entry in /etc/fstab?" :
+                                       "Failed to create unit file %s: %m",
+                                       unit);
 
         fprintf(f,
                 "# Automatically generated by systemd-fstab-generator\n\n"
@@ -281,13 +280,12 @@ static int add_mount(
                 return log_oom();
 
         f = fopen(unit, "wxe");
-        if (!f) {
-                if (errno == EEXIST)
-                        log_error("Failed to create mount unit file %s, as it already exists. Duplicate entry in /etc/fstab?", unit);
-                else
-                        log_error_errno(errno, "Failed to create unit file %s: %m", unit);
-                return -errno;
-        }
+        if (!f)
+                return log_error_errno(errno,
+                                       errno == EEXIST ?
+                                       "Failed to create mount unit file %s, as it already exists. Duplicate entry in /etc/fstab?" :
+                                       "Failed to create unit file %s: %m",
+                                       unit);
 
         fprintf(f,
                 "# Automatically generated by systemd-fstab-generator\n\n"
index a4938a7c3a63ab0fee6e7e55dd57b61dc498b656..39355de953464683c2e0f40c951c67b0b74a6944 100644 (file)
@@ -489,10 +489,8 @@ static int add_boot(const char *what) {
                 return 0;
         }
 
-        if (r < 0) {
-                log_error_errno(r, "Failed to read ESP partition UUID: %m");
-                return r;
-        }
+        if (r < 0)
+                return log_error_errno(r, "Failed to read ESP partition UUID: %m");
 
         errno = 0;
         b = blkid_new_probe_from_filename(what);
index f7d83909a0dc843676e5d99ff9460df1a1f7e5d8..348e3962927528f30799239049968afb1056abef 100644 (file)
@@ -311,8 +311,7 @@ int user_load(User *u) {
                 if (r == -ENOENT)
                         return 0;
 
-                log_error_errno(r, "Failed to read %s: %m", u->state_file);
-                return r;
+                return log_error_errno(r, "Failed to read %s: %m", u->state_file);
         }
 
         if (display)
index 54db1b47f8352be61479761fa15821bccffde9c1..3ab7160ebe9954fd545653c26fc6636c61181e08 100644 (file)
@@ -119,10 +119,8 @@ static int seccomp_add_default_syscall_filter(scmp_filter_ctx ctx,
                 r = seccomp_rule_add(ctx, SCMP_ACT_ERRNO(EPERM), blacklist[i].syscall_num, 0);
                 if (r == -EFAULT)
                         continue; /* unknown syscall */
-                if (r < 0) {
-                        log_error_errno(r, "Failed to block syscall: %m");
-                        return r;
-                }
+                if (r < 0)
+                        return log_error_errno(r, "Failed to block syscall: %m");
         }
 
         return 0;
index ee15a47e93e6afb24992d4f026691919f5388a6e..b8e8e091c8f2572c5e68dfe1b8a84b41f529ecca 100644 (file)
@@ -124,14 +124,12 @@ int change_uid_gid(const char *user, char **_home) {
         fd = -1;
 
         if (!fgets(line, sizeof(line), f)) {
-
                 if (!ferror(f)) {
                         log_error("Failed to resolve user %s.", user);
                         return -ESRCH;
                 }
 
-                log_error_errno(errno, "Failed to read from getent: %m");
-                return -errno;
+                return log_error_errno(errno, "Failed to read from getent: %m");
         }
 
         truncate_nl(line);
@@ -214,8 +212,7 @@ int change_uid_gid(const char *user, char **_home) {
                         return -ESRCH;
                 }
 
-                log_error_errno(errno, "Failed to read from getent: %m");
-                return -errno;
+                return log_error_errno(errno, "Failed to read from getent: %m");
         }
 
         truncate_nl(line);
index d85ab5441e1cc56662eabb7a1a7b5129384ff3f7..7cf222e4d2ff0c252d2aff6fd7e54e5429b1cf6c 100644 (file)
@@ -323,8 +323,7 @@ int config_parse(const char *unit,
                         if (feof(f))
                                 break;
 
-                        log_error_errno(errno, "Failed to read configuration file '%s': %m", filename);
-                        return -errno;
+                        return log_error_errno(errno, "Failed to read configuration file '%s': %m", filename);
                 }
 
                 l = buf;
index 92ba6aa4e4350950c4809050e313999667b5bdcd..5298fcfb9ca5f213c60ba017abe6d274646ac921 100644 (file)
@@ -5537,10 +5537,8 @@ static int enable_sysv_units(const char *verb, char **args) {
                 }
 
                 j = wait_for_terminate(pid, &status);
-                if (j < 0) {
-                        log_error_errno(j, "Failed to wait for child: %m");
-                        return j;
-                }
+                if (j < 0)
+                        return log_error_errno(j, "Failed to wait for child: %m");
 
                 if (status.si_code == CLD_EXITED) {
                         if (streq(verb, "is-enabled")) {
index bfb6293b3d9146a1a8cfe252d36e6f8e2935c21a..954f4aa98572518d9adb3cc38eae76da82fe3f38 100644 (file)
@@ -1575,13 +1575,12 @@ static int clean_item_instance(Item *i, const char* instance) {
 
         d = opendir_nomod(instance);
         if (!d) {
-                if (errno == ENOENT || errno == ENOTDIR) {
+                if (IN_SET(errno, ENOENT, ENOTDIR)) {
                         log_debug_errno(errno, "Directory \"%s\": %m", instance);
                         return 0;
                 }
 
-                log_error_errno(errno, "Failed to open directory %s: %m", instance);
-                return -errno;
+                return log_error_errno(errno, "Failed to open directory %s: %m", instance);
         }
 
         if (fstat(dirfd(d), &s) < 0)