]> git.ipfire.org Git - thirdparty/systemd.git/commitdiff
Merge pull request #1210 from poettering/import-fixes
authorDaniel Mack <github@zonque.org>
Wed, 9 Sep 2015 08:08:44 +0000 (10:08 +0200)
committerDaniel Mack <github@zonque.org>
Wed, 9 Sep 2015 08:08:44 +0000 (10:08 +0200)
cgroup fix, nspawn fix, plus change to download .nspawn files in importd

86 files changed:
coccinelle/empty-if.cocci [new file with mode: 0644]
coccinelle/errno.cocci [new file with mode: 0644]
coccinelle/mfree.cocci [new file with mode: 0644]
coccinelle/no-if-assignments.cocci [new file with mode: 0644]
coccinelle/safe_close-no-if.cocci [new file with mode: 0644]
coccinelle/safe_close.cocci [new file with mode: 0644]
src/analyze/analyze.c
src/ask-password/ask-password.c
src/basic/bitmap.c
src/basic/fdset.c
src/basic/lockfile-util.c
src/basic/strv.c
src/bootchart/bootchart.c
src/bootchart/svg.c
src/core/automount.c
src/core/busname.c
src/core/dbus-execute.c
src/core/device.c
src/core/execute.c
src/core/load-fragment.c
src/core/main.c
src/core/manager.c
src/core/mount.c
src/core/namespace.c
src/core/scope.c
src/core/service.c
src/core/shutdown.c
src/core/socket.c
src/core/swap.c
src/core/transaction.c
src/cryptsetup/cryptsetup.c
src/gpt-auto-generator/gpt-auto-generator.c
src/hostname/hostnamed.c
src/import/export-tar.c
src/import/import-raw.c
src/import/import-tar.c
src/import/importd.c
src/import/pull-dkr.c
src/initctl/initctl.c
src/journal-remote/journal-gatewayd.c
src/journal-remote/journal-remote-write.c
src/journal-remote/journal-remote.c
src/journal-remote/journal-upload-journal.c
src/journal/cat.c
src/journal/coredumpctl.c
src/journal/journal-verify.c
src/journal/journalctl.c
src/journal/journald-audit.c
src/journal/test-journal-verify.c
src/libsystemd-network/sd-ipv4ll.c
src/libsystemd/sd-bus/bus-creds.c
src/libsystemd/sd-bus/bus-message.c
src/libsystemd/sd-bus/busctl-introspect.c
src/libsystemd/sd-bus/sd-bus.c
src/libsystemd/sd-netlink/netlink-message.c
src/libudev/libudev-list.c
src/login/logind-button.c
src/login/logind-dbus.c
src/login/logind-inhibit.c
src/login/logind-session.c
src/login/logind-user.c
src/machine/machine.c
src/machine/machinectl.c
src/network/networkd-netdev-bond.c
src/network/networkd-netdev-tuntap.c
src/network/networkd-wait-online-link.c
src/random-seed/random-seed.c
src/resolve-host/resolve-host.c
src/resolve/resolved-dns-cache.c
src/resolve/resolved-manager.c
src/shared/ask-password-api.c
src/shared/bus-util.c
src/shared/conf-parser.c
src/shared/logs-show.c
src/shared/pager.c
src/systemctl/systemctl.c
src/test/test-loopback.c
src/udev/net/ethtool-util.c
src/udev/scsi_id/scsi_serial.c
src/udev/udev-builtin-path_id.c
src/udev/udev-ctrl.c
src/udev/udev-event.c
src/udev/udev-rules.c
src/udev/udevd.c
src/update-utmp/update-utmp.c
src/user-sessions/user-sessions.c

diff --git a/coccinelle/empty-if.cocci b/coccinelle/empty-if.cocci
new file mode 100644 (file)
index 0000000..ebd0bfd
--- /dev/null
@@ -0,0 +1,19 @@
+@@
+expression e, f;
+statement s, t;
+@@
+(
+if (e) {
+if (f) s
+}
+|
+if (e) {
+if (f) s
+else t
+}
+|
+- if (e) {
++ if (e)
+s
+- }
+)
diff --git a/coccinelle/errno.cocci b/coccinelle/errno.cocci
new file mode 100644 (file)
index 0000000..073d905
--- /dev/null
@@ -0,0 +1,42 @@
+@@
+identifier r;
+expression t, e;
+@@
+- r = -e;
+- log_error_errno(e, t);
++ r = log_error_errno(e, t);
+@@
+identifier r;
+expression t, e;
+@@
+- log_error_errno(e, t);
+- r = -e;
++ r = log_error_errno(e, t);
+@@
+identifier r;
+expression t, e;
+@@
+- r = log_error_errno(e, t);
+- return r;
++ return log_error_errno(e, t);
+@@
+identifier r;
+expression t, e;
+@@
+- r = -e;
+- log_warning_errno(e, t);
++ r = log_warning_errno(e, t);
+@@
+identifier r;
+expression t, e;
+@@
+- log_warning_errno(e, t);
+- r = -e;
++ r = log_warning_errno(e, t);
+@@
+identifier r;
+expression t, e;
+@@
+- r = log_warning_errno(e, t);
+- return r;
++ return log_warning_errno(e, t);
diff --git a/coccinelle/mfree.cocci b/coccinelle/mfree.cocci
new file mode 100644 (file)
index 0000000..1389cd3
--- /dev/null
@@ -0,0 +1,6 @@
+@@
+expression p;
+@@
+- free(p);
+- p = NULL;
++ p = mfree(p);
diff --git a/coccinelle/no-if-assignments.cocci b/coccinelle/no-if-assignments.cocci
new file mode 100644 (file)
index 0000000..9f63e90
--- /dev/null
@@ -0,0 +1,20 @@
+@@
+expression p, q;
+identifier r;
+statement s;
+@@
+- if ((r = q) < p)
+- s
++ r = q;
++ if (r < p)
++ s
+@@
+expression p, q;
+identifier r;
+statement s;
+@@
+- if ((r = q) >= p)
+- s
++ r = q;
++ if (r >= p)
++ s
diff --git a/coccinelle/safe_close-no-if.cocci b/coccinelle/safe_close-no-if.cocci
new file mode 100644 (file)
index 0000000..81c5678
--- /dev/null
@@ -0,0 +1,7 @@
+@@
+expression fd;
+@@
+- if (fd >= 0) {
+- fd = safe_close(fd);
+- }
++ fd = safe_close(fd);
diff --git a/coccinelle/safe_close.cocci b/coccinelle/safe_close.cocci
new file mode 100644 (file)
index 0000000..6fedd80
--- /dev/null
@@ -0,0 +1,18 @@
+@@
+expression fd;
+@@
+- close(fd);
+- fd = -1;
++ fd = safe_close(fd);
+@@
+expression fd;
+@@
+- close_nointr(fd);
+- fd = -1;
++ fd = safe_close(fd);
+@@
+expression fd;
+@@
+- safe_close(fd);
+- fd = -1;
++ fd = safe_close(fd);
index ab7fb53269c8ac9ae25ac622e4f1bcd73e4d4c7a..d1ff156d12a55018ba5b8b2dfbd6195f064d862d 100644 (file)
@@ -582,8 +582,7 @@ static int analyze_plot(sd_bus *bus) {
 
                 if (u->activating < boot->userspace_time ||
                     u->activating > boot->finish_time) {
-                        free(u->name);
-                        u->name = NULL;
+                        u->name = mfree(u->name);
                         continue;
                 }
 
@@ -845,11 +844,8 @@ static int list_dependencies_one(sd_bus *bus, const char *name, unsigned int lev
 
         STRV_FOREACH(c, deps) {
                 times = hashmap_get(unit_times_hashmap, *c);
-                if (times && times->activated
-                    && times->activated <= boot->finish_time
-                    && (service_longest - times->activated) <= arg_fuzz) {
+                if (times && times->activated && times->activated <= boot->finish_time && (service_longest - times->activated) <= arg_fuzz)
                         to_print++;
-                }
         }
 
         if (!to_print)
@@ -1016,7 +1012,7 @@ static int analyze_time(sd_bus *bus) {
         return 0;
 }
 
-static int graph_one_property(sd_bus *bus, const UnitInfo *u, const char* prop, const char *color, char* patterns[]) {
+static int graph_one_property(sd_bus *bus, const UnitInfo *u, const char* prop, const char *color, char* patterns[], char* from_patterns[], char* to_patterns[]) {
         _cleanup_strv_free_ char **units = NULL;
         char **unit;
         int r;
@@ -1028,9 +1024,9 @@ static int graph_one_property(sd_bus *bus, const UnitInfo *u, const char* prop,
 
         match_patterns = strv_fnmatch(patterns, u->id, 0);
 
-        if (!strv_isempty(arg_dot_from_patterns) &&
+        if (!strv_isempty(from_patterns) &&
             !match_patterns &&
-            !strv_fnmatch(arg_dot_from_patterns, u->id, 0))
+            !strv_fnmatch(from_patterns, u->id, 0))
                         return 0;
 
         r = bus_get_unit_property_strv(bus, u->unit_path, prop, &units);
@@ -1042,9 +1038,9 @@ static int graph_one_property(sd_bus *bus, const UnitInfo *u, const char* prop,
 
                 match_patterns2 = strv_fnmatch(patterns, *unit, 0);
 
-                if (!strv_isempty(arg_dot_to_patterns) &&
+                if (!strv_isempty(to_patterns) &&
                     !match_patterns2 &&
-                    !strv_fnmatch(arg_dot_to_patterns, *unit, 0))
+                    !strv_fnmatch(to_patterns, *unit, 0))
                         continue;
 
                 if (!strv_isempty(patterns) && !match_patterns && !match_patterns2)
@@ -1056,35 +1052,35 @@ static int graph_one_property(sd_bus *bus, const UnitInfo *u, const char* prop,
         return 0;
 }
 
-static int graph_one(sd_bus *bus, const UnitInfo *u, char *patterns[]) {
+static int graph_one(sd_bus *bus, const UnitInfo *u, char *patterns[], char *from_patterns[], char *to_patterns[]) {
         int r;
 
         assert(bus);
         assert(u);
 
         if (arg_dot == DEP_ORDER ||arg_dot == DEP_ALL) {
-                r = graph_one_property(bus, u, "After", "green", patterns);
+                r = graph_one_property(bus, u, "After", "green", patterns, from_patterns, to_patterns);
                 if (r < 0)
                         return r;
         }
 
         if (arg_dot == DEP_REQUIRE ||arg_dot == DEP_ALL) {
-                r = graph_one_property(bus, u, "Requires", "black", patterns);
+                r = graph_one_property(bus, u, "Requires", "black", patterns, from_patterns, to_patterns);
                 if (r < 0)
                         return r;
-                r = graph_one_property(bus, u, "RequiresOverridable", "black", patterns);
+                r = graph_one_property(bus, u, "RequiresOverridable", "black", patterns, from_patterns, to_patterns);
                 if (r < 0)
                         return r;
-                r = graph_one_property(bus, u, "RequisiteOverridable", "darkblue", patterns);
+                r = graph_one_property(bus, u, "RequisiteOverridable", "darkblue", patterns, from_patterns, to_patterns);
                 if (r < 0)
                         return r;
-                r = graph_one_property(bus, u, "Wants", "grey66", patterns);
+                r = graph_one_property(bus, u, "Wants", "grey66", patterns, from_patterns, to_patterns);
                 if (r < 0)
                         return r;
-                r = graph_one_property(bus, u, "Conflicts", "red", patterns);
+                r = graph_one_property(bus, u, "Conflicts", "red", patterns, from_patterns, to_patterns);
                 if (r < 0)
                         return r;
-                r = graph_one_property(bus, u, "ConflictedBy", "red", patterns);
+                r = graph_one_property(bus, u, "ConflictedBy", "red", patterns, from_patterns, to_patterns);
                 if (r < 0)
                         return r;
         }
@@ -1138,6 +1134,8 @@ static int dot(sd_bus *bus, char* patterns[]) {
         _cleanup_bus_message_unref_ sd_bus_message *reply = NULL;
         _cleanup_bus_error_free_ sd_bus_error error = SD_BUS_ERROR_NULL;
         _cleanup_strv_free_ char **expanded_patterns = NULL;
+        _cleanup_strv_free_ char **expanded_from_patterns = NULL;
+        _cleanup_strv_free_ char **expanded_to_patterns = NULL;
         int r;
         UnitInfo u;
 
@@ -1145,6 +1143,14 @@ static int dot(sd_bus *bus, char* patterns[]) {
         if (r < 0)
                 return r;
 
+        r = expand_patterns(bus, arg_dot_from_patterns, &expanded_from_patterns);
+        if (r < 0)
+                return r;
+
+        r = expand_patterns(bus, arg_dot_to_patterns, &expanded_to_patterns);
+        if (r < 0)
+                return r;
+
         r = sd_bus_call_method(
                         bus,
                        "org.freedesktop.systemd1",
@@ -1167,7 +1173,7 @@ static int dot(sd_bus *bus, char* patterns[]) {
 
         while ((r = bus_parse_unit_info(reply, &u)) > 0) {
 
-                r = graph_one(bus, &u, expanded_patterns);
+                r = graph_one(bus, &u, expanded_patterns, expanded_from_patterns, expanded_to_patterns);
                 if (r < 0)
                         return r;
         }
index 2cbed293ba65a9ff1dbc69e96f345b1550522ae6..abfd545c791e0bc10bcbd698cbdc8812b2a8997e 100644 (file)
@@ -156,7 +156,9 @@ int main(int argc, char *argv[]) {
         if (arg_use_tty && isatty(STDIN_FILENO)) {
                 char *password = NULL;
 
-                if ((r = ask_password_tty(arg_message, timeout, arg_echo, NULL, &password)) >= 0) {
+                r = ask_password_tty(arg_message, timeout, arg_echo, NULL,
+                                     &password);
+                if (r >= 0) {
                         puts(password);
                         free(password);
                 }
@@ -164,7 +166,9 @@ int main(int argc, char *argv[]) {
         } else {
                 char **l;
 
-                if ((r = ask_password_agent(arg_message, arg_icon, arg_id, timeout, arg_echo, arg_accept_cached, &l)) >= 0) {
+                r = ask_password_agent(arg_message, arg_icon, arg_id, timeout,
+                                       arg_echo, arg_accept_cached, &l);
+                if (r >= 0) {
                         char **p;
 
                         STRV_FOREACH(p, l) {
index 7ea3357031b75ba1e2c03649ea531f282b0d9ae3..2eabf3e1c1bbaf5d140c2fc1214bd74e80e2cad9 100644 (file)
@@ -145,8 +145,7 @@ bool bitmap_isclear(Bitmap *b) {
 void bitmap_clear(Bitmap *b) {
         assert(b);
 
-        free(b->bitmaps);
-        b->bitmaps = NULL;
+        b->bitmaps = mfree(b->bitmaps);
         b->n_bitmaps = 0;
         b->bitmaps_allocated = 0;
 }
index a4823e6659623602d71227929e797d83d87e38ef..d70fe156a26044a3940920b1a8f20edf2f5b2fdc 100644 (file)
@@ -201,9 +201,11 @@ int fdset_cloexec(FDSet *fds, bool b) {
 
         assert(fds);
 
-        SET_FOREACH(p, MAKE_SET(fds), i)
-                if ((r = fd_cloexec(PTR_TO_FD(p), b)) < 0)
+        SET_FOREACH(p, MAKE_SET(fds), i) {
+                r = fd_cloexec(PTR_TO_FD(p), b);
+                if (r < 0)
                         return r;
+        }
 
         return 0;
 }
index 05e16d1caae237d3951058f37538e4ae18a48c5e..f3ec6a3e5243431988ee37ac356ba71e1b7ac3d5 100644 (file)
@@ -145,8 +145,7 @@ void release_lock_file(LockFile *f) {
                 if ((f->operation & ~LOCK_NB) == LOCK_EX)
                         unlink_noerrno(f->path);
 
-                free(f->path);
-                f->path = NULL;
+                f->path = mfree(f->path);
         }
 
         f->fd = safe_close(f->fd);
index eaf440a4b2bc7c168775bd48b3dfeb1c48613e01..b9aef64b1586b78974800787d3ffbef2a2eb18ce 100644 (file)
@@ -270,10 +270,8 @@ char **strv_split_newlines(const char *s) {
         if (n <= 0)
                 return l;
 
-        if (isempty(l[n-1])) {
-                free(l[n-1]);
-                l[n-1] = NULL;
-        }
+        if (isempty(l[n - 1]))
+                l[n - 1] = mfree(l[n - 1]);
 
         return l;
 }
@@ -292,9 +290,8 @@ int strv_split_extract(char ***t, const char *s, const char *separators, Extract
                 r = extract_first_word(&s, &word, separators, flags);
                 if (r < 0)
                         return r;
-                if (r == 0) {
+                if (r == 0)
                         break;
-                }
 
                 if (!GREEDY_REALLOC(l, allocated, n + 2))
                         return -ENOMEM;
index 322cec84a9efabc04bd9bdc7911424e61e295013..e61b58b5e5f0494905942c51e946936dc7221400 100644 (file)
@@ -438,10 +438,9 @@ int main(int argc, char *argv[]) {
 
                         res = nanosleep(&req, NULL);
                         if (res) {
-                                if (errno == EINTR) {
+                                if (errno == EINTR)
                                         /* caught signal, probably HUP! */
                                         break;
-                                }
                                 log_error_errno(errno, "nanosleep() failed: %m");
                                 return EXIT_FAILURE;
                         }
index a7ef653d5d0d78d2c9d2920e3419eb14c367db82..1231e6eaceb075847de150b959310133b8b135b6 100644 (file)
@@ -630,12 +630,11 @@ static void svg_io_bi_bar(FILE *of,
                                 pbi * (arg_scale_y * 5));
 
                 /* labels around highest value */
-                if (i == max_here) {
+                if (i == max_here)
                         fprintf(of, "  <text class=\"sec\" x=\"%.03f\" y=\"%.03f\">%0.2fmb/sec</text>\n",
                                 time_to_graph(sampledata->sampletime - graph_start) + 5,
                                 ((arg_scale_y * 5) - (pbi * (arg_scale_y * 5))) + 15,
                                 max / 1024.0 / (interval / 1000000000.0));
-                }
 
                 i++;
                 prev_sampledata = sampledata;
@@ -743,12 +742,11 @@ static void svg_io_bo_bar(FILE *of,
                                 pbo * (arg_scale_y * 5));
 
                 /* labels around highest bo value */
-                if (i == max_here) {
+                if (i == max_here)
                         fprintf(of, "  <text class=\"sec\" x=\"%.03f\" y=\"%.03f\">%0.2fmb/sec</text>\n",
                                 time_to_graph(sampledata->sampletime - graph_start) + 5,
                                 ((arg_scale_y * 5) - (pbo * (arg_scale_y * 5))),
                                 max / 1024.0 / (interval / 1000000000.0));
-                }
 
                 i++;
                 prev_sampledata = sampledata;
index b8171ddad7a7dba9dfb3e0296658a7712ef86c2b..5bb61b95d3132fb809eac4325a754b976b1748da 100644 (file)
@@ -127,8 +127,7 @@ static void automount_done(Unit *u) {
 
         unmount_autofs(a);
 
-        free(a->where);
-        a->where = NULL;
+        a->where = mfree(a->where);
 
         set_free(a->tokens);
         a->tokens = NULL;
index d3c12822392fcb14e41cfc476656d06e1c0c37f6..4020e9dd3c6817b8b58b8e9de357cca5384ef293 100644 (file)
@@ -95,8 +95,7 @@ static void busname_done(Unit *u) {
 
         assert(n);
 
-        free(n->name);
-        n->name = NULL;
+        n->name = mfree(n->name);
 
         busname_free_policy(n);
         busname_unwatch_control_pid(n);
index 3c98a0b18626145ae7bd2dd3dddf616121212360..ed55fcfca29317e7b0f2239ee947d68adfc3317d 100644 (file)
@@ -786,8 +786,7 @@ int bus_exec_context_set_transient_property(
                 if (mode != UNIT_CHECK) {
 
                         if (isempty(uu)) {
-                                free(c->user);
-                                c->user = NULL;
+                                c->user = mfree(c->user);
                         } else {
                                 char *t;
 
@@ -814,8 +813,7 @@ int bus_exec_context_set_transient_property(
                 if (mode != UNIT_CHECK) {
 
                         if (isempty(gg)) {
-                                free(c->group);
-                                c->group = NULL;
+                                c->group = mfree(c->group);
                         } else {
                                 char *t;
 
index 3f574b1832ecdf5b3883741b7702078bd8e077c8..7fdfacfddfbeecfe38bd246cf3b99529cae99b8c 100644 (file)
@@ -60,8 +60,7 @@ static void device_unset_sysfs(Device *d) {
         else
                 hashmap_remove(devices, d->sysfs);
 
-        free(d->sysfs);
-        d->sysfs = NULL;
+        d->sysfs = mfree(d->sysfs);
 }
 
 static int device_set_sysfs(Device *d, const char *sysfs) {
index 28eeeaad182f912f24b1d5007024190cb3cceaf5..cd3592b847ec4018fab10447bc4513e78a02da21 100644 (file)
@@ -122,7 +122,8 @@ static int shift_fds(int fds[], unsigned n_fds) {
                         if (fds[i] == i+3)
                                 continue;
 
-                        if ((nfd = fcntl(fds[i], F_DUPFD, i+3)) < 0)
+                        nfd = fcntl(fds[i], F_DUPFD, i + 3);
+                        if (nfd < 0)
                                 return -errno;
 
                         safe_close(fds[i]);
@@ -156,14 +157,16 @@ static int flags_fds(const int fds[], unsigned n_fds, bool nonblock) {
 
         for (i = 0; i < n_fds; i++) {
 
-                if ((r = fd_nonblock(fds[i], nonblock)) < 0)
+                r = fd_nonblock(fds[i], nonblock);
+                if (r < 0)
                         return r;
 
                 /* We unconditionally drop FD_CLOEXEC from the fds,
                  * since after all we want to pass these fds to our
                  * children */
 
-                if ((r = fd_cloexec(fds[i], false)) < 0)
+                r = fd_cloexec(fds[i], false);
+                if (r < 0)
                         return r;
         }
 
@@ -315,7 +318,8 @@ static int open_terminal_as(const char *path, mode_t mode, int nfd) {
         assert(path);
         assert(nfd >= 0);
 
-        if ((fd = open_terminal(path, mode | O_NOCTTY)) < 0)
+        fd = open_terminal(path, mode | O_NOCTTY);
+        if (fd < 0)
                 return fd;
 
         if (fd != nfd) {
@@ -629,7 +633,8 @@ static int enforce_groups(const ExecContext *context, const char *username, gid_
                 if (context->group) {
                         const char *g = context->group;
 
-                        if ((r = get_group_creds(&g, &gid)) < 0)
+                        r = get_group_creds(&g, &gid);
+                        if (r < 0)
                                 return r;
                 }
 
@@ -658,7 +663,8 @@ static int enforce_groups(const ExecContext *context, const char *username, gid_
                         return -ENOMEM;
 
                 if (keep_groups) {
-                        if ((k = getgroups(ngroups_max, gids)) < 0) {
+                        k = getgroups(ngroups_max, gids);
+                        if (k < 0) {
                                 free(gids);
                                 return -errno;
                         }
@@ -922,8 +928,7 @@ fail:
                 log_error("PAM failed: %s", pam_strerror(handle, pam_code));
                 err = -EPERM;  /* PAM errors do not map to errno */
         } else {
-                log_error_errno(errno, "PAM failed: %m");
-                err = -errno;
+                err = log_error_errno(errno, "PAM failed: %m");
         }
 
         if (handle) {
@@ -1994,32 +1999,20 @@ void exec_context_done(ExecContext *c) {
         c->environment_files = NULL;
 
         for (l = 0; l < ELEMENTSOF(c->rlimit); l++) {
-                free(c->rlimit[l]);
-                c->rlimit[l] = NULL;
+                c->rlimit[l] = mfree(c->rlimit[l]);
         }
 
-        free(c->working_directory);
-        c->working_directory = NULL;
-        free(c->root_directory);
-        c->root_directory = NULL;
-
-        free(c->tty_path);
-        c->tty_path = NULL;
-
-        free(c->syslog_identifier);
-        c->syslog_identifier = NULL;
-
-        free(c->user);
-        c->user = NULL;
-
-        free(c->group);
-        c->group = NULL;
+        c->working_directory = mfree(c->working_directory);
+        c->root_directory = mfree(c->root_directory);
+        c->tty_path = mfree(c->tty_path);
+        c->syslog_identifier = mfree(c->syslog_identifier);
+        c->user = mfree(c->user);
+        c->group = mfree(c->group);
 
         strv_free(c->supplementary_groups);
         c->supplementary_groups = NULL;
 
-        free(c->pam_name);
-        c->pam_name = NULL;
+        c->pam_name = mfree(c->pam_name);
 
         if (c->capabilities) {
                 cap_free(c->capabilities);
@@ -2038,14 +2031,9 @@ void exec_context_done(ExecContext *c) {
         if (c->cpuset)
                 CPU_FREE(c->cpuset);
 
-        free(c->utmp_id);
-        c->utmp_id = NULL;
-
-        free(c->selinux_context);
-        c->selinux_context = NULL;
-
-        free(c->apparmor_profile);
-        c->apparmor_profile = NULL;
+        c->utmp_id = mfree(c->utmp_id);
+        c->selinux_context = mfree(c->selinux_context);
+        c->apparmor_profile = mfree(c->apparmor_profile);
 
         set_free(c->syscall_filter);
         c->syscall_filter = NULL;
@@ -2090,8 +2078,7 @@ int exec_context_destroy_runtime_directory(ExecContext *c, const char *runtime_p
 void exec_command_done(ExecCommand *c) {
         assert(c);
 
-        free(c->path);
-        c->path = NULL;
+        c->path = mfree(c->path);
 
         strv_free(c->argv);
         c->argv = NULL;
index 542bf8eb26e8528ea10ae219fdb89f6c0dc93831..b695c57da8e441acaf315e61e469e99d4a7e52dd 100644 (file)
@@ -1215,8 +1215,7 @@ int config_parse_exec_selinux_context(
         assert(data);
 
         if (isempty(rvalue)) {
-                free(c->selinux_context);
-                c->selinux_context = NULL;
+                c->selinux_context = mfree(c->selinux_context);
                 c->selinux_context_ignore = false;
                 return 0;
         }
@@ -1265,8 +1264,7 @@ int config_parse_exec_apparmor_profile(
         assert(data);
 
         if (isempty(rvalue)) {
-                free(c->apparmor_profile);
-                c->apparmor_profile = NULL;
+                c->apparmor_profile = mfree(c->apparmor_profile);
                 c->apparmor_profile_ignore = false;
                 return 0;
         }
@@ -1315,8 +1313,7 @@ int config_parse_exec_smack_process_label(
         assert(data);
 
         if (isempty(rvalue)) {
-                free(c->smack_process_label);
-                c->smack_process_label = NULL;
+                c->smack_process_label = mfree(c->smack_process_label);
                 c->smack_process_label_ignore = false;
                 return 0;
         }
@@ -3571,13 +3568,11 @@ int unit_load_fragment(Unit *u) {
                 if (r < 0)
                         return r;
 
-                if (u->load_state == UNIT_STUB) {
+                if (u->load_state == UNIT_STUB)
                         /* Hmm, this didn't work? Then let's get rid
                          * of the fragment path stored for us, so that
                          * we don't point to an invalid location. */
-                        free(u->fragment_path);
-                        u->fragment_path = NULL;
-                }
+                        u->fragment_path = mfree(u->fragment_path);
         }
 
         /* Look for a template */
index fe8f1924bda6201c310f0760f10bf8ad75be1094..9aaf244e715a43bccf9217f9f737276356854c5f 100644 (file)
@@ -1204,12 +1204,11 @@ static int status_welcome(void) {
                            "PRETTY_NAME", &pretty_name,
                            "ANSI_COLOR", &ansi_color,
                            NULL);
-        if (r == -ENOENT) {
+        if (r == -ENOENT)
                 r = parse_env_file("/usr/lib/os-release", NEWLINE,
                                    "PRETTY_NAME", &pretty_name,
                                    "ANSI_COLOR", &ansi_color,
                                    NULL);
-        }
 
         if (r < 0 && r != -ENOENT)
                 log_warning_errno(r, "Failed to read os-release file: %m");
@@ -1843,8 +1842,7 @@ finish:
         m = manager_free(m);
 
         for (j = 0; j < ELEMENTSOF(arg_default_rlimit); j++) {
-                free(arg_default_rlimit[j]);
-                arg_default_rlimit[j] = NULL;
+                arg_default_rlimit[j] = mfree(arg_default_rlimit[j]);
         }
 
         arg_default_unit = mfree(arg_default_unit);
index 56f2c92febeefb1a98acdeaafa3b34f96eb5c37d..d918007bb87e1fbeccbab9060393e17e7796460c 100644 (file)
@@ -674,8 +674,7 @@ static int manager_setup_notify(Manager *m) {
                 static const int one = 1;
 
                 /* First free all secondary fields */
-                free(m->notify_socket);
-                m->notify_socket = NULL;
+                m->notify_socket = mfree(m->notify_socket);
                 m->notify_event_source = sd_event_source_unref(m->notify_event_source);
 
                 fd = socket(AF_UNIX, SOCK_DGRAM|SOCK_CLOEXEC|SOCK_NONBLOCK, 0);
@@ -2793,10 +2792,8 @@ static void trim_generator_dir(Manager *m, char **generator) {
         if (!*generator)
                 return;
 
-        if (rmdir(*generator) >= 0) {
-                free(*generator);
-                *generator = NULL;
-        }
+        if (rmdir(*generator) >= 0)
+                *generator = mfree(*generator);
 
         return;
 }
@@ -2866,8 +2863,7 @@ static void remove_generator_dir(Manager *m, char **generator) {
         strv_remove(m->lookup_paths.unit_path, *generator);
         (void) rm_rf(*generator, REMOVE_ROOT);
 
-        free(*generator);
-        *generator = NULL;
+        *generator = mfree(*generator);
 }
 
 static void manager_undo_generators(Manager *m) {
index 2b81d17b9c92ec525067ac6a5b84ef3e95c10492..83746ca41286b34126521dfa3d77d64d618a8ab2 100644 (file)
@@ -203,8 +203,7 @@ static void mount_done(Unit *u) {
 
         assert(m);
 
-        free(m->where);
-        m->where = NULL;
+        m->where = mfree(m->where);
 
         mount_parameters_done(&m->parameters_proc_self_mountinfo);
         mount_parameters_done(&m->parameters_fragment);
index 045321e1d44e8468ac6530f809948366767de4b5..0b85b859fa5b041d098b505b5342d5de2624416f 100644 (file)
@@ -288,8 +288,7 @@ static int mount_kdbus(BindMount *m) {
         /* create a new /dev/null dev node copy so we have some fodder to
          * bind-mount the custom endpoint over. */
         if (stat("/dev/null", &st) < 0) {
-                log_error_errno(errno, "Failed to stat /dev/null: %m");
-                r = -errno;
+                r = log_error_errno(errno, "Failed to stat /dev/null: %m");
                 goto fail;
         }
 
index 35cf0621bed55a6f150964f5028f94ce1ac7c5e1..98395becfd5538ff7852ea12db55ef5e1df81fa1 100644 (file)
@@ -476,8 +476,7 @@ int scope_abandon(Scope *s) {
         if (!IN_SET(s->state, SCOPE_RUNNING, SCOPE_ABANDONED))
                 return -ESTALE;
 
-        free(s->controller);
-        s->controller = NULL;
+        s->controller = mfree(s->controller);
 
         /* The client is no longer watching the remaining processes,
          * so let's step in here, under the assumption that the
index 292fe50de81e8bbe610d4ebb07a5bcbca05a867f..e396dbe213c2641f300162e05dcf87a673439054 100644 (file)
@@ -142,8 +142,7 @@ static void service_unwatch_pid_file(Service *s) {
         log_unit_debug(UNIT(s), "Stopping watch for PID file %s", s->pid_file_pathspec->path);
         path_spec_unwatch(s->pid_file_pathspec);
         path_spec_done(s->pid_file_pathspec);
-        free(s->pid_file_pathspec);
-        s->pid_file_pathspec = NULL;
+        s->pid_file_pathspec = mfree(s->pid_file_pathspec);
 }
 
 static int service_set_main_pid(Service *s, pid_t pid) {
@@ -287,14 +286,9 @@ static void service_done(Unit *u) {
 
         assert(s);
 
-        free(s->pid_file);
-        s->pid_file = NULL;
-
-        free(s->status_text);
-        s->status_text = NULL;
-
-        free(s->reboot_arg);
-        s->reboot_arg = NULL;
+        s->pid_file = mfree(s->pid_file);
+        s->status_text = mfree(s->status_text);
+        s->reboot_arg = mfree(s->reboot_arg);
 
         s->exec_runtime = exec_runtime_unref(s->exec_runtime);
         exec_command_free_array(s->exec_command, _SERVICE_EXEC_COMMAND_MAX);
@@ -313,8 +307,7 @@ static void service_done(Unit *u) {
 
         if (s->bus_name)  {
                 unit_unwatch_bus_name(u, s->bus_name);
-                free(s->bus_name);
-                s->bus_name = NULL;
+                s->bus_name = mfree(s->bus_name);
         }
 
         s->bus_endpoint_fd = safe_close(s->bus_endpoint_fd);
@@ -702,13 +695,12 @@ static void service_dump(Unit *u, FILE *f, const char *prefix) {
                 fprintf(f, "%sStatus Text: %s\n",
                         prefix, s->status_text);
 
-        if (s->n_fd_store_max > 0) {
+        if (s->n_fd_store_max > 0)
                 fprintf(f,
                         "%sFile Descriptor Store Max: %u\n"
                         "%sFile Descriptor Store Current: %u\n",
                         prefix, s->n_fd_store_max,
                         prefix, s->n_fd_store);
-        }
 }
 
 static int service_load_pid_file(Service *s, bool may_warn) {
@@ -1939,8 +1931,7 @@ static int service_start(Unit *u) {
         s->forbid_restart = false;
         s->reset_cpu_usage = true;
 
-        free(s->status_text);
-        s->status_text = NULL;
+        s->status_text = mfree(s->status_text);
         s->status_errno = 0;
 
         s->notify_state = NOTIFY_UNKNOWN;
index 8a6fd25f313768cabc8a7f7d6a1659b1a47cc01f..8cc6efc5b837da216d60cbd0defd4de2981687b0 100644 (file)
@@ -404,8 +404,7 @@ int main(int argc, char *argv[]) {
                 exit(0);
         }
 
-        log_error_errno(errno, "Failed to invoke reboot(): %m");
-        r = -errno;
+        r = log_error_errno(errno, "Failed to invoke reboot(): %m");
 
   error:
         log_emergency_errno(r, "Critical error while doing system shutdown: %m");
index 1014fad626dcaef7f40fafbca302823a2edb7bf7..9db42a033310c53e3f53dcae2bb14a393ec1ad06 100644 (file)
@@ -135,11 +135,8 @@ static void socket_done(Unit *u) {
 
         unit_ref_unset(&s->service);
 
-        free(s->tcp_congestion);
-        s->tcp_congestion = NULL;
-
-        free(s->bind_to_device);
-        s->bind_to_device = NULL;
+        s->tcp_congestion = mfree(s->tcp_congestion);
+        s->bind_to_device = mfree(s->bind_to_device);
 
         free(s->smack);
         free(s->smack_ip_in);
@@ -985,7 +982,9 @@ static int fifo_address_create(
                 goto fail;
         }
 
-        if ((fd = open(path, O_RDWR|O_CLOEXEC|O_NOCTTY|O_NONBLOCK|O_NOFOLLOW)) < 0) {
+        fd = open(path,
+                  O_RDWR | O_CLOEXEC | O_NOCTTY | O_NONBLOCK | O_NOFOLLOW);
+        if (fd < 0) {
                 r = -errno;
                 goto fail;
         }
index 2f462e339d30dcc170292fcc56d979ea061d50ac..a26bc58cfcd852cdc5b303c236bbcf6e762ac522 100644 (file)
@@ -59,8 +59,7 @@ static void swap_unset_proc_swaps(Swap *s) {
         if (!s->from_proc_swaps)
                 return;
 
-        free(s->parameters_proc_swaps.what);
-        s->parameters_proc_swaps.what = NULL;
+        s->parameters_proc_swaps.what = mfree(s->parameters_proc_swaps.what);
 
         s->from_proc_swaps = false;
 }
@@ -87,8 +86,7 @@ static int swap_set_devnode(Swap *s, const char *devnode) {
                 else
                         hashmap_remove(swaps, s->devnode);
 
-                free(s->devnode);
-                s->devnode = NULL;
+                s->devnode = mfree(s->devnode);
         }
 
         if (devnode) {
@@ -141,14 +139,9 @@ static void swap_done(Unit *u) {
         swap_unset_proc_swaps(s);
         swap_set_devnode(s, NULL);
 
-        free(s->what);
-        s->what = NULL;
-
-        free(s->parameters_fragment.what);
-        s->parameters_fragment.what = NULL;
-
-        free(s->parameters_fragment.options);
-        s->parameters_fragment.options = NULL;
+        s->what = mfree(s->what);
+        s->parameters_fragment.what = mfree(s->parameters_fragment.what);
+        s->parameters_fragment.options = mfree(s->parameters_fragment.options);
 
         s->exec_runtime = exec_runtime_unref(s->exec_runtime);
         exec_command_done_array(s->exec_command, _SWAP_EXEC_COMMAND_MAX);
index 090103fbdad76a2c6c0632e311cdd910afda33e6..b8f69ec6f3a5c1639344e976c80c088d3eeba3ea 100644 (file)
@@ -380,12 +380,10 @@ static int transaction_verify_order_one(Transaction *tr, Job *j, Job *from, unsi
                                          "Found dependency on %s/%s",
                                          k->unit->id, job_type_to_string(k->type));
 
-                        if (!delete && hashmap_get(tr->jobs, k->unit) &&
-                            !unit_matters_to_anchor(k->unit, k)) {
+                        if (!delete && hashmap_get(tr->jobs, k->unit) && !unit_matters_to_anchor(k->unit, k))
                                 /* Ok, we can drop this one, so let's
                                  * do so. */
                                 delete = k;
-                        }
 
                         /* Check if this in fact was the beginning of
                          * the cycle */
@@ -464,9 +462,11 @@ static int transaction_verify_order(Transaction *tr, unsigned *generation, sd_bu
 
         g = (*generation)++;
 
-        HASHMAP_FOREACH(j, tr->jobs, i)
-                if ((r = transaction_verify_order_one(tr, j, NULL, g, e)) < 0)
+        HASHMAP_FOREACH(j, tr->jobs, i) {
+                r = transaction_verify_order_one(tr, j, NULL, g, e);
+                if (r < 0)
                         return r;
+        }
 
         return 0;
 }
index 74fa90a233632030df7c991357e57bc9c61c0bfe..5d5872b7f4b3b58b8fcdefd1c10f581ebfa1e9e8 100644 (file)
@@ -329,12 +329,11 @@ static int get_password(const char *vol, const char *src, usec_t until, bool acc
         description = disk_description(src);
         mount_point = disk_mount_point(vol);
 
-        if (description && streq(vol, description)) {
+        if (description && streq(vol, description))
                 /* If the description string is simply the
                  * volume name, then let's not show this
                  * twice */
                 description = mfree(description);
-        }
 
         if (mount_point && description)
                 r = asprintf(&name_buffer, "%s (%s) on %s", description, vol, mount_point);
index c97be2dabf49ea6475d762653909ecfb4e9247f9..bb821797f1c28aebfe1474927b2cedb058b69ef8 100644 (file)
@@ -526,9 +526,9 @@ static int add_boot(const char *what) {
                        what,
                        "/boot",
                        "vfat",
-                       "EFI System Partition Automount",
-                       false,
+                       true,
                        "umask=0077",
+                       "EFI System Partition Automount",
                        120 * USEC_PER_SEC);
 
         return r;
index e90ae541564245a9b8f9620a39d4654ad2f07ea8..cb837e9d030053f1c93a5f829955d696fcddd55a 100644 (file)
@@ -64,8 +64,7 @@ static void context_reset(Context *c) {
         assert(c);
 
         for (p = 0; p < _PROP_MAX; p++) {
-                free(c->data[p]);
-                c->data[p] = NULL;
+                c->data[p] = mfree(c->data[p]);
         }
 }
 
@@ -114,12 +113,11 @@ static int context_read_data(Context *c) {
                            "PRETTY_NAME", &c->data[PROP_OS_PRETTY_NAME],
                            "CPE_NAME", &c->data[PROP_OS_CPE_NAME],
                            NULL);
-        if (r == -ENOENT) {
+        if (r == -ENOENT)
                 r = parse_env_file("/usr/lib/os-release", NEWLINE,
                                    "PRETTY_NAME", &c->data[PROP_OS_PRETTY_NAME],
                                    "CPE_NAME", &c->data[PROP_OS_CPE_NAME],
                                    NULL);
-        }
 
         if (r < 0 && r != -ENOENT)
                 return r;
@@ -498,8 +496,7 @@ static int method_set_static_hostname(sd_bus_message *m, void *userdata, sd_bus_
                 return 1; /* No authorization for now, but the async polkit stuff will call us again when it has it */
 
         if (isempty(name)) {
-                free(c->data[PROP_STATIC_HOSTNAME]);
-                c->data[PROP_STATIC_HOSTNAME] = NULL;
+                c->data[PROP_STATIC_HOSTNAME] = mfree(c->data[PROP_STATIC_HOSTNAME]);
         } else {
                 char *h;
 
@@ -570,8 +567,7 @@ static int set_machine_info(Context *c, sd_bus_message *m, int prop, sd_bus_mess
                 return 1; /* No authorization for now, but the async polkit stuff will call us again when it has it */
 
         if (isempty(name)) {
-                free(c->data[prop]);
-                c->data[prop] = NULL;
+                c->data[prop] = mfree(c->data[prop]);
         } else {
                 char *h;
 
index 5adc748c50da2bf0bf65a94ca56710211d5ce633..43fa9d1b03864d81ce70c563c22a696de830afcc 100644 (file)
@@ -287,8 +287,7 @@ int tar_export_start(TarExport *e, const char *path, int fd, ImportCompressType
                 if (r >= 0)
                         e->quota_referenced = q.referenced;
 
-                free(e->temp_path);
-                e->temp_path = NULL;
+                e->temp_path = mfree(e->temp_path);
 
                 r = tempfn_random(path, NULL, &e->temp_path);
                 if (r < 0)
@@ -298,8 +297,7 @@ int tar_export_start(TarExport *e, const char *path, int fd, ImportCompressType
                 r = btrfs_subvol_snapshot_fd(sfd, e->temp_path, BTRFS_SNAPSHOT_READ_ONLY|BTRFS_SNAPSHOT_RECURSIVE);
                 if (r < 0) {
                         log_debug_errno(r, "Couldn't create snapshot %s of %s, not exporting atomically: %m", e->temp_path, path);
-                        free(e->temp_path);
-                        e->temp_path = NULL;
+                        e->temp_path = mfree(e->temp_path);
                 }
         }
 
index a27e81bbd4ce6451ab4a2918bf3615597cc14cc7..5f7d25d063e63e2dca668cfb921e49b23a324617 100644 (file)
@@ -249,8 +249,7 @@ static int raw_import_finish(RawImport *i) {
         if (r < 0)
                 return log_error_errno(r, "Failed to move image into place: %m");
 
-        free(i->temp_path);
-        i->temp_path = NULL;
+        i->temp_path = mfree(i->temp_path);
 
         return 0;
 }
index 7ffe83cc336a4aebb92196a8b5c14c7adb3abe87..d2bfb3023841e755c217fe8318ce6c8cd19a7548 100644 (file)
@@ -205,8 +205,7 @@ static int tar_import_finish(TarImport *i) {
         if (r < 0)
                 return log_error_errno(r, "Failed to move image into place: %m");
 
-        free(i->temp_path);
-        i->temp_path = NULL;
+        i->temp_path = mfree(i->temp_path);
 
         return 0;
 }
index ffff94ee721beafee1ed3b7c3121a7d0182d2e8c..b91300a5df2431ca0af3d1b86a27535eb15703ce 100644 (file)
@@ -600,12 +600,9 @@ static int manager_on_notify(sd_event_source *s, int fd, uint32_t revents, void
         cmsg_close_all(&msghdr);
 
         CMSG_FOREACH(cmsg, &msghdr) {
-                if (cmsg->cmsg_level == SOL_SOCKET &&
-                           cmsg->cmsg_type == SCM_CREDENTIALS &&
-                           cmsg->cmsg_len == CMSG_LEN(sizeof(struct ucred))) {
+                if (cmsg->cmsg_level == SOL_SOCKET && cmsg->cmsg_type == SCM_CREDENTIALS && cmsg->cmsg_len == CMSG_LEN(sizeof(struct ucred)))
 
                         ucred = (struct ucred*) CMSG_DATA(cmsg);
-                }
         }
 
         if (msghdr.msg_flags & MSG_TRUNC) {
index 5ff49baa2291fc5af3cec5fe4071145fc8064adb..0dab184af12639f95252602d7c92b0a21720fe10 100644 (file)
@@ -1211,10 +1211,8 @@ static void dkr_pull_job_on_finished(PullJob *j) {
                 log_info("Completed writing to layer %s.", i->final_path);
 
                 i->layer_job = pull_job_unref(i->layer_job);
-                free(i->temp_path);
-                i->temp_path = NULL;
-                free(i->final_path);
-                i->final_path = NULL;
+                i->temp_path = mfree(i->temp_path);
+                i->final_path = mfree(i->final_path);
 
                 i->current_ancestry ++;
                 r = dkr_pull_pull_layer(i);
index 19d6468fcc0c8999aec43c31c239c1c900df78da..6d08db74ef8fd7a1834f7dca1b08d907e9db9e82 100644 (file)
@@ -269,8 +269,8 @@ static int server_init(Server *s, unsigned n_sockets) {
 
         s->epoll_fd = epoll_create1(EPOLL_CLOEXEC);
         if (s->epoll_fd < 0) {
-                r = -errno;
-                log_error_errno(errno, "Failed to create epoll object: %m");
+                r = log_error_errno(errno,
+                                    "Failed to create epoll object: %m");
                 goto fail;
         }
 
@@ -399,13 +399,10 @@ int main(int argc, char *argv[]) {
                 struct epoll_event event;
                 int k;
 
-                if ((k = epoll_wait(server.epoll_fd,
-                                    &event, 1,
-                                    TIMEOUT_MSEC)) < 0) {
-
+                k = epoll_wait(server.epoll_fd, &event, 1, TIMEOUT_MSEC);
+                if (k < 0) {
                         if (errno == EINTR)
                                 continue;
-
                         log_error_errno(errno, "epoll_wait() failed: %m");
                         goto fail;
                 }
index ebdd9edfc3c393eba002c8cd84cbce12ba3b13ea..bb762c88321a937e511d065b46bc144319bbe4a5 100644 (file)
@@ -337,10 +337,8 @@ static int request_parse_range(
                 return -ENOMEM;
 
         m->cursor[strcspn(m->cursor, WHITESPACE)] = 0;
-        if (isempty(m->cursor)) {
-                free(m->cursor);
-                m->cursor = NULL;
-        }
+        if (isempty(m->cursor))
+                m->cursor = mfree(m->cursor);
 
         return 0;
 }
index 99820fa7b8adaef537d2ed1c552ac7612cbebe53..40f4ff8e58cf3238e68e95cc09c029f032c2f22c 100644 (file)
@@ -30,8 +30,7 @@ int iovw_put(struct iovec_wrapper *iovw, void* data, size_t len) {
 }
 
 void iovw_free_contents(struct iovec_wrapper *iovw) {
-        free(iovw->iovec);
-        iovw->iovec = NULL;
+        iovw->iovec = mfree(iovw->iovec);
         iovw->size_bytes = iovw->count = 0;
 }
 
index cdcda1cb52a17b1155d9928fb4f067db07be4424..bdf01f582c974820fbf6fbcc1069915a01f41c15 100644 (file)
@@ -88,8 +88,7 @@ static int spawn_child(const char* child, char** argv) {
 
         child_pid = fork();
         if (child_pid < 0) {
-                r = -errno;
-                log_error_errno(errno, "Failed to fork: %m");
+                r = log_error_errno(errno, "Failed to fork: %m");
                 safe_close_pair(fd);
                 return r;
         }
index 5fd639a76abbc69ce5ce4f699a77d8d12dd91aff..507210f51c4c57c071fca7c34eff46f747226d36 100644 (file)
@@ -21,8 +21,7 @@ static ssize_t write_entry(char *buf, size_t size, Uploader *u) {
 
                 switch(u->entry_state) {
                 case ENTRY_CURSOR: {
-                        free(u->current_cursor);
-                        u->current_cursor = NULL;
+                        u->current_cursor = mfree(u->current_cursor);
 
                         r = sd_journal_get_cursor(u->journal, &u->current_cursor);
                         if (r < 0)
@@ -375,10 +374,9 @@ int open_journal_for_upload(Uploader *u,
 
         if (cursor) {
                 r = sd_journal_seek_cursor(j, cursor);
-                if (r < 0) {
+                if (r < 0)
                         return log_error_errno(r, "Failed to seek to cursor %s: %m",
                                                cursor);
-                }
         }
 
         return process_journal_input(u, 1 + !!after_cursor);
index 2e236f0004cfc14d7998a0cb90cd649e9c340532..be2c2e33548c33d26caee72f341dde985966929b 100644 (file)
@@ -142,8 +142,7 @@ int main(int argc, char *argv[]) {
 
         if (dup3(fd, STDOUT_FILENO, 0) < 0 ||
             dup3(fd, STDERR_FILENO, 0) < 0) {
-                log_error_errno(errno, "Failed to duplicate fd: %m");
-                r = -errno;
+                r = log_error_errno(errno, "Failed to duplicate fd: %m");
                 goto finish;
         }
 
index 644ba91b0dbc57e4fe250639ed131a003b1835fb..0fa427003ba06f2a5becae130537f373c052c9bc 100644 (file)
@@ -631,8 +631,8 @@ static int save_core(sd_journal *j, int fd, char **path, bool *unlink_temp) {
 
                         sz = write(fdt, data, len);
                         if (sz < 0) {
-                                log_error_errno(errno, "Failed to write temporary file: %m");
-                                r = -errno;
+                                r = log_error_errno(errno,
+                                                    "Failed to write temporary file: %m");
                                 goto error;
                         }
                         if (sz != (ssize_t) len) {
@@ -758,8 +758,7 @@ static int run_gdb(sd_journal *j) {
 
         pid = fork();
         if (pid < 0) {
-                log_error_errno(errno, "Failed to fork(): %m");
-                r = -errno;
+                r = log_error_errno(errno, "Failed to fork(): %m");
                 goto finish;
         }
         if (pid == 0) {
index eaf006db7a7df6c8782c351f4c9bf140df65495e..00f70d3a530dbcfe570f1dbb839ddd1d1c862b1c 100644 (file)
@@ -839,22 +839,20 @@ int journal_file_verify(
 
         data_fd = open_tmpfile("/var/tmp", O_RDWR | O_CLOEXEC);
         if (data_fd < 0) {
-                log_error_errno(errno, "Failed to create data file: %m");
-                r = -errno;
+                r = log_error_errno(errno, "Failed to create data file: %m");
                 goto fail;
         }
 
         entry_fd = open_tmpfile("/var/tmp", O_RDWR | O_CLOEXEC);
         if (entry_fd < 0) {
-                log_error_errno(errno, "Failed to create entry file: %m");
-                r = -errno;
+                r = log_error_errno(errno, "Failed to create entry file: %m");
                 goto fail;
         }
 
         entry_array_fd = open_tmpfile("/var/tmp", O_RDWR | O_CLOEXEC);
         if (entry_array_fd < 0) {
-                log_error_errno(errno, "Failed to create entry array file: %m");
-                r = -errno;
+                r = log_error_errno(errno,
+                                    "Failed to create entry array file: %m");
                 goto fail;
         }
 
index ce2dd9da26cabd233333387b677c6b2e990788d1..d31ab1c6d7205e8045d900f56bb5d13bd73e02ba 100644 (file)
@@ -1428,8 +1428,7 @@ static int setup_keys(void) {
 
         fd = open("/dev/random", O_RDONLY|O_CLOEXEC|O_NOCTTY);
         if (fd < 0) {
-                log_error_errno(errno, "Failed to open /dev/random: %m");
-                r = -errno;
+                r = log_error_errno(errno, "Failed to open /dev/random: %m");
                 goto finish;
         }
 
@@ -1488,8 +1487,7 @@ static int setup_keys(void) {
         }
 
         if (link(k, p) < 0) {
-                log_error_errno(errno, "Failed to link file: %m");
-                r = -errno;
+                r = log_error_errno(errno, "Failed to link file: %m");
                 goto finish;
         }
 
index 83c3332abf20b0de114190bb1c798d85f37a79fb..fe8ae194c9d145cc81a24b6ccd9b87b0f1fe3531 100644 (file)
@@ -324,10 +324,9 @@ static int map_all_fields(
                         if (r < 0)
                                 return log_debug_errno(r, "Failed to parse audit array: %m");
 
-                        if (r == 0) {
+                        if (r == 0)
                                 /* Couldn't process as generic field, let's just skip over it */
                                 p += strcspn(p, WHITESPACE);
-                        }
                 }
         }
 }
index d24502d9a88dc11cbe79a642f331a96159b554c9..9dd9cb853f7a2ae4391cfcd7ee39b544c3f46515 100644 (file)
@@ -118,12 +118,11 @@ int main(int argc, char *argv[]) {
 
         assert_se(journal_file_verify(f, verification_key, &from, &to, &total, true) >= 0);
 
-        if (verification_key && JOURNAL_HEADER_SEALED(f->header)) {
+        if (verification_key && JOURNAL_HEADER_SEALED(f->header))
                 log_info("=> Validated from %s to %s, %s missing",
                          format_timestamp(a, sizeof(a), from),
                          format_timestamp(b, sizeof(b), to),
                          format_timespan(c, sizeof(c), total > to ? total - to : 0, 0));
-        }
 
         journal_file_close(f);
 
index 0fc05e1484528b7781bda4777354fc5fe7444072..14b9444dab0ef0d842a85348ac19c14c88b47dc6 100644 (file)
@@ -463,9 +463,8 @@ int sd_ipv4ll_get_address(sd_ipv4ll *ll, struct in_addr *address){
         assert_return(ll, -EINVAL);
         assert_return(address, -EINVAL);
 
-        if (ll->claimed_address == 0) {
+        if (ll->claimed_address == 0)
                 return -ENOENT;
-        }
 
         address->s_addr = ll->claimed_address;
         return 0;
index c3cc2b7212f73c8c3d62fb0d943fb2b87d2a70d0..6826e2166545afc59e1977e686ade02b27d845aa 100644 (file)
@@ -107,8 +107,7 @@ _public_ sd_bus_creds *sd_bus_creds_unref(sd_bus_creds *c) {
                         free(c->cgroup_root);
                         free(c->description);
 
-                        free(c->supplementary_gids);
-                        c->supplementary_gids = NULL;
+                        c->supplementary_gids = mfree(c->supplementary_gids);
 
                         strv_free(c->well_known_names);
                         c->well_known_names = NULL;
@@ -1015,10 +1014,8 @@ int bus_creds_add_more(sd_bus_creds *c, uint64_t mask, pid_t pid, pid_t tid) {
                         if (r != -EPERM && r != -EACCES)
                                 return r;
                 } else {
-                        if (c->cmdline_size == 0) {
-                                free(c->cmdline);
-                                c->cmdline = NULL;
-                        }
+                        if (c->cmdline_size == 0)
+                                c->cmdline = mfree(c->cmdline);
 
                         c->mask |= SD_BUS_CREDS_CMDLINE;
                 }
index 366a0264263e76abf857d8fbed3140953cecefd7..72e2b9f785cacbd59119aba491556906d26b2863 100644 (file)
@@ -113,8 +113,7 @@ static void message_reset_containers(sd_bus_message *m) {
                 free(m->containers[i].offsets);
         }
 
-        free(m->containers);
-        m->containers = NULL;
+        m->containers = mfree(m->containers);
 
         m->n_containers = m->containers_allocated = 0;
         m->root_container.index = 0;
index 03e83d08a1e5d8b2e2ae74f10455ae54a5cd3e59..abe482fc46d52af716024cade4b27a6f91541a7f 100644 (file)
@@ -55,8 +55,7 @@ static void context_reset_member(Context *c) {
 }
 
 static void context_reset_interface(Context *c) {
-        free(c->interface_name);
-        c->interface_name = NULL;
+        c->interface_name = mfree(c->interface_name);
         c->interface_flags = 0;
 
         context_reset_member(c);
index 4a9181613a6b0f69294102bff69efa9af4443c11..2ac4b9be8e9d6d8f051e285851264d6ccc4d1fb3 100644 (file)
@@ -820,8 +820,7 @@ static int parse_container_unix_address(sd_bus *b, const char **p, char **guid)
                 b->machine = machine;
                 machine = NULL;
         } else {
-                free(b->machine);
-                b->machine = NULL;
+                b->machine = mfree(b->machine);
         }
 
         if (pid) {
@@ -880,8 +879,7 @@ static int parse_container_kernel_address(sd_bus *b, const char **p, char **guid
                 b->machine = machine;
                 machine = NULL;
         } else {
-                free(b->machine);
-                b->machine = NULL;
+                b->machine = mfree(b->machine);
         }
 
         if (pid) {
index aee2ced2d93e1f43adedacc30d4707e3e043d7c8..7ac89498300ecf3ebcd7968435a1eb30207c514e 100644 (file)
@@ -843,8 +843,7 @@ int sd_netlink_message_exit_container(sd_netlink_message *m) {
         assert_return(m->sealed, -EINVAL);
         assert_return(m->n_containers > 0, -EINVAL);
 
-        free(m->containers[m->n_containers].attributes);
-        m->containers[m->n_containers].attributes = NULL;
+        m->containers[m->n_containers].attributes = mfree(m->containers[m->n_containers].attributes);
         m->containers[m->n_containers].type_system = NULL;
 
         m->n_containers --;
@@ -894,16 +893,14 @@ int sd_netlink_message_rewind(sd_netlink_message *m) {
                 rtnl_message_seal(m);
 
         for (i = 1; i <= m->n_containers; i++) {
-                free(m->containers[i].attributes);
-                m->containers[i].attributes = NULL;
+                m->containers[i].attributes = mfree(m->containers[i].attributes);
         }
 
         m->n_containers = 0;
 
-        if (m->containers[0].attributes) {
+        if (m->containers[0].attributes)
                 /* top-level attributes have already been parsed */
                 return 0;
-        }
 
         assert(m->hdr);
 
index 044ee3a0cbe0b89b10e96356d7ddebc439d4dc7c..19e9130be0b630ac6445e584a66289c5b50cea3b 100644 (file)
@@ -246,8 +246,7 @@ void udev_list_cleanup(struct udev_list *list)
         struct udev_list_entry *entry_loop;
         struct udev_list_entry *entry_tmp;
 
-        free(list->entries);
-        list->entries = NULL;
+        list->entries = mfree(list->entries);
         list->entries_cur = 0;
         list->entries_max = 0;
         udev_list_entry_foreach_safe(entry_loop, entry_tmp, udev_list_get_entry(list))
index 210b889c4f987cd7998b38ac69e0578c77e98603..f40e35a8cbbf60ffec2eb369fd7f3b24ddca6e7b 100644 (file)
@@ -66,12 +66,11 @@ void button_free(Button *b) {
         sd_event_source_unref(b->io_event_source);
         sd_event_source_unref(b->check_event_source);
 
-        if (b->fd >= 0) {
+        if (b->fd >= 0)
                 /* If the device has been unplugged close() returns
                  * ENODEV, let's ignore this, hence we don't use
                  * safe_close() */
                 (void) close(b->fd);
-        }
 
         free(b->name);
         free(b->seat);
@@ -239,10 +238,7 @@ int button_open(Button *b) {
 
         assert(b);
 
-        if (b->fd >= 0) {
-                close(b->fd);
-                b->fd = -1;
-        }
+        b->fd = safe_close(b->fd);
 
         p = strjoina("/dev/input/", b->name);
 
@@ -251,8 +247,7 @@ int button_open(Button *b) {
                 return log_warning_errno(errno, "Failed to open %s: %m", b->name);
 
         if (ioctl(b->fd, EVIOCGNAME(sizeof(name)), name) < 0) {
-                log_error_errno(errno, "Failed to get input name: %m");
-                r = -errno;
+                r = log_error_errno(errno, "Failed to get input name: %m");
                 goto fail;
         }
 
@@ -267,8 +262,7 @@ int button_open(Button *b) {
         return 0;
 
 fail:
-        close(b->fd);
-        b->fd = -1;
+        b->fd = safe_close(b->fd);
         return r;
 }
 
index b6fa50aa5252cbf1b12523b5ddc6a0bf8c6a77d6..050d0252ad7681f49023753d3e81036388bbccca 100644 (file)
@@ -1987,8 +1987,7 @@ static int method_cancel_scheduled_shutdown(sd_bus_message *message, void *userd
         m->scheduled_shutdown_timeout_source = sd_event_source_unref(m->scheduled_shutdown_timeout_source);
         m->wall_message_timeout_source = sd_event_source_unref(m->wall_message_timeout_source);
         m->nologin_timeout_source = sd_event_source_unref(m->nologin_timeout_source);
-        free(m->scheduled_shutdown_type);
-        m->scheduled_shutdown_type = NULL;
+        m->scheduled_shutdown_type = mfree(m->scheduled_shutdown_type);
         m->scheduled_shutdown_timeout = 0;
 
         if (m->unlink_nologin) {
index cfae186edd615c5c8e4e3c799acca50f3aaa8c26..0c9c1e5e9795065e1ce4bd552cae76e281579b91 100644 (file)
@@ -333,8 +333,7 @@ void inhibitor_remove_fifo(Inhibitor *i) {
 
         if (i->fifo_path) {
                 unlink(i->fifo_path);
-                free(i->fifo_path);
-                i->fifo_path = NULL;
+                i->fifo_path = mfree(i->fifo_path);
         }
 }
 
index 92a6027a7ef4a085f21ca90c5a60f13823b2d68a..d2c5a298018fec336157d4b018a8533327973ac7 100644 (file)
@@ -913,8 +913,7 @@ static void session_remove_fifo(Session *s) {
 
         if (s->fifo_path) {
                 unlink(s->fifo_path);
-                free(s->fifo_path);
-                s->fifo_path = NULL;
+                s->fifo_path = mfree(s->fifo_path);
         }
 }
 
index 5d8a7571cd2ccb4f31d587879db471cf2c6ea91d..f2c89e365336f107b0106fc5986d46d3310952b1 100644 (file)
@@ -560,8 +560,7 @@ static int user_remove_runtime_path(User *u) {
         if (r < 0)
                 log_error_errno(r, "Failed to remove runtime directory %s: %m", u->runtime_path);
 
-        free(u->runtime_path);
-        u->runtime_path = NULL;
+        u->runtime_path = mfree(u->runtime_path);
 
         return r;
 }
index a056ec3b080e8c446d0e55cc247d0c0e70b1bf71..b52ecd015c3cbfcfb6d4ca9a91d052762a399a54 100644 (file)
@@ -600,8 +600,7 @@ void machine_release_unit(Machine *m) {
                 return;
 
         (void) hashmap_remove(m->manager->machine_units, m->unit);
-        free(m->unit);
-        m->unit = NULL;
+        m->unit = mfree(m->unit);
 }
 
 static const char* const machine_class_table[_MACHINE_CLASS_MAX] = {
index bb8c5ac64b6f92bbbf3eb779725ec6816287796e..7b8f6d1fabe3deaad7a9fe08c96124967744180d 100644 (file)
@@ -597,7 +597,7 @@ static void print_machine_status_info(sd_bus *bus, MachineStatusInfo *i) {
                 printf("\t    Unit: %s\n", i->unit);
                 show_unit_cgroup(bus, i->unit, i->leader);
 
-                if (arg_transport == BUS_TRANSPORT_LOCAL) {
+                if (arg_transport == BUS_TRANSPORT_LOCAL)
 
                         show_journal_by_unit(
                                         stdout,
@@ -611,7 +611,6 @@ static void print_machine_status_info(sd_bus *bus, MachineStatusInfo *i) {
                                         SD_JOURNAL_LOCAL_ONLY,
                                         true,
                                         NULL);
-                }
         }
 }
 
index a60034dbe631bbbd86021bb7d9938737ca958702..12e23216743ae87b9b68a51c1edcf859df6695ad 100644 (file)
@@ -204,9 +204,8 @@ static int netdev_bond_fill_message_create(NetDev *netdev, Link *link, sd_netlin
         if (b->lacp_rate != _NETDEV_BOND_LACP_RATE_INVALID &&
             b->mode == NETDEV_BOND_MODE_802_3AD) {
                 r = sd_netlink_message_append_u8(m, IFLA_BOND_AD_LACP_RATE, b->lacp_rate );
-                if (r < 0) {
+                if (r < 0)
                         return log_netdev_error_errno(netdev, r, "Could not append IFLA_BOND_AD_LACP_RATE attribute: %m");
-                }
         }
 
         if (b->miimon != 0) {
index ba84e802fc015e4304eb35f4f925097b7dacf57e..6a808b6205bccc396b46fcfb751a5b25e1748867 100644 (file)
@@ -143,11 +143,8 @@ static void tuntap_done(NetDev *netdev) {
 
         assert(t);
 
-        free(t->user_name);
-        t->user_name = NULL;
-
-        free(t->group_name);
-        t->group_name = NULL;
+        t->user_name = mfree(t->user_name);
+        t->group_name = mfree(t->group_name);
 }
 
 static int tuntap_verify(NetDev *netdev, const char *filename) {
index 2d5123788c34e115a077dee612224d61633f69c8..cacb4c257e5440379dfcb5ba1b1b7f51d5a5b768 100644 (file)
@@ -120,13 +120,11 @@ int link_update_rtnl(Link *l, sd_netlink_message *m) {
 int link_update_monitor(Link *l) {
         assert(l);
 
-        free(l->operational_state);
-        l->operational_state = NULL;
+        l->operational_state = mfree(l->operational_state);
 
         sd_network_link_get_operational_state(l->ifindex, &l->operational_state);
 
-        free(l->state);
-        l->state = NULL;
+        l->state = mfree(l->state);
 
         sd_network_link_get_setup_state(l->ifindex, &l->state);
 
index 92176b1e9f9b222855c286c64c8827c06a7819e9..f4778fc16a7d04e938da87478baedf46a1935e63 100644 (file)
@@ -54,10 +54,9 @@ int main(int argc, char *argv[]) {
         /* Read pool size, if possible */
         f = fopen("/proc/sys/kernel/random/poolsize", "re");
         if (f) {
-                if (fscanf(f, "%zu", &buf_size) > 0) {
+                if (fscanf(f, "%zu", &buf_size) > 0)
                         /* poolsize is in bits on 2.6, but we want bytes */
                         buf_size /= 8;
-                }
 
                 fclose(f);
         }
index 9847effb5334ffac1a08033cadf23587961e3292..22af092cc0b3cdcf0a863755472463bf39320062 100644 (file)
@@ -168,11 +168,10 @@ static int resolve_host(sd_bus *bus, const char *name) {
         if (r < 0)
                 return bus_log_parse_error(r);
 
-        if (!streq(name, canonical)) {
+        if (!streq(name, canonical))
                 printf("%*s%s (%s)\n",
                        (int) strlen(name), c == 0 ? name : "", c == 0 ? ":" : " ",
                        canonical);
-        }
 
         if (c == 0) {
                 log_error("%s: no addresses found", name);
index ef6b69c768e64a06332496e81063c67bf7fcc426..cbbbed8c8a418f7eed75630e62a33637866f305a 100644 (file)
@@ -241,12 +241,11 @@ static void dns_cache_item_update_positive(DnsCache *c, DnsCacheItem *i, DnsReso
 
         i->type = DNS_CACHE_POSITIVE;
 
-        if (!i->by_key_prev) {
+        if (!i->by_key_prev)
                 /* We are the first item in the list, we need to
                  * update the key used in the hashmap */
 
                 assert_se(hashmap_replace(c->by_key, rr->key, i) >= 0);
-        }
 
         dns_resource_record_ref(rr);
         dns_resource_record_unref(i->rr);
index 13852192c4d10638d1f9ca898c3e8637d72f5ff4..de924e3ed95e3cb9591c946d6fc33db6c5ee92b7 100644 (file)
@@ -619,8 +619,7 @@ int manager_read_resolv_conf(Manager *m) {
         }
 
         if (fstat(fileno(f), &st) < 0) {
-                log_error_errno(errno, "Failed to stat open file: %m");
-                r = -errno;
+                r = log_error_errno(errno, "Failed to stat open file: %m");
                 goto clear;
         }
 
index ca4c24ebde6f844f1095efcda5ccf33faa4faa18..f5cff6fc5666d01aaacc5a210deb997b0dc34c55 100644 (file)
@@ -331,8 +331,8 @@ int ask_password_agent(
 
         fd = mkostemp_safe(temp, O_WRONLY|O_CLOEXEC);
         if (fd < 0) {
-                log_error_errno(errno, "Failed to create password file: %m");
-                r = -errno;
+                r = log_error_errno(errno,
+                                    "Failed to create password file: %m");
                 goto finish;
         }
 
@@ -340,8 +340,7 @@ int ask_password_agent(
 
         f = fdopen(fd, "w");
         if (!f) {
-                log_error_errno(errno, "Failed to allocate FILE: %m");
-                r = -errno;
+                r = log_error_errno(errno, "Failed to allocate FILE: %m");
                 goto finish;
         }
 
@@ -349,8 +348,7 @@ int ask_password_agent(
 
         signal_fd = signalfd(-1, &mask, SFD_NONBLOCK|SFD_CLOEXEC);
         if (signal_fd < 0) {
-                log_error_errno(errno, "signalfd(): %m");
-                r = -errno;
+                r = log_error_errno(errno, "signalfd(): %m");
                 goto finish;
         }
 
@@ -395,8 +393,7 @@ int ask_password_agent(
         final[sizeof(final)-9] = 'k';
 
         if (rename(temp, final) < 0) {
-                log_error_errno(errno, "Failed to rename query file: %m");
-                r = -errno;
+                r = log_error_errno(errno, "Failed to rename query file: %m");
                 goto finish;
         }
 
@@ -432,8 +429,7 @@ int ask_password_agent(
                         if (errno == EINTR)
                                 continue;
 
-                        log_error_errno(errno, "poll() failed: %m");
-                        r = -errno;
+                        r = log_error_errno(errno, "poll() failed: %m");
                         goto finish;
                 }
 
@@ -471,8 +467,7 @@ int ask_password_agent(
                             errno == EINTR)
                                 continue;
 
-                        log_error_errno(errno, "recvmsg() failed: %m");
-                        r = -errno;
+                        r = log_error_errno(errno, "recvmsg() failed: %m");
                         goto finish;
                 }
 
index d9cc19700e32fbb580708aa370434ee19a8757fc..36c44227c5fe9cb6fe81f64bf70864597e0c5907 100644 (file)
@@ -1884,11 +1884,8 @@ int bus_wait_for_jobs(BusWaitForJobs *d, bool quiet) {
                         log_debug_errno(q, "Got result %s/%m for job %s", strna(d->result), strna(d->name));
                 }
 
-                free(d->name);
-                d->name = NULL;
-
-                free(d->result);
-                d->result = NULL;
+                d->name = mfree(d->name);
+                d->result = mfree(d->result);
         }
 
         return r;
index 36150d87449ae3cf2cccdba25172a393cff7278b..23512f0d354153c5310c9650a549f9f7664f09df 100644 (file)
@@ -232,8 +232,7 @@ static int parse_line(const char* unit,
                                            "Unknown section '%s'. Ignoring.", n);
 
                         free(n);
-                        free(*section);
-                        *section = NULL;
+                        *section = mfree(*section);
                         *section_line = 0;
                         *section_ignored = true;
                 } else {
index 9a5ffb7a6ca670f2245156e88f6ac2495a61ccca..7790c1a3c80c7f3b659150e338c52bf33d215c9e 100644 (file)
@@ -334,10 +334,9 @@ static int output_short(
                         break;
                 case OUTPUT_SHORT_PRECISE:
                         r = strftime(buf, sizeof(buf), "%b %d %H:%M:%S", gettime_r(&t, &tm));
-                        if (r > 0) {
+                        if (r > 0)
                                 snprintf(buf + strlen(buf), sizeof(buf) - strlen(buf),
                                          ".%06llu", (unsigned long long) (x % USEC_PER_SEC));
-                        }
                         break;
                 default:
                         r = strftime(buf, sizeof(buf), "%b %d %H:%M:%S", gettime_r(&t, &tm));
index 3992f9c837a5bd2fa168dfe3efcc4863b6fb1e27..55fd5cb79e4f8364cce1e0a6aa265b6e23718433 100644 (file)
@@ -74,8 +74,7 @@ int pager_open(bool jump_to_end) {
 
         pager_pid = fork();
         if (pager_pid < 0) {
-                r = -errno;
-                log_error_errno(errno, "Failed to fork pager: %m");
+                r = log_error_errno(errno, "Failed to fork pager: %m");
                 safe_close_pair(fd);
                 return r;
         }
index 96c39aa0a9a10bfd7af09dc04edd8c7a50ab9eb3..a82b9b83a2356ad9939c544f16bd2cecbef7f6ca 100644 (file)
@@ -3585,7 +3585,7 @@ static void print_status_info(
                 }
         }
 
-        if (i->id && arg_transport == BUS_TRANSPORT_LOCAL) {
+        if (i->id && arg_transport == BUS_TRANSPORT_LOCAL)
                 show_journal_by_unit(
                                 stdout,
                                 i->id,
@@ -3598,7 +3598,6 @@ static void print_status_info(
                                 SD_JOURNAL_LOCAL_ONLY,
                                 arg_scope == UNIT_FILE_SYSTEM,
                                 ellipsized);
-        }
 
         if (i->need_daemon_reload)
                 warn_unit_file_changed(i->id);
index c03bda43829ec91b1af66bb6bb48e5cc6e2a9c01..e3e5a95add29c597e024f20e4b0571bafd52f8e3 100644 (file)
@@ -31,7 +31,8 @@ int main(int argc, char* argv[]) {
         log_open();
         log_parse_environment();
 
-        if ((r = loopback_setup()) < 0)
+        r = loopback_setup();
+        if (r < 0)
                 fprintf(stderr, "loopback: %s\n", strerror(-r));
 
         return 0;
index 927b8abc64f335943566bcd07e13700446b09d32..a4b05d1becd5a6b261ef67fbe6e05bca59924fb4 100644 (file)
@@ -54,9 +54,8 @@ int ethtool_connect(int *ret) {
         assert_return(ret, -EINVAL);
 
         fd = socket(PF_INET, SOCK_DGRAM, 0);
-        if (fd < 0) {
+        if (fd < 0)
                 return -errno;
-        }
 
         *ret = fd;
 
index 3691a69d48edb4674903fb0960038058778c0a3f..69260cb1a05faf2ea2163c847f4de0f9b98b8b87 100644 (file)
@@ -577,9 +577,8 @@ static int check_fill_0x83_id(struct udev *udev,
 
         if (id_search->id_type == SCSI_ID_NAA && wwn != NULL) {
                 strncpy(wwn, &serial[s], 16);
-                if (wwn_vendor_extension != NULL) {
+                if (wwn_vendor_extension != NULL)
                         strncpy(wwn_vendor_extension, &serial[s + 16], 16);
-                }
         }
 
         return 0;
index f529ffcf256d8688479c924d9dc5f247aa64fa34..01e2c659ae13bab30b384f0ae0984c7bcc1c1428 100644 (file)
@@ -317,6 +317,39 @@ out:
         return parent;
 }
 
+static struct udev_device *handle_scsi_ata(struct udev_device *parent, char **path) {
+        struct udev *udev  = udev_device_get_udev(parent);
+        struct udev_device *targetdev;
+        struct udev_device *target_parent;
+        struct udev_device *atadev;
+        const char *port_no;
+
+        assert(parent);
+        assert(path);
+
+        targetdev = udev_device_get_parent_with_subsystem_devtype(parent, "scsi", "scsi_host");
+        if (!targetdev)
+                return NULL;
+
+        target_parent = udev_device_get_parent(targetdev);
+        if (!target_parent)
+                return NULL;
+
+        atadev = udev_device_new_from_subsystem_sysname(udev, "ata_port", udev_device_get_sysname(target_parent));
+        if (!atadev)
+                return NULL;
+
+        port_no = udev_device_get_sysattr_value(atadev, "port_no");
+        if (!port_no) {
+               parent = NULL;
+               goto out;
+        }
+        path_prepend(path, "ata-%s", port_no);
+out:
+        udev_device_unref(atadev);
+        return parent;
+}
+
 static struct udev_device *handle_scsi_default(struct udev_device *parent, char **path) {
         struct udev_device *hostdev;
         int host, bus, target, lun;
@@ -482,19 +515,8 @@ static struct udev_device *handle_scsi(struct udev_device *parent, char **path,
                 goto out;
         }
 
-        /*
-         * We do not support the ATA transport class, it uses global counters
-         * to name the ata devices which numbers spread across multiple
-         * controllers.
-         *
-         * The real link numbers are not exported. Also, possible chains of ports
-         * behind port multipliers cannot be composed that way.
-         *
-         * Until all that is solved at the kernel level, there are no by-path/
-         * links for ATA devices.
-         */
         if (strstr(name, "/ata") != NULL) {
-                parent = NULL;
+                parent = handle_scsi_ata(parent, path);
                 goto out;
         }
 
index ead7c92b2738fd8be3737aa2e97a3d37cd37cfec..56277f551fef769e363f3f3f0651279f2648823b 100644 (file)
@@ -121,18 +121,12 @@ int udev_ctrl_enable_receiving(struct udev_ctrl *uctrl) {
                         err = bind(uctrl->sock, &uctrl->saddr.sa, uctrl->addrlen);
                 }
 
-                if (err < 0) {
-                        err = -errno;
-                        log_error_errno(errno, "bind failed: %m");
-                        return err;
-                }
+                if (err < 0)
+                        return log_error_errno(errno, "bind failed: %m");
 
                 err = listen(uctrl->sock, 0);
-                if (err < 0) {
-                        err = -errno;
-                        log_error_errno(errno, "listen failed: %m");
-                        return err;
-                }
+                if (err < 0)
+                        return log_error_errno(errno, "listen failed: %m");
 
                 uctrl->bound = true;
                 uctrl->cleanup_socket = true;
index 47612227864035dda2608d044e2ea9c409f48381..1e34cbc2f53857f52c85aebc3af91e1aada200e3 100644 (file)
@@ -731,15 +731,13 @@ int udev_event_spawn(struct udev_event *event,
         /* pipes from child to parent */
         if (result != NULL || log_get_max_level() >= LOG_INFO) {
                 if (pipe2(outpipe, O_NONBLOCK) != 0) {
-                        err = -errno;
-                        log_error_errno(errno, "pipe failed: %m");
+                        err = log_error_errno(errno, "pipe failed: %m");
                         goto out;
                 }
         }
         if (log_get_max_level() >= LOG_INFO) {
                 if (pipe2(errpipe, O_NONBLOCK) != 0) {
-                        err = -errno;
-                        log_error_errno(errno, "pipe failed: %m");
+                        err = log_error_errno(errno, "pipe failed: %m");
                         goto out;
                 }
         }
@@ -753,14 +751,8 @@ int udev_event_spawn(struct udev_event *event,
                 char program[UTIL_PATH_SIZE];
 
                 /* child closes parent's ends of pipes */
-                if (outpipe[READ_END] >= 0) {
-                        close(outpipe[READ_END]);
-                        outpipe[READ_END] = -1;
-                }
-                if (errpipe[READ_END] >= 0) {
-                        close(errpipe[READ_END]);
-                        errpipe[READ_END] = -1;
-                }
+                outpipe[READ_END] = safe_close(outpipe[READ_END]);
+                errpipe[READ_END] = safe_close(errpipe[READ_END]);
 
                 strscpy(arg, sizeof(arg), cmd);
                 udev_build_argv(event->udev, arg, NULL, argv);
@@ -784,14 +776,8 @@ int udev_event_spawn(struct udev_event *event,
                 goto out;
         default:
                 /* parent closed child's ends of pipes */
-                if (outpipe[WRITE_END] >= 0) {
-                        close(outpipe[WRITE_END]);
-                        outpipe[WRITE_END] = -1;
-                }
-                if (errpipe[WRITE_END] >= 0) {
-                        close(errpipe[WRITE_END]);
-                        errpipe[WRITE_END] = -1;
-                }
+                outpipe[WRITE_END] = safe_close(outpipe[WRITE_END]);
+                errpipe[WRITE_END] = safe_close(errpipe[WRITE_END]);
 
                 spawn_read(event,
                            timeout_usec,
index 43255fb9d4d28102d815c029921bd1e980e19dbd..822f292217ecc055a702b5ad53c212afa18c59b9 100644 (file)
@@ -672,9 +672,8 @@ static int import_parent_into_properties(struct udev_device *dev, const char *fi
                 const char *key = udev_list_entry_get_name(list_entry);
                 const char *val = udev_list_entry_get_value(list_entry);
 
-                if (fnmatch(filter, key, 0) == 0) {
+                if (fnmatch(filter, key, 0) == 0)
                         udev_device_add_property(dev, key, val);
-                }
         }
         return 0;
 }
@@ -1686,12 +1685,10 @@ struct udev_rules *udev_rules_new(struct udev *udev, int resolve_names) {
         strbuf_complete(rules->strbuf);
 
         /* cleanup uid/gid cache */
-        free(rules->uids);
-        rules->uids = NULL;
+        rules->uids = mfree(rules->uids);
         rules->uids_cur = 0;
         rules->uids_max = 0;
-        free(rules->gids);
-        rules->gids = NULL;
+        rules->gids = mfree(rules->gids);
         rules->gids_cur = 0;
         rules->gids_max = 0;
 
@@ -2064,8 +2061,7 @@ int udev_rules_apply_to_event(struct udev_rules *rules,
                         char program[UTIL_PATH_SIZE];
                         char result[UTIL_LINE_SIZE];
 
-                        free(event->program_result);
-                        event->program_result = NULL;
+                        event->program_result = mfree(event->program_result);
                         udev_event_apply_format(event, rules_str(rules, cur->key.value_off), program, sizeof(program));
                         log_debug("PROGRAM '%s' %s:%u",
                                   program,
index f354ced2e271908d530533710ca5256a4b3482b6..20497ae8be6b88f72c39a5ad45ed8dcde65c5d0b 100644 (file)
@@ -1670,9 +1670,8 @@ int main(int argc, char *argv[]) {
 
                 arg_children_max = 8;
 
-                if (sched_getaffinity(0, sizeof (cpu_set), &cpu_set) == 0) {
+                if (sched_getaffinity(0, sizeof(cpu_set), &cpu_set) == 0)
                         arg_children_max += CPU_COUNT(&cpu_set) * 2;
-                }
 
                 log_debug("set children_max to %u", arg_children_max);
         }
index 61bcf02b2f27a734af77f9c39eb23cc61abc77d6..b2998dce43c409401b3f731443f5efc5bcce5c33 100644 (file)
@@ -130,8 +130,8 @@ static int on_reboot(Context *c) {
         if (c->audit_fd >= 0)
                 if (audit_log_user_comm_message(c->audit_fd, AUDIT_SYSTEM_BOOT, "", "systemd-update-utmp", NULL, NULL, NULL, 1) < 0 &&
                     errno != EPERM) {
-                        log_error_errno(errno, "Failed to send audit message: %m");
-                        r = -errno;
+                        r = log_error_errno(errno,
+                                            "Failed to send audit message: %m");
                 }
 #endif
 
@@ -160,8 +160,8 @@ static int on_shutdown(Context *c) {
         if (c->audit_fd >= 0)
                 if (audit_log_user_comm_message(c->audit_fd, AUDIT_SYSTEM_SHUTDOWN, "", "systemd-update-utmp", NULL, NULL, NULL, 1) < 0 &&
                     errno != EPERM) {
-                        log_error_errno(errno, "Failed to send audit message: %m");
-                        r = -errno;
+                        r = log_error_errno(errno,
+                                            "Failed to send audit message: %m");
                 }
 #endif
 
@@ -210,11 +210,9 @@ static int on_runlevel(Context *c) {
                              runlevel > 0 ? runlevel : 'N') < 0)
                         return log_oom();
 
-                if (audit_log_user_comm_message(c->audit_fd, AUDIT_SYSTEM_RUNLEVEL, s, "systemd-update-utmp", NULL, NULL, NULL, 1) < 0 &&
-                    errno != EPERM) {
-                        log_error_errno(errno, "Failed to send audit message: %m");
-                        r = -errno;
-                }
+                if (audit_log_user_comm_message(c->audit_fd, AUDIT_SYSTEM_RUNLEVEL, s, "systemd-update-utmp", NULL, NULL, NULL, 1) < 0 && errno != EPERM)
+                        r = log_error_errno(errno,
+                                            "Failed to send audit message: %m");
         }
 #endif
 
index e80a7771de6ae63d24bf65cc71aceedd08d8a935..7c736c44d25e45fc3ee746017537194fd7512f57 100644 (file)
@@ -42,10 +42,9 @@ int main(int argc, char*argv[]) {
         if (streq(argv[1], "start")) {
                 int r = 0;
 
-                if (unlink("/run/nologin") < 0 && errno != ENOENT) {
-                        log_error_errno(errno, "Failed to remove /run/nologin file: %m");
-                        r = -errno;
-                }
+                if (unlink("/run/nologin") < 0 && errno != ENOENT)
+                        r = log_error_errno(errno,
+                                            "Failed to remove /run/nologin file: %m");
 
                 if (unlink("/etc/nologin") < 0 && errno != ENOENT) {
                         /* If the file doesn't exist and /etc simply