]> git.ipfire.org Git - thirdparty/systemd.git/commitdiff
tree-wide: avoid assignment of r just to use in a comparison
authorZbigniew Jędrzejewski-Szmek <zbyszek@in.waw.pl>
Tue, 24 Apr 2018 11:44:09 +0000 (13:44 +0200)
committerZbigniew Jędrzejewski-Szmek <zbyszek@in.waw.pl>
Tue, 24 Apr 2018 12:10:27 +0000 (14:10 +0200)
This changes
  r = ...;
  if (r < 0)
to
  if (... < 0)
when r will not be used again.

src/activate/activate.c
src/basic/capability-util.c
src/boot/bootctl.c
src/core/bpf-firewall.c
src/core/cgroup.c

index 7fd39b29da5fd38a1ab0b926cc84d291606ffe2f..eefea277208f8507f3a7cf21ef2c3deb5a408fc5 100644 (file)
@@ -35,16 +35,14 @@ static bool arg_inetd = false;
 
 static int add_epoll(int epoll_fd, int fd) {
         struct epoll_event ev = {
-                .events = EPOLLIN
+                .events = EPOLLIN,
+                .data.fd = fd,
         };
-        int r;
 
         assert(epoll_fd >= 0);
         assert(fd >= 0);
 
-        ev.data.fd = fd;
-        r = epoll_ctl(epoll_fd, EPOLL_CTL_ADD, fd, &ev);
-        if (r < 0)
+        if (epoll_ctl(epoll_fd, EPOLL_CTL_ADD, fd, &ev) < 0)
                 return log_error_errno(errno, "Failed to add event on epoll fd:%d for fd:%d: %m", epoll_fd, fd);
 
         return 0;
@@ -194,8 +192,7 @@ static int exec_process(const char* name, char **argv, char **env, int start_fd,
                 if (start_fd != SD_LISTEN_FDS_START) {
                         assert(n_fds == 1);
 
-                        r = dup2(start_fd, SD_LISTEN_FDS_START);
-                        if (r < 0)
+                        if (dup2(start_fd, SD_LISTEN_FDS_START) < 0)
                                 return log_error_errno(errno, "Failed to dup connection: %m");
 
                         safe_close(start_fd);
@@ -312,10 +309,7 @@ static int install_chld_handler(void) {
                 .sa_handler = sigchld_hdl,
         };
 
-        int r;
-
-        r = sigaction(SIGCHLD, &act, 0);
-        if (r < 0)
+        if (sigaction(SIGCHLD, &act, 0) < 0)
                 return log_error_errno(errno, "Failed to install SIGCHLD handler: %m");
 
         return 0;
@@ -490,8 +484,7 @@ int main(int argc, char **argv, char **envp) {
         for (;;) {
                 struct epoll_event event;
 
-                r = epoll_wait(epoll_fd, &event, 1, -1);
-                if (r < 0) {
+                if (epoll_wait(epoll_fd, &event, 1, -1) < 0) {
                         if (errno == EINTR)
                                 continue;
 
index 233d18a854aff3913ee84a0f37fdbde11a579f49..645cd322a7f6081caf99b595795450c909b7b6de 100644 (file)
@@ -301,8 +301,7 @@ int drop_privileges(uid_t uid, gid_t gid, uint64_t keep_capabilities) {
         if (prctl(PR_SET_KEEPCAPS, 1) < 0)
                 return log_error_errno(errno, "Failed to enable keep capabilities flag: %m");
 
-        r = setresuid(uid, uid, uid);
-        if (r < 0)
+        if (setresuid(uid, uid, uid) < 0)
                 return log_error_errno(errno, "Failed to change user ID: %m");
 
         if (prctl(PR_SET_KEEPCAPS, 0) < 0)
index 294d5922cf127728ea20695d53b44cf111efeb66..b9659d4860b7ea5787b8fc6e367910ab4871de74 100644 (file)
@@ -428,8 +428,7 @@ static int copy_file_with_version_check(const char *from, const char *to, bool f
 
         (void) fsync_directory_of_file(fd_to);
 
-        r = renameat(AT_FDCWD, t, AT_FDCWD, to);
-        if (r < 0) {
+        if (renameat(AT_FDCWD, t, AT_FDCWD, to) < 0) {
                 (void) unlink_noerrno(t);
                 return log_error_errno(errno, "Failed to rename \"%s\" to \"%s\": %m", t, to);
         }
index 7dc8467a7f815e2a1b1349ad6b39ea46efaebce2..22cd8e9158bdae0238ed97fc073f45d0a5ceb677 100644 (file)
@@ -728,8 +728,7 @@ int bpf_firewall_supported(void) {
                 .attach_bpf_fd = -1,
         };
 
-        r = bpf(BPF_PROG_ATTACH, &attr, sizeof(attr));
-        if (r < 0) {
+        if (bpf(BPF_PROG_ATTACH, &attr, sizeof(attr)) < 0) {
                 if (errno != EBADF) {
                         log_debug_errno(errno, "Didn't get EBADF from BPF_PROG_ATTACH, BPF firewalling is not supported: %m");
                         return supported = BPF_FIREWALL_UNSUPPORTED;
@@ -753,8 +752,7 @@ int bpf_firewall_supported(void) {
                 .attach_flags = BPF_F_ALLOW_MULTI,
         };
 
-        r = bpf(BPF_PROG_ATTACH, &attr, sizeof(attr));
-        if (r < 0) {
+        if (bpf(BPF_PROG_ATTACH, &attr, sizeof(attr)) < 0) {
                 if (errno == EBADF) {
                         log_debug_errno(errno, "Got EBADF when using BPF_F_ALLOW_MULTI, which indicates it is supported. Yay!");
                         return supported = BPF_FIREWALL_SUPPORTED_WITH_MULTI;
index 426732483efbd701aed54d5d72d480f1af5b0871..25778320ab51e2f419ff37363b4aed3006eb6a8a 100644 (file)
@@ -308,13 +308,11 @@ void cgroup_context_dump(CGroupContext *c, FILE* f, const char *prefix) {
 
 static int lookup_block_device(const char *p, dev_t *dev) {
         struct stat st;
-        int r;
 
         assert(p);
         assert(dev);
 
-        r = stat(p, &st);
-        if (r < 0)
+        if (stat(p, &st) < 0)
                 return log_warning_errno(errno, "Couldn't stat device %s: %m", p);
 
         if (S_ISBLK(st.st_mode))