]> git.ipfire.org Git - thirdparty/systemd.git/commitdiff
execute: make some code shorter
authorLennart Poettering <lennart@poettering.net>
Fri, 14 Jul 2017 16:58:57 +0000 (18:58 +0200)
committerLennart Poettering <lennart@poettering.net>
Mon, 31 Jul 2017 16:01:42 +0000 (18:01 +0200)
Let's simplify some lines to make it shorter.

src/core/execute.c

index f9580a25ad19089547edbae83de2e4486036387d..b76b9b9e6f75a1958902965c6566516c54c340b7 100644 (file)
@@ -278,7 +278,7 @@ static int open_null_as(int flags, int nfd) {
 }
 
 static int connect_journal_socket(int fd, uid_t uid, gid_t gid) {
-        union sockaddr_union sa = {
+        static const union sockaddr_union sa = {
                 .un.sun_family = AF_UNIX,
                 .un.sun_path = "/run/systemd/journal/stdout",
         };
@@ -289,24 +289,20 @@ static int connect_journal_socket(int fd, uid_t uid, gid_t gid) {
         if (gid_is_valid(gid)) {
                 oldgid = getgid();
 
-                r = setegid(gid);
-                if (r < 0)
+                if (setegid(gid) < 0)
                         return -errno;
         }
 
         if (uid_is_valid(uid)) {
                 olduid = getuid();
 
-                r = seteuid(uid);
-                if (r < 0) {
+                if (seteuid(uid) < 0) {
                         r = -errno;
                         goto restore_gid;
                 }
         }
 
-        r = connect(fd, &sa.sa, SOCKADDR_UN_LEN(sa.un));
-        if (r < 0)
-                r = -errno;
+        r = connect(fd, &sa.sa, SOCKADDR_UN_LEN(sa.un)) < 0 ? -errno : 0;
 
         /* If we fail to restore the uid or gid, things will likely
            fail later on. This should only happen if an LSM interferes. */