]> git.ipfire.org Git - thirdparty/systemd.git/commitdiff
execute: shorten some code by using RET_NERRNO()
authorLennart Poettering <lennart@poettering.net>
Tue, 27 Jun 2023 09:19:12 +0000 (11:19 +0200)
committerLennart Poettering <lennart@poettering.net>
Wed, 28 Jun 2023 20:06:49 +0000 (22:06 +0200)
src/core/execute.c

index f19c144f3784038483881488006cc9808bb8f3ff..c3eeaa486b5a49d34cdf9eb6011214bd1177e9d8 100644 (file)
@@ -2625,10 +2625,9 @@ static int setup_exec_directory(
                                               "Apparently, service previously had DynamicUser= turned off, and has now turned it on.",
                                               exec_directory_type_to_string(type), p, pp);
 
-                                if (rename(p, pp) < 0) {
-                                        r = -errno;
+                                r = RET_NERRNO(rename(p, pp));
+                                if (r < 0)
                                         goto fail;
-                                }
                         } else {
                                 /* Otherwise, create the actual directory for the service */
 
@@ -2694,15 +2693,13 @@ static int setup_exec_directory(
                                                       "Apparently, service previously had DynamicUser= turned on, and has now turned it off.",
                                                       exec_directory_type_to_string(type), q, p);
 
-                                        if (unlink(p) < 0) {
-                                                r = -errno;
+                                        r = RET_NERRNO(unlink(p));
+                                        if (r < 0)
                                                 goto fail;
-                                        }
 
-                                        if (rename(q, p) < 0) {
-                                                r = -errno;
+                                        r = RET_NERRNO(rename(q, p));
+                                        if (r < 0)
                                                 goto fail;
-                                        }
                                 }
                         }
 
@@ -2718,10 +2715,9 @@ static int setup_exec_directory(
                                          * as in the common case it is not written to by a service, and shall
                                          * not be writable. */
 
-                                        if (stat(p, &st) < 0) {
-                                                r = -errno;
+                                        r = RET_NERRNO(stat(p, &st));
+                                        if (r < 0)
                                                 goto fail;
-                                        }
 
                                         /* Still complain if the access mode doesn't match */
                                         if (((st.st_mode ^ context->directories[type].mode) & 07777) != 0)