Bug #944: Deletion of unnecessary checks before a few calls of systemd functions

The following functions return immediately if a null pointer was passed.
* calendar_spec_free
* link_address_free
* manager_free
* sd_bus_unref
* sd_journal_close
* udev_monitor_unref
* udev_unref

It is therefore not needed that a function caller repeats a corresponding check.

This issue was fixed by using the software Coccinelle 1.0.1.
This commit is contained in:
Markus Elfring
2015-08-17 10:45:30 +02:00
parent dc4ebc0787
commit 3e044c492e
9 changed files with 14 additions and 32 deletions
+1 -2
View File
@@ -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;
}
+1 -4
View File
@@ -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);
}
}
+1 -2
View File
@@ -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);
+1 -2
View File
@@ -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);
}
+1 -3
View File
@@ -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;
}
+6 -12
View File
@@ -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);
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);
if (m->udev)
udev_unref(m->udev);
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;
}
+1 -2
View File
@@ -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;
}
+1 -2
View File
@@ -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;
}
+1 -3
View File
@@ -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;
}