diff options
author | Lennart Poettering <lennart@poettering.net> | 2015-08-17 11:30:31 +0200 |
---|---|---|
committer | Lennart Poettering <lennart@poettering.net> | 2015-08-17 11:30:31 +0200 |
commit | aaa2a3abf9b3f027918b60fe0d0340fcd4874291 (patch) | |
tree | 20ffef498556100193946c2bc6c5f6da51a4166d /src | |
parent | 22175a39e8df964b26def7988b841b348de9c97a (diff) | |
parent | 3e044c492e3ebe64f4e3175c94f9db8a62557b82 (diff) |
Merge pull request #976 from elfring/Remove_unnecessary_checks2
Delete unnecessary checks before some function calls
Diffstat (limited to 'src')
-rw-r--r-- | src/core/dbus-timer.c | 3 | ||||
-rw-r--r-- | src/core/timer.c | 5 | ||||
-rw-r--r-- | src/journal-remote/journal-gatewayd.c | 3 | ||||
-rw-r--r-- | src/journal/journal-file.c | 2 | ||||
-rw-r--r-- | src/journal/journald-server.c | 3 | ||||
-rw-r--r-- | src/libsystemd/sd-bus/bus-message.c | 6 | ||||
-rw-r--r-- | src/libsystemd/sd-bus/test-bus-chat.c | 4 | ||||
-rw-r--r-- | src/login/logind.c | 20 | ||||
-rw-r--r-- | src/machine/machined.c | 3 | ||||
-rw-r--r-- | src/resolve/resolved-manager.c | 3 | ||||
-rw-r--r-- | src/udev/udev-builtin-path_id.c | 12 | ||||
-rw-r--r-- | src/update-utmp/update-utmp.c | 4 |
12 files changed, 21 insertions, 47 deletions
diff --git a/src/core/dbus-timer.c b/src/core/dbus-timer.c index 74a9914358..8ea2cf84a4 100644 --- a/src/core/dbus-timer.c +++ b/src/core/dbus-timer.c @@ -252,8 +252,7 @@ static int bus_timer_set_transient_property( v = new0(TimerValue, 1); if (!v) { - if (c) - calendar_spec_free(c); + calendar_spec_free(c); return -ENOMEM; } diff --git a/src/core/timer.c b/src/core/timer.c index 51cd56ca84..7027f83dfd 100644 --- a/src/core/timer.c +++ b/src/core/timer.c @@ -56,10 +56,7 @@ void timer_free_values(Timer *t) { while ((v = t->values)) { LIST_REMOVE(value, t->values, v); - - if (v->calendar_spec) - calendar_spec_free(v->calendar_spec); - + calendar_spec_free(v->calendar_spec); free(v); } } diff --git a/src/journal-remote/journal-gatewayd.c b/src/journal-remote/journal-gatewayd.c index 1eb07a1681..ebdd9edfc3 100644 --- a/src/journal-remote/journal-gatewayd.c +++ b/src/journal-remote/journal-gatewayd.c @@ -103,8 +103,7 @@ static void request_meta_free( if (!m) return; - if (m->journal) - sd_journal_close(m->journal); + sd_journal_close(m->journal); if (m->tmp) fclose(m->tmp); diff --git a/src/journal/journal-file.c b/src/journal/journal-file.c index f7815b2796..4f94799ce7 100644 --- a/src/journal/journal-file.c +++ b/src/journal/journal-file.c @@ -169,7 +169,7 @@ void journal_file_close(JournalFile *f) { #ifdef HAVE_GCRYPT if (f->fss_file) munmap(f->fss_file, PAGE_ALIGN(f->fss_file_size)); - else if (f->fsprg_state) + else free(f->fsprg_state); free(f->fsprg_seed); diff --git a/src/journal/journald-server.c b/src/journal/journald-server.c index 28b1472ac8..fa2e9b9825 100644 --- a/src/journal/journald-server.c +++ b/src/journal/journald-server.c @@ -1689,6 +1689,5 @@ void server_done(Server *s) { if (s->mmap) mmap_cache_unref(s->mmap); - if (s->udev) - udev_unref(s->udev); + udev_unref(s->udev); } diff --git a/src/libsystemd/sd-bus/bus-message.c b/src/libsystemd/sd-bus/bus-message.c index b52285403f..a212f0b398 100644 --- a/src/libsystemd/sd-bus/bus-message.c +++ b/src/libsystemd/sd-bus/bus-message.c @@ -143,11 +143,7 @@ static void message_free(sd_bus_message *m) { if (m->iovec != m->iovec_fixed) free(m->iovec); - if (m->destination_ptr) { - free(m->destination_ptr); - m->destination_ptr = NULL; - } - + m->destination_ptr = mfree(m->destination_ptr); message_reset_containers(m); free(m->root_container.signature); free(m->root_container.offsets); diff --git a/src/libsystemd/sd-bus/test-bus-chat.c b/src/libsystemd/sd-bus/test-bus-chat.c index b97729caf7..a0aecc1f55 100644 --- a/src/libsystemd/sd-bus/test-bus-chat.c +++ b/src/libsystemd/sd-bus/test-bus-chat.c @@ -118,9 +118,7 @@ static int server_init(sd_bus **_bus) { return 0; fail: - if (bus) - sd_bus_unref(bus); - + sd_bus_unref(bus); return r; } diff --git a/src/login/logind.c b/src/login/logind.c index cf71c0ec5a..8ac2aceb9b 100644 --- a/src/login/logind.c +++ b/src/login/logind.c @@ -153,17 +153,12 @@ static void manager_free(Manager *m) { safe_close(m->console_active_fd); - if (m->udev_seat_monitor) - udev_monitor_unref(m->udev_seat_monitor); - if (m->udev_device_monitor) - udev_monitor_unref(m->udev_device_monitor); - if (m->udev_vcsa_monitor) - udev_monitor_unref(m->udev_vcsa_monitor); - if (m->udev_button_monitor) - udev_monitor_unref(m->udev_button_monitor); - - if (m->udev) - udev_unref(m->udev); + udev_monitor_unref(m->udev_seat_monitor); + udev_monitor_unref(m->udev_device_monitor); + udev_monitor_unref(m->udev_vcsa_monitor); + udev_monitor_unref(m->udev_button_monitor); + + udev_unref(m->udev); if (m->unlink_nologin) (void) unlink("/run/nologin"); @@ -1170,8 +1165,7 @@ finish: "STOPPING=1\n" "STATUS=Shutting down..."); - if (m) - manager_free(m); + manager_free(m); return r < 0 ? EXIT_FAILURE : EXIT_SUCCESS; } diff --git a/src/machine/machined.c b/src/machine/machined.c index 1eeeaf17a5..c8ad157326 100644 --- a/src/machine/machined.c +++ b/src/machine/machined.c @@ -355,8 +355,7 @@ int main(int argc, char *argv[]) { log_debug("systemd-machined stopped as pid "PID_FMT, getpid()); finish: - if (m) - manager_free(m); + manager_free(m); return r < 0 ? EXIT_FAILURE : EXIT_SUCCESS; } diff --git a/src/resolve/resolved-manager.c b/src/resolve/resolved-manager.c index 5be01d3cb8..645f2a824c 100644 --- a/src/resolve/resolved-manager.c +++ b/src/resolve/resolved-manager.c @@ -176,8 +176,7 @@ static int manager_process_address(sd_netlink *rtnl, sd_netlink_message *mm, voi break; case RTM_DELADDR: - if (a) - link_address_free(a); + link_address_free(a); break; } diff --git a/src/udev/udev-builtin-path_id.c b/src/udev/udev-builtin-path_id.c index aa5cda6fe7..f529ffcf25 100644 --- a/src/udev/udev-builtin-path_id.c +++ b/src/udev/udev-builtin-path_id.c @@ -117,8 +117,7 @@ static struct udev_device *handle_scsi_fibre_channel(struct udev_device *parent, format_lun_number(parent, &lun); path_prepend(path, "fc-%s-%s", port, lun); - if (lun) - free(lun); + free(lun); out: udev_device_unref(fcdev); return parent; @@ -156,8 +155,7 @@ static struct udev_device *handle_scsi_sas_wide_port(struct udev_device *parent, format_lun_number(parent, &lun); path_prepend(path, "sas-%s-%s", sas_address, lun); - if (lun) - free(lun); + free(lun); out: udev_device_unref(sasdev); return parent; @@ -251,8 +249,7 @@ static struct udev_device *handle_scsi_sas(struct udev_device *parent, char **pa else path_prepend(path, "sas-phy%s-%s", phy_id, lun); - if (lun) - free(lun); + free(lun); out: udev_device_unref(target_sasdev); udev_device_unref(expander_sasdev); @@ -313,8 +310,7 @@ static struct udev_device *handle_scsi_iscsi(struct udev_device *parent, char ** format_lun_number(parent, &lun); path_prepend(path, "ip-%s:%s-iscsi-%s-%s", addr, port, target, lun); - if (lun) - free(lun); + free(lun); out: udev_device_unref(sessiondev); udev_device_unref(conndev); diff --git a/src/update-utmp/update-utmp.c b/src/update-utmp/update-utmp.c index ea9b0c9c84..61bcf02b2f 100644 --- a/src/update-utmp/update-utmp.c +++ b/src/update-utmp/update-utmp.c @@ -286,8 +286,6 @@ finish: audit_close(c.audit_fd); #endif - if (c.bus) - sd_bus_unref(c.bus); - + sd_bus_unref(c.bus); return r < 0 ? EXIT_FAILURE : EXIT_SUCCESS; } |