diff options
author | Lennart Poettering <lennart@poettering.net> | 2016-11-03 13:59:20 -0600 |
---|---|---|
committer | GitHub <noreply@github.com> | 2016-11-03 13:59:20 -0600 |
commit | 493fd52f1ada36bfe63301d4bb50f7fd2b38c670 (patch) | |
tree | 19864f5568a2fe48181c1b3f33c46b4db36dd768 /src/core | |
parent | a1e2ef7ec912902d8142e7cb5830cbfb47dba86c (diff) | |
parent | 9aa2169eaeb20994fb2b0196c051cff52f57a93d (diff) |
Merge pull request #4510 from keszybz/tree-wide-cleanups
Tree wide cleanups
Diffstat (limited to 'src/core')
-rw-r--r-- | src/core/cgroup.c | 17 | ||||
-rw-r--r-- | src/core/dbus-execute.c | 2 | ||||
-rw-r--r-- | src/core/dbus-unit.c | 6 | ||||
-rw-r--r-- | src/core/device.c | 2 | ||||
-rw-r--r-- | src/core/execute.c | 10 | ||||
-rw-r--r-- | src/core/locale-setup.c | 2 | ||||
-rw-r--r-- | src/core/manager.c | 113 | ||||
-rw-r--r-- | src/core/namespace.c | 2 | ||||
-rw-r--r-- | src/core/service.c | 2 | ||||
-rw-r--r-- | src/core/timer.c | 4 | ||||
-rw-r--r-- | src/core/unit.c | 4 |
11 files changed, 83 insertions, 81 deletions
diff --git a/src/core/cgroup.c b/src/core/cgroup.c index 23a92f9651..bd6248406f 100644 --- a/src/core/cgroup.c +++ b/src/core/cgroup.c @@ -928,7 +928,7 @@ static void cgroup_context_apply(Unit *u, CGroupMask mask, ManagerState state) { } LIST_FOREACH(device_allow, a, c->device_allow) { - char acc[4]; + char acc[4], *val; unsigned k = 0; if (a->r) @@ -945,10 +945,10 @@ static void cgroup_context_apply(Unit *u, CGroupMask mask, ManagerState state) { if (startswith(a->path, "/dev/")) whitelist_device(path, a->path, acc); - else if (startswith(a->path, "block-")) - whitelist_major(path, a->path + 6, 'b', acc); - else if (startswith(a->path, "char-")) - whitelist_major(path, a->path + 5, 'c', acc); + else if ((val = startswith(a->path, "block-"))) + whitelist_major(path, val, 'b', acc); + else if ((val = startswith(a->path, "char-"))) + whitelist_major(path, val, 'c', acc); else log_unit_debug(u, "Ignoring device %s while writing cgroup attribute.", a->path); } @@ -1201,9 +1201,10 @@ char *unit_default_cgroup_path(Unit *u) { return NULL; if (slice) - return strjoin(u->manager->cgroup_root, "/", slice, "/", escaped, NULL); + return strjoin(u->manager->cgroup_root, "/", slice, "/", + escaped); else - return strjoin(u->manager->cgroup_root, "/", escaped, NULL); + return strjoin(u->manager->cgroup_root, "/", escaped); } int unit_set_cgroup_path(Unit *u, const char *path) { @@ -1643,7 +1644,7 @@ static int unit_watch_pids_in_path(Unit *u, const char *path) { while ((r = cg_read_subgroup(d, &fn)) > 0) { _cleanup_free_ char *p = NULL; - p = strjoin(path, "/", fn, NULL); + p = strjoin(path, "/", fn); free(fn); if (!p) diff --git a/src/core/dbus-execute.c b/src/core/dbus-execute.c index 1a7f770db1..03f23780c1 100644 --- a/src/core/dbus-execute.c +++ b/src/core/dbus-execute.c @@ -1368,7 +1368,7 @@ int bus_exec_context_set_transient_property( if (mode != UNIT_CHECK) { char *buf = NULL; - buf = strjoin(b ? "-" : "", path, NULL); + buf = strjoin(b ? "-" : "", path); if (!buf) return -ENOMEM; diff --git a/src/core/dbus-unit.c b/src/core/dbus-unit.c index 69e249c844..b6cb6e1350 100644 --- a/src/core/dbus-unit.c +++ b/src/core/dbus-unit.c @@ -481,7 +481,7 @@ int bus_unit_method_start_generic( return sd_bus_error_setf(error, SD_BUS_ERROR_INVALID_ARGS, "Job mode %s invalid", smode); if (reload_if_possible) - verb = strjoin("reload-or-", job_type_to_string(job_type), NULL); + verb = strjoin("reload-or-", job_type_to_string(job_type)); else verb = strdup(job_type_to_string(job_type)); if (!verb) @@ -984,7 +984,7 @@ static int append_cgroup(sd_bus_message *reply, const char *p, Set *pids) { if (r == 0) break; - j = strjoin(p, "/", g, NULL); + j = strjoin(p, "/", g); if (!j) return -ENOMEM; @@ -1363,7 +1363,7 @@ static int bus_unit_set_transient_property( if (r < 0) return r; - label = strjoin(name, "-", other, NULL); + label = strjoin(name, "-", other); if (!label) return -ENOMEM; diff --git a/src/core/device.c b/src/core/device.c index bd87a447cd..498351af11 100644 --- a/src/core/device.c +++ b/src/core/device.c @@ -239,7 +239,7 @@ static int device_update_description(Unit *u, struct udev_device *dev, const cha if (label) { _cleanup_free_ char *j; - j = strjoin(model, " ", label, NULL); + j = strjoin(model, " ", label); if (j) r = unit_set_description(u, j); else diff --git a/src/core/execute.c b/src/core/execute.c index f13ca30395..5bb23e2e4a 100644 --- a/src/core/execute.c +++ b/src/core/execute.c @@ -1603,7 +1603,7 @@ static int build_environment( if (!joined) return -ENOMEM; - x = strjoin("LISTEN_FDNAMES=", joined, NULL); + x = strjoin("LISTEN_FDNAMES=", joined); if (!x) return -ENOMEM; our_env[n_env++] = x; @@ -1710,7 +1710,7 @@ static int build_pass_environment(const ExecContext *c, char ***ret) { v = getenv(*i); if (!v) continue; - x = strjoin(*i, "=", v, NULL); + x = strjoin(*i, "=", v); if (!x) return -ENOMEM; if (!GREEDY_REALLOC(pass_env, n_bufsize, n_env + 2)) @@ -1924,7 +1924,7 @@ static int setup_runtime_directory( STRV_FOREACH(rt, context->runtime_directory) { _cleanup_free_ char *p; - p = strjoin(params->runtime_prefix, "/", *rt, NULL); + p = strjoin(params->runtime_prefix, "/", *rt); if (!p) return -ENOMEM; @@ -2000,7 +2000,7 @@ static int compile_read_write_paths( STRV_FOREACH(rt, context->runtime_directory) { char *s; - s = strjoin(params->runtime_prefix, "/", *rt, NULL); + s = strjoin(params->runtime_prefix, "/", *rt); if (!s) return -ENOMEM; @@ -3004,7 +3004,7 @@ int exec_context_destroy_runtime_directory(ExecContext *c, const char *runtime_p STRV_FOREACH(i, c->runtime_directory) { _cleanup_free_ char *p; - p = strjoin(runtime_prefix, "/", *i, NULL); + p = strjoin(runtime_prefix, "/", *i); if (!p) return -ENOMEM; diff --git a/src/core/locale-setup.c b/src/core/locale-setup.c index ccf61d29fb..fdd847ee8b 100644 --- a/src/core/locale-setup.c +++ b/src/core/locale-setup.c @@ -87,7 +87,7 @@ int locale_setup(char ***environment) { if (!variables[i]) continue; - s = strjoin(locale_variable_to_string(i), "=", variables[i], NULL); + s = strjoin(locale_variable_to_string(i), "=", variables[i]); if (!s) { r = -ENOMEM; goto finish; diff --git a/src/core/manager.c b/src/core/manager.c index ffccfdcd5e..52174eac07 100644 --- a/src/core/manager.c +++ b/src/core/manager.c @@ -1196,7 +1196,7 @@ static void manager_build_unit_path_cache(Manager *m) { FOREACH_DIRENT(de, d, r = -errno; goto fail) { char *p; - p = strjoin(streq(*i, "/") ? "" : *i, "/", de->d_name, NULL); + p = strjoin(streq(*i, "/") ? "" : *i, "/", de->d_name); if (!p) { r = -ENOMEM; goto fail; @@ -2565,6 +2565,7 @@ int manager_deserialize(Manager *m, FILE *f, FDSet *fds) { for (;;) { char line[LINE_MAX], *l; + const char *val; if (!fgets(line, sizeof(line), f)) { if (feof(f)) @@ -2581,63 +2582,63 @@ int manager_deserialize(Manager *m, FILE *f, FDSet *fds) { if (l[0] == 0) break; - if (startswith(l, "current-job-id=")) { + if ((val = startswith(l, "current-job-id="))) { uint32_t id; - if (safe_atou32(l+15, &id) < 0) - log_debug("Failed to parse current job id value %s", l+15); + if (safe_atou32(val, &id) < 0) + log_debug("Failed to parse current job id value %s", val); else m->current_job_id = MAX(m->current_job_id, id); - } else if (startswith(l, "n-installed-jobs=")) { + } else if ((val = startswith(l, "n-installed-jobs="))) { uint32_t n; - if (safe_atou32(l+17, &n) < 0) - log_debug("Failed to parse installed jobs counter %s", l+17); + if (safe_atou32(val, &n) < 0) + log_debug("Failed to parse installed jobs counter %s", val); else m->n_installed_jobs += n; - } else if (startswith(l, "n-failed-jobs=")) { + } else if ((val = startswith(l, "n-failed-jobs="))) { uint32_t n; - if (safe_atou32(l+14, &n) < 0) - log_debug("Failed to parse failed jobs counter %s", l+14); + if (safe_atou32(val, &n) < 0) + log_debug("Failed to parse failed jobs counter %s", val); else m->n_failed_jobs += n; - } else if (startswith(l, "taint-usr=")) { + } else if ((val = startswith(l, "taint-usr="))) { int b; - b = parse_boolean(l+10); + b = parse_boolean(val); if (b < 0) - log_debug("Failed to parse taint /usr flag %s", l+10); + log_debug("Failed to parse taint /usr flag %s", val); else m->taint_usr = m->taint_usr || b; - } else if (startswith(l, "firmware-timestamp=")) - dual_timestamp_deserialize(l+19, &m->firmware_timestamp); - else if (startswith(l, "loader-timestamp=")) - dual_timestamp_deserialize(l+17, &m->loader_timestamp); - else if (startswith(l, "kernel-timestamp=")) - dual_timestamp_deserialize(l+17, &m->kernel_timestamp); - else if (startswith(l, "initrd-timestamp=")) - dual_timestamp_deserialize(l+17, &m->initrd_timestamp); - else if (startswith(l, "userspace-timestamp=")) - dual_timestamp_deserialize(l+20, &m->userspace_timestamp); - else if (startswith(l, "finish-timestamp=")) - dual_timestamp_deserialize(l+17, &m->finish_timestamp); - else if (startswith(l, "security-start-timestamp=")) - dual_timestamp_deserialize(l+25, &m->security_start_timestamp); - else if (startswith(l, "security-finish-timestamp=")) - dual_timestamp_deserialize(l+26, &m->security_finish_timestamp); - else if (startswith(l, "generators-start-timestamp=")) - dual_timestamp_deserialize(l+27, &m->generators_start_timestamp); - else if (startswith(l, "generators-finish-timestamp=")) - dual_timestamp_deserialize(l+28, &m->generators_finish_timestamp); - else if (startswith(l, "units-load-start-timestamp=")) - dual_timestamp_deserialize(l+27, &m->units_load_start_timestamp); - else if (startswith(l, "units-load-finish-timestamp=")) - dual_timestamp_deserialize(l+28, &m->units_load_finish_timestamp); + } else if ((val = startswith(l, "firmware-timestamp="))) + dual_timestamp_deserialize(val, &m->firmware_timestamp); + else if ((val = startswith(l, "loader-timestamp="))) + dual_timestamp_deserialize(val, &m->loader_timestamp); + else if ((val = startswith(l, "kernel-timestamp="))) + dual_timestamp_deserialize(val, &m->kernel_timestamp); + else if ((val = startswith(l, "initrd-timestamp="))) + dual_timestamp_deserialize(val, &m->initrd_timestamp); + else if ((val = startswith(l, "userspace-timestamp="))) + dual_timestamp_deserialize(val, &m->userspace_timestamp); + else if ((val = startswith(l, "finish-timestamp="))) + dual_timestamp_deserialize(val, &m->finish_timestamp); + else if ((val = startswith(l, "security-start-timestamp="))) + dual_timestamp_deserialize(val, &m->security_start_timestamp); + else if ((val = startswith(l, "security-finish-timestamp="))) + dual_timestamp_deserialize(val, &m->security_finish_timestamp); + else if ((val = startswith(l, "generators-start-timestamp="))) + dual_timestamp_deserialize(val, &m->generators_start_timestamp); + else if ((val = startswith(l, "generators-finish-timestamp="))) + dual_timestamp_deserialize(val, &m->generators_finish_timestamp); + else if ((val = startswith(l, "units-load-start-timestamp="))) + dual_timestamp_deserialize(val, &m->units_load_start_timestamp); + else if ((val = startswith(l, "units-load-finish-timestamp="))) + dual_timestamp_deserialize(val, &m->units_load_finish_timestamp); else if (startswith(l, "env=")) { _cleanup_free_ char *uce = NULL; char **e; @@ -2655,21 +2656,21 @@ int manager_deserialize(Manager *m, FILE *f, FDSet *fds) { strv_free(m->environment); m->environment = e; - } else if (startswith(l, "notify-fd=")) { + } else if ((val = startswith(l, "notify-fd="))) { int fd; - if (safe_atoi(l + 10, &fd) < 0 || fd < 0 || !fdset_contains(fds, fd)) - log_debug("Failed to parse notify fd: %s", l + 10); + if (safe_atoi(val, &fd) < 0 || fd < 0 || !fdset_contains(fds, fd)) + log_debug("Failed to parse notify fd: %s", val); else { m->notify_event_source = sd_event_source_unref(m->notify_event_source); safe_close(m->notify_fd); m->notify_fd = fdset_remove(fds, fd); } - } else if (startswith(l, "notify-socket=")) { + } else if ((val = startswith(l, "notify-socket="))) { char *n; - n = strdup(l+14); + n = strdup(val); if (!n) { r = -ENOMEM; goto finish; @@ -2678,22 +2679,22 @@ int manager_deserialize(Manager *m, FILE *f, FDSet *fds) { free(m->notify_socket); m->notify_socket = n; - } else if (startswith(l, "cgroups-agent-fd=")) { + } else if ((val = startswith(l, "cgroups-agent-fd="))) { int fd; - if (safe_atoi(l + 17, &fd) < 0 || fd < 0 || !fdset_contains(fds, fd)) - log_debug("Failed to parse cgroups agent fd: %s", l + 10); + if (safe_atoi(val, &fd) < 0 || fd < 0 || !fdset_contains(fds, fd)) + log_debug("Failed to parse cgroups agent fd: %s", val); else { m->cgroups_agent_event_source = sd_event_source_unref(m->cgroups_agent_event_source); safe_close(m->cgroups_agent_fd); m->cgroups_agent_fd = fdset_remove(fds, fd); } - } else if (startswith(l, "user-lookup=")) { + } else if ((val = startswith(l, "user-lookup="))) { int fd0, fd1; - if (sscanf(l + 12, "%i %i", &fd0, &fd1) != 2 || fd0 < 0 || fd1 < 0 || fd0 == fd1 || !fdset_contains(fds, fd0) || !fdset_contains(fds, fd1)) - log_debug("Failed to parse user lookup fd: %s", l + 12); + if (sscanf(val, "%i %i", &fd0, &fd1) != 2 || fd0 < 0 || fd1 < 0 || fd0 == fd1 || !fdset_contains(fds, fd0) || !fdset_contains(fds, fd1)) + log_debug("Failed to parse user lookup fd: %s", val); else { m->user_lookup_event_source = sd_event_source_unref(m->user_lookup_event_source); safe_close_pair(m->user_lookup_fds); @@ -2701,15 +2702,15 @@ int manager_deserialize(Manager *m, FILE *f, FDSet *fds) { m->user_lookup_fds[1] = fdset_remove(fds, fd1); } - } else if (startswith(l, "dynamic-user=")) - dynamic_user_deserialize_one(m, l + 13, fds); - else if (startswith(l, "destroy-ipc-uid=")) - manager_deserialize_uid_refs_one(m, l + 16); - else if (startswith(l, "destroy-ipc-gid=")) - manager_deserialize_gid_refs_one(m, l + 16); - else if (startswith(l, "subscribed=")) { + } else if ((val = startswith(l, "dynamic-user="))) + dynamic_user_deserialize_one(m, val, fds); + else if ((val = startswith(l, "destroy-ipc-uid="))) + manager_deserialize_uid_refs_one(m, val); + else if ((val = startswith(l, "destroy-ipc-gid="))) + manager_deserialize_gid_refs_one(m, val); + else if ((val = startswith(l, "subscribed="))) { - if (strv_extend(&m->deserialized_subscribed, l+11) < 0) + if (strv_extend(&m->deserialized_subscribed, val) < 0) log_oom(); } else if (!startswith(l, "kdbus-fd=")) /* ignore this one */ diff --git a/src/core/namespace.c b/src/core/namespace.c index 1195e9a854..db9a7aa5e7 100644 --- a/src/core/namespace.c +++ b/src/core/namespace.c @@ -909,7 +909,7 @@ static int setup_one_tmp_dir(const char *id, const char *prefix, char **path) { if (r < 0) return r; - x = strjoin(prefix, "/systemd-private-", sd_id128_to_string(boot_id, bid), "-", id, "-XXXXXX", NULL); + x = strjoin(prefix, "/systemd-private-", sd_id128_to_string(boot_id, bid), "-", id, "-XXXXXX"); if (!x) return -ENOMEM; diff --git a/src/core/service.c b/src/core/service.c index a7274a758f..f6acc2f129 100644 --- a/src/core/service.c +++ b/src/core/service.c @@ -3273,7 +3273,7 @@ int service_set_socket_fd(Service *s, int fd, Socket *sock, bool selinux_context if (UNIT(s)->description) { _cleanup_free_ char *a; - a = strjoin(UNIT(s)->description, " (", peer, ")", NULL); + a = strjoin(UNIT(s)->description, " (", peer, ")"); if (!a) return -ENOMEM; diff --git a/src/core/timer.c b/src/core/timer.c index 2469a517ea..c6b28dd9c5 100644 --- a/src/core/timer.c +++ b/src/core/timer.c @@ -147,7 +147,7 @@ static int timer_setup_persistent(Timer *t) { e = getenv("XDG_DATA_HOME"); if (e) - t->stamp_path = strjoin(e, "/systemd/timers/stamp-", UNIT(t)->id, NULL); + t->stamp_path = strjoin(e, "/systemd/timers/stamp-", UNIT(t)->id); else { _cleanup_free_ char *h = NULL; @@ -156,7 +156,7 @@ static int timer_setup_persistent(Timer *t) { if (r < 0) return log_unit_error_errno(UNIT(t), r, "Failed to determine home directory: %m"); - t->stamp_path = strjoin(h, "/.local/share/systemd/timers/stamp-", UNIT(t)->id, NULL); + t->stamp_path = strjoin(h, "/.local/share/systemd/timers/stamp-", UNIT(t)->id); } } diff --git a/src/core/unit.c b/src/core/unit.c index e664e23892..fa1f3d9d4b 100644 --- a/src/core/unit.c +++ b/src/core/unit.c @@ -2510,7 +2510,7 @@ int unit_set_default_slice(Unit *u) { return -ENOMEM; if (MANAGER_IS_SYSTEM(u->manager)) - b = strjoin("system-", escaped, ".slice", NULL); + b = strjoin("system-", escaped, ".slice"); else b = strappend(escaped, ".slice"); if (!b) @@ -3670,7 +3670,7 @@ int unit_make_transient(Unit *u) { if (!UNIT_VTABLE(u)->can_transient) return -EOPNOTSUPP; - path = strjoin(u->manager->lookup_paths.transient, "/", u->id, NULL); + path = strjoin(u->manager->lookup_paths.transient, "/", u->id); if (!path) return -ENOMEM; |