summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
Diffstat (limited to 'src')
-rw-r--r--src/core/execute.c2
-rw-r--r--src/core/execute.h1
-rw-r--r--src/core/job.c2
-rw-r--r--src/core/job.h2
-rw-r--r--src/core/manager.c51
-rw-r--r--src/core/manager.h4
-rw-r--r--src/core/unit.c100
-rw-r--r--src/core/unit.h5
-rw-r--r--src/journal/journal-file.c2
-rw-r--r--src/journal/journal-file.h1
-rw-r--r--src/libsystemd-bus/bus-bloom.c2
-rw-r--r--src/libsystemd-bus/bus-bloom.h1
-rw-r--r--src/login/logind-device.c24
-rw-r--r--src/login/logind-device.h1
-rw-r--r--src/login/logind.c12
-rw-r--r--src/login/logind.h7
-rw-r--r--src/shared/cgroup-util.c137
-rw-r--r--src/shared/cgroup-util.h7
-rw-r--r--src/shared/conf-parser.c31
-rw-r--r--src/shared/conf-parser.h1
-rw-r--r--src/shared/util.c21
-rw-r--r--src/udev/udev-builtin-net_setup_link.c2
22 files changed, 98 insertions, 318 deletions
diff --git a/src/core/execute.c b/src/core/execute.c
index 3ae28ee080..1e571da69c 100644
--- a/src/core/execute.c
+++ b/src/core/execute.c
@@ -155,7 +155,7 @@ _pure_ static const char *tty_path(const ExecContext *context) {
return "/dev/console";
}
-void exec_context_tty_reset(const ExecContext *context) {
+static void exec_context_tty_reset(const ExecContext *context) {
assert(context);
if (context->tty_vhangup)
diff --git a/src/core/execute.h b/src/core/execute.h
index c1e9717dc8..368c9f00bb 100644
--- a/src/core/execute.h
+++ b/src/core/execute.h
@@ -194,7 +194,6 @@ void exec_context_init(ExecContext *c);
void exec_context_done(ExecContext *c, bool reloading_or_reexecuting);
void exec_context_tmp_dirs_done(ExecContext *c);
void exec_context_dump(ExecContext *c, FILE* f, const char *prefix);
-void exec_context_tty_reset(const ExecContext *context);
int exec_context_load_environment(const ExecContext *c, char ***l);
diff --git a/src/core/job.c b/src/core/job.c
index e5dcef7cf4..fc446fbc42 100644
--- a/src/core/job.c
+++ b/src/core/job.c
@@ -416,7 +416,7 @@ int job_type_merge_and_collapse(JobType *a, JobType b, Unit *u) {
return 0;
}
-bool job_is_runnable(Job *j) {
+static bool job_is_runnable(Job *j) {
Iterator i;
Unit *other;
diff --git a/src/core/job.h b/src/core/job.h
index d90bc96b76..be9d278b0c 100644
--- a/src/core/job.h
+++ b/src/core/job.h
@@ -206,8 +206,6 @@ void job_type_collapse(JobType *t, Unit *u);
int job_type_merge_and_collapse(JobType *a, JobType b, Unit *u);
-bool job_is_runnable(Job *j);
-
void job_add_to_run_queue(Job *j);
void job_add_to_dbus_queue(Job *j);
diff --git a/src/core/manager.c b/src/core/manager.c
index c75c1e1a4e..07ca4c92f7 100644
--- a/src/core/manager.c
+++ b/src/core/manager.c
@@ -800,7 +800,7 @@ int manager_enumerate(Manager *m) {
return r;
}
-int manager_coldplug(Manager *m) {
+static int manager_coldplug(Manager *m) {
int r = 0, q;
Iterator i;
Unit *u;
@@ -880,6 +880,29 @@ fail:
m->unit_path_cache = NULL;
}
+
+static int manager_distribute_fds(Manager *m, FDSet *fds) {
+ Unit *u;
+ Iterator i;
+ int r;
+
+ assert(m);
+
+ HASHMAP_FOREACH(u, m->units, i) {
+
+ if (fdset_size(fds) <= 0)
+ break;
+
+ if (UNIT_VTABLE(u)->distribute_fds) {
+ r = UNIT_VTABLE(u)->distribute_fds(u, fds);
+ if (r < 0)
+ return r;
+ }
+ }
+
+ return 0;
+}
+
int manager_startup(Manager *m, FILE *serialization, FDSet *fds) {
int r, q;
@@ -1187,7 +1210,7 @@ void manager_clear_jobs(Manager *m) {
job_finish_and_invalidate(j, JOB_CANCELED, false);
}
-unsigned manager_dispatch_run_queue(Manager *m) {
+static unsigned manager_dispatch_run_queue(Manager *m) {
Job *j;
unsigned n = 0;
@@ -1215,7 +1238,7 @@ unsigned manager_dispatch_run_queue(Manager *m) {
return n;
}
-unsigned manager_dispatch_dbus_queue(Manager *m) {
+static unsigned manager_dispatch_dbus_queue(Manager *m) {
Job *j;
Unit *u;
unsigned n = 0;
@@ -2298,28 +2321,6 @@ finish:
return r;
}
-int manager_distribute_fds(Manager *m, FDSet *fds) {
- Unit *u;
- Iterator i;
- int r;
-
- assert(m);
-
- HASHMAP_FOREACH(u, m->units, i) {
-
- if (fdset_size(fds) <= 0)
- break;
-
- if (UNIT_VTABLE(u)->distribute_fds) {
- r = UNIT_VTABLE(u)->distribute_fds(u, fds);
- if (r < 0)
- return r;
- }
- }
-
- return 0;
-}
-
int manager_reload(Manager *m) {
int r, q;
_cleanup_fclose_ FILE *f = NULL;
diff --git a/src/core/manager.h b/src/core/manager.h
index f83c008a2e..150525ee13 100644
--- a/src/core/manager.h
+++ b/src/core/manager.h
@@ -265,7 +265,6 @@ int manager_new(SystemdRunningAs running_as, bool reexecuting, Manager **m);
void manager_free(Manager *m);
int manager_enumerate(Manager *m);
-int manager_coldplug(Manager *m);
int manager_startup(Manager *m, FILE *serialization, FDSet *fds);
Job *manager_get_job(Manager *m, uint32_t id);
@@ -288,8 +287,6 @@ void manager_dump_jobs(Manager *s, FILE *f, const char *prefix);
void manager_clear_jobs(Manager *m);
unsigned manager_dispatch_load_queue(Manager *m);
-unsigned manager_dispatch_run_queue(Manager *m);
-unsigned manager_dispatch_dbus_queue(Manager *m);
int manager_environment_add(Manager *m, char **environment);
int manager_set_default_rlimits(Manager *m, struct rlimit **default_rlimit);
@@ -303,7 +300,6 @@ int manager_open_serialization(Manager *m, FILE **_f);
int manager_serialize(Manager *m, FILE *f, FDSet *fds, bool switching_root);
int manager_deserialize(Manager *m, FILE *f, FDSet *fds);
-int manager_distribute_fds(Manager *m, FDSet *fds);
int manager_reload(Manager *m);
diff --git a/src/core/unit.c b/src/core/unit.c
index e19d281aa7..201329fc86 100644
--- a/src/core/unit.c
+++ b/src/core/unit.c
@@ -946,6 +946,44 @@ static int unit_add_default_dependencies(Unit *u) {
return 0;
}
+static int unit_add_mount_links(Unit *u) {
+ char **i;
+ int r;
+
+ assert(u);
+
+ STRV_FOREACH(i, u->requires_mounts_for) {
+ char prefix[strlen(*i) + 1];
+
+ PATH_FOREACH_PREFIX_MORE(prefix, *i) {
+ Unit *m;
+
+ r = manager_get_unit_by_path(u->manager, prefix, ".mount", &m);
+ if (r < 0)
+ return r;
+ if (r == 0)
+ continue;
+ if (m == u)
+ continue;
+
+ if (m->load_state != UNIT_LOADED)
+ continue;
+
+ r = unit_add_dependency(u, UNIT_AFTER, m, true);
+ if (r < 0)
+ return r;
+
+ if (m->fragment_path) {
+ r = unit_add_dependency(u, UNIT_REQUIRES, m, true);
+ if (r < 0)
+ return r;
+ }
+ }
+ }
+
+ return 0;
+}
+
int unit_load(Unit *u) {
int r;
@@ -1015,7 +1053,7 @@ fail:
return r;
}
-bool unit_condition_test(Unit *u) {
+static bool unit_condition_test(Unit *u) {
assert(u);
dual_timestamp_get(&u->condition_timestamp);
@@ -2118,28 +2156,6 @@ int unit_load_related_unit(Unit *u, const char *type, Unit **_found) {
return r;
}
-int unit_get_related_unit(Unit *u, const char *type, Unit **_found) {
- _cleanup_free_ char *t = NULL;
- Unit *found;
-
- assert(u);
- assert(type);
- assert(_found);
-
- t = unit_name_change_suffix(u->id, type);
- if (!t)
- return -ENOMEM;
-
- assert(!unit_has_name(u, t));
-
- found = manager_get_unit(u->manager, t);
- if (!found)
- return -ENOENT;
-
- *_found = found;
- return 0;
-}
-
int unit_watch_bus_name(Unit *u, const char *name) {
assert(u);
assert(name);
@@ -2684,44 +2700,6 @@ void unit_ref_unset(UnitRef *ref) {
ref->unit = NULL;
}
-int unit_add_mount_links(Unit *u) {
- char **i;
- int r;
-
- assert(u);
-
- STRV_FOREACH(i, u->requires_mounts_for) {
- char prefix[strlen(*i) + 1];
-
- PATH_FOREACH_PREFIX_MORE(prefix, *i) {
- Unit *m;
-
- r = manager_get_unit_by_path(u->manager, prefix, ".mount", &m);
- if (r < 0)
- return r;
- if (r == 0)
- continue;
- if (m == u)
- continue;
-
- if (m->load_state != UNIT_LOADED)
- continue;
-
- r = unit_add_dependency(u, UNIT_AFTER, m, true);
- if (r < 0)
- return r;
-
- if (m->fragment_path) {
- r = unit_add_dependency(u, UNIT_REQUIRES, m, true);
- if (r < 0)
- return r;
- }
- }
- }
-
- return 0;
-}
-
int unit_exec_context_defaults(Unit *u, ExecContext *c) {
unsigned i;
int r;
diff --git a/src/core/unit.h b/src/core/unit.h
index 6971048a9b..1a558423f7 100644
--- a/src/core/unit.h
+++ b/src/core/unit.h
@@ -545,7 +545,6 @@ int set_unit_path(const char *p);
char *unit_dbus_path(Unit *u);
int unit_load_related_unit(Unit *u, const char *type, Unit **_found);
-int unit_get_related_unit(Unit *u, const char *type, Unit **_found);
bool unit_can_serialize(Unit *u) _pure_;
int unit_serialize(Unit *u, FILE *f, FDSet *fds, bool serialize_jobs);
@@ -580,8 +579,6 @@ int unit_following_set(Unit *u, Set **s);
void unit_start_on_failure(Unit *u);
void unit_trigger_notify(Unit *u);
-bool unit_condition_test(Unit *u);
-
UnitFileState unit_get_unit_file_state(Unit *u);
Unit* unit_ref_set(UnitRef *ref, Unit *u);
@@ -590,8 +587,6 @@ void unit_ref_unset(UnitRef *ref);
#define UNIT_DEREF(ref) ((ref).unit)
#define UNIT_ISSET(ref) (!!(ref).unit)
-int unit_add_mount_links(Unit *u);
-
int unit_exec_context_defaults(Unit *u, ExecContext *c);
ExecContext *unit_get_exec_context(Unit *u) _pure_;
diff --git a/src/journal/journal-file.c b/src/journal/journal-file.c
index 901e71b6aa..bc72fca725 100644
--- a/src/journal/journal-file.c
+++ b/src/journal/journal-file.c
@@ -68,7 +68,7 @@
/* How many entries to keep in the entry array chain cache at max */
#define CHAIN_CACHE_MAX 20
-int journal_file_set_online(JournalFile *f) {
+static int journal_file_set_online(JournalFile *f) {
assert(f);
if (!f->writable)
diff --git a/src/journal/journal-file.h b/src/journal/journal-file.h
index 5cc2c2d28d..773ece07e8 100644
--- a/src/journal/journal-file.h
+++ b/src/journal/journal-file.h
@@ -111,7 +111,6 @@ int journal_file_open(
JournalFile **ret);
int journal_file_set_offline(JournalFile *f);
-int journal_file_set_online(JournalFile *f);
void journal_file_close(JournalFile *j);
int journal_file_open_reliably(
diff --git a/src/libsystemd-bus/bus-bloom.c b/src/libsystemd-bus/bus-bloom.c
index 04bee8581e..c3ad9f6385 100644
--- a/src/libsystemd-bus/bus-bloom.c
+++ b/src/libsystemd-bus/bus-bloom.c
@@ -28,7 +28,7 @@ static inline void set_bit(uint64_t filter[], unsigned b) {
filter[b >> 6] |= 1ULL << (b & 63);
}
-void bloom_add_data(uint64_t filter[BLOOM_SIZE/8], const void *data, size_t n) {
+static void bloom_add_data(uint64_t filter[BLOOM_SIZE/8], const void *data, size_t n) {
uint16_t hash[8];
unsigned k = 0;
diff --git a/src/libsystemd-bus/bus-bloom.h b/src/libsystemd-bus/bus-bloom.h
index 1bf14a3331..422eb4e01a 100644
--- a/src/libsystemd-bus/bus-bloom.h
+++ b/src/libsystemd-bus/bus-bloom.h
@@ -25,6 +25,5 @@
#define BLOOM_SIZE 64
-void bloom_add_data(uint64_t filter[BLOOM_SIZE/8], const void *data, size_t n);
void bloom_add_pair(uint64_t filter[BLOOM_SIZE/8], const char *a, const char *b);
void bloom_add_prefixes(uint64_t filter[BLOOM_SIZE/8], const char *a, const char *b, char sep);
diff --git a/src/login/logind-device.c b/src/login/logind-device.c
index c5fe92bd60..76c5a5c88f 100644
--- a/src/login/logind-device.c
+++ b/src/login/logind-device.c
@@ -54,18 +54,7 @@ Device* device_new(Manager *m, const char *sysfs, bool master) {
return d;
}
-void device_free(Device *d) {
- assert(d);
-
- device_detach(d);
-
- hashmap_remove(d->manager->devices, d->sysfs);
-
- free(d->sysfs);
- free(d);
-}
-
-void device_detach(Device *d) {
+static void device_detach(Device *d) {
Seat *s;
SessionDevice *sd;
@@ -87,6 +76,17 @@ void device_detach(Device *d) {
}
}
+void device_free(Device *d) {
+ assert(d);
+
+ device_detach(d);
+
+ hashmap_remove(d->manager->devices, d->sysfs);
+
+ free(d->sysfs);
+ free(d);
+}
+
void device_attach(Device *d, Seat *s) {
Device *i;
bool had_master;
diff --git a/src/login/logind-device.h b/src/login/logind-device.h
index fa6eda7e55..c273d2bfa0 100644
--- a/src/login/logind-device.h
+++ b/src/login/logind-device.h
@@ -45,4 +45,3 @@ struct Device {
Device* device_new(Manager *m, const char *sysfs, bool master);
void device_free(Device *d);
void device_attach(Device *d, Seat *s);
-void device_detach(Device *d);
diff --git a/src/login/logind.c b/src/login/logind.c
index e334bebdf8..c4227f16b2 100644
--- a/src/login/logind.c
+++ b/src/login/logind.c
@@ -177,7 +177,7 @@ void manager_free(Manager *m) {
free(m);
}
-int manager_enumerate_devices(Manager *m) {
+static int manager_enumerate_devices(Manager *m) {
struct udev_list_entry *item = NULL, *first = NULL;
struct udev_enumerate *e;
int r;
@@ -226,7 +226,7 @@ finish:
return r;
}
-int manager_enumerate_buttons(Manager *m) {
+static int manager_enumerate_buttons(Manager *m) {
struct udev_list_entry *item = NULL, *first = NULL;
struct udev_enumerate *e;
int r;
@@ -284,7 +284,7 @@ finish:
return r;
}
-int manager_enumerate_seats(Manager *m) {
+static int manager_enumerate_seats(Manager *m) {
_cleanup_closedir_ DIR *d = NULL;
struct dirent *de;
int r = 0;
@@ -357,7 +357,7 @@ static int manager_enumerate_linger_users(Manager *m) {
return r;
}
-int manager_enumerate_users(Manager *m) {
+static int manager_enumerate_users(Manager *m) {
_cleanup_closedir_ DIR *d = NULL;
struct dirent *de;
int r, k;
@@ -401,7 +401,7 @@ int manager_enumerate_users(Manager *m) {
return r;
}
-int manager_enumerate_sessions(Manager *m) {
+static int manager_enumerate_sessions(Manager *m) {
_cleanup_closedir_ DIR *d = NULL;
struct dirent *de;
int r = 0;
@@ -449,7 +449,7 @@ int manager_enumerate_sessions(Manager *m) {
return r;
}
-int manager_enumerate_inhibitors(Manager *m) {
+static int manager_enumerate_inhibitors(Manager *m) {
_cleanup_closedir_ DIR *d = NULL;
struct dirent *de;
int r = 0;
diff --git a/src/login/logind.h b/src/login/logind.h
index 9a3b9a8320..5c04d0a828 100644
--- a/src/login/logind.h
+++ b/src/login/logind.h
@@ -135,13 +135,6 @@ int manager_add_inhibitor(Manager *m, const char* id, Inhibitor **_inhibitor);
int manager_process_seat_device(Manager *m, struct udev_device *d);
int manager_process_button_device(Manager *m, struct udev_device *d);
-int manager_enumerate_devices(Manager *m);
-int manager_enumerate_buttons(Manager *m);
-int manager_enumerate_seats(Manager *m);
-int manager_enumerate_sessions(Manager *m);
-int manager_enumerate_users(Manager *m);
-int manager_enumerate_inhibitors(Manager *m);
-
int manager_startup(Manager *m);
int manager_run(Manager *m);
int manager_spawn_autovt(Manager *m, int vtnr);
diff --git a/src/shared/cgroup-util.c b/src/shared/cgroup-util.c
index 8a4eddab7a..4e0211a7a0 100644
--- a/src/shared/cgroup-util.c
+++ b/src/shared/cgroup-util.c
@@ -279,37 +279,6 @@ int cg_kill_recursive(const char *controller, const char *path, int sig, bool si
return ret;
}
-int cg_kill_recursive_and_wait(const char *controller, const char *path, bool rem) {
- unsigned i;
-
- assert(path);
-
- /* This safely kills all processes; first it sends a SIGTERM,
- * then checks 8 times after 200ms whether the group is now
- * empty, then kills everything that is left with SIGKILL and
- * finally checks 5 times after 200ms each whether the group
- * is finally empty. */
-
- for (i = 0; i < 15; i++) {
- int sig, r;
-
- if (i <= 0)
- sig = SIGTERM;
- else if (i == 9)
- sig = SIGKILL;
- else
- sig = 0;
-
- r = cg_kill_recursive(controller, path, sig, true, true, rem, NULL);
- if (r <= 0)
- return r;
-
- usleep(200 * USEC_PER_MSEC);
- }
-
- return 0;
-}
-
int cg_migrate(const char *cfrom, const char *pfrom, const char *cto, const char *pto, bool ignore_self) {
bool done = false;
_cleanup_set_free_ Set *s = NULL;
@@ -941,19 +910,6 @@ int cg_is_empty(const char *controller, const char *path, bool ignore_self) {
return !found;
}
-int cg_is_empty_by_spec(const char *spec, bool ignore_self) {
- _cleanup_free_ char *controller = NULL, *path = NULL;
- int r;
-
- assert(spec);
-
- r = cg_split_spec(spec, &controller, &path);
- if (r < 0)
- return r;
-
- return cg_is_empty(controller, path, ignore_self);
-}
-
int cg_is_empty_recursive(const char *controller, const char *path, bool ignore_self) {
_cleanup_closedir_ DIR *d = NULL;
char *fn;
@@ -1080,33 +1036,6 @@ int cg_split_spec(const char *spec, char **controller, char **path) {
return 0;
}
-int cg_join_spec(const char *controller, const char *path, char **spec) {
- char *s;
-
- assert(path);
-
- if (!controller)
- controller = "systemd";
- else {
- if (!cg_controller_is_valid(controller, true))
- return -EINVAL;
-
- controller = normalize_controller(controller);
- }
-
- if (!path_is_absolute(path))
- return -EINVAL;
-
- s = strjoin(controller, ":", path, NULL);
- if (!s)
- return -ENOMEM;
-
- path_kill_slashes(s + strlen(controller) + 1);
-
- *spec = s;
- return 0;
-}
-
int cg_mangle_path(const char *path, char **result) {
_cleanup_free_ char *c = NULL, *p = NULL;
char *t;
@@ -1153,43 +1082,6 @@ int cg_get_root_path(char **path) {
return 0;
}
-char **cg_shorten_controllers(char **controllers) {
- char **f, **t;
-
- if (!controllers)
- return controllers;
-
- for (f = controllers, t = controllers; *f; f++) {
- const char *p;
- int r;
-
- p = normalize_controller(*f);
-
- if (streq(p, "systemd")) {
- free(*f);
- continue;
- }
-
- if (!cg_controller_is_valid(p, true)) {
- log_warning("Controller %s is not valid, removing from controllers list.", p);
- free(*f);
- continue;
- }
-
- r = check_hierarchy(p);
- if (r < 0) {
- log_debug("Controller %s is not available, removing from controllers list.", p);
- free(*f);
- continue;
- }
-
- *(t++) = *f;
- }
-
- *t = NULL;
- return strv_uniq(controllers);
-}
-
int cg_pid_get_path_shifted(pid_t pid, char **root, char **cgroup) {
_cleanup_free_ char *cg_root = NULL;
char *cg_process, *p;
@@ -1529,35 +1421,6 @@ int cg_pid_get_slice(pid_t pid, char **slice) {
return cg_path_get_slice(cgroup, slice);
}
-int cg_controller_from_attr(const char *attr, char **controller) {
- const char *dot;
- char *c;
-
- assert(attr);
- assert(controller);
-
- if (!filename_is_safe(attr))
- return -EINVAL;
-
- dot = strchr(attr, '.');
- if (!dot) {
- *controller = NULL;
- return 0;
- }
-
- c = strndup(attr, dot - attr);
- if (!c)
- return -ENOMEM;
-
- if (!cg_controller_is_valid(c, false)) {
- free(c);
- return -EINVAL;
- }
-
- *controller = c;
- return 1;
-}
-
char *cg_escape(const char *p) {
bool need_prefix = false;
diff --git a/src/shared/cgroup-util.h b/src/shared/cgroup-util.h
index 0963450b08..b64457300a 100644
--- a/src/shared/cgroup-util.h
+++ b/src/shared/cgroup-util.h
@@ -60,14 +60,12 @@ int cg_read_subgroup(DIR *d, char **fn);
int cg_kill(const char *controller, const char *path, int sig, bool sigcont, bool ignore_self, Set *s);
int cg_kill_recursive(const char *controller, const char *path, int sig, bool sigcont, bool ignore_self, bool remove, Set *s);
-int cg_kill_recursive_and_wait(const char *controller, const char *path, bool remove);
int cg_migrate(const char *cfrom, const char *pfrom, const char *cto, const char *pto, bool ignore_self);
int cg_migrate_recursive(const char *cfrom, const char *pfrom, const char *cto, const char *pto, bool ignore_self, bool remove);
int cg_migrate_recursive_fallback(const char *cfrom, const char *pfrom, const char *cto, const char *pto, bool ignore_self, bool rem);
int cg_split_spec(const char *spec, char **controller, char **path);
-int cg_join_spec(const char *controller, const char *path, char **spec);
int cg_mangle_path(const char *path, char **result);
int cg_get_path(const char *controller, const char *path, const char *suffix, char **fs);
@@ -94,7 +92,6 @@ int cg_install_release_agent(const char *controller, const char *agent);
int cg_uninstall_release_agent(const char *controller);
int cg_is_empty(const char *controller, const char *path, bool ignore_self);
-int cg_is_empty_by_spec(const char *spec, bool ignore_self);
int cg_is_empty_recursive(const char *controller, const char *path, bool ignore_self);
int cg_get_root_path(char **path);
@@ -117,10 +114,6 @@ int cg_pid_get_slice(pid_t pid, char **slice);
int cg_path_decode_unit(const char *cgroup, char **unit);
-char **cg_shorten_controllers(char **controllers);
-
-int cg_controller_from_attr(const char *attr, char **controller);
-
char *cg_escape(const char *p);
char *cg_unescape(const char *p) _pure_;
diff --git a/src/shared/conf-parser.c b/src/shared/conf-parser.c
index 16c3c71eae..efd2147e79 100644
--- a/src/shared/conf-parser.c
+++ b/src/shared/conf-parser.c
@@ -517,37 +517,6 @@ int config_parse_bool(const char* unit,
return 0;
}
-int config_parse_tristate(const char *unit,
- const char *filename,
- unsigned line,
- const char *section,
- const char *lvalue,
- int ltype,
- const char *rvalue,
- void *data,
- void *userdata) {
-
- int k;
- int *b = data;
-
- assert(filename);
- assert(lvalue);
- assert(rvalue);
- assert(data);
-
- /* Tristates are like booleans, but can also take the 'default' value, i.e. "-1" */
-
- k = parse_boolean(rvalue);
- if (k < 0) {
- log_syntax(unit, LOG_ERR, filename, line, -k,
- "Failed to parse boolean value, ignoring: %s", rvalue);
- return 0;
- }
-
- *b = !!k;
- return 0;
-}
-
int config_parse_string(const char *unit,
const char *filename,
unsigned line,
diff --git a/src/shared/conf-parser.h b/src/shared/conf-parser.h
index f988e1c443..312315b35e 100644
--- a/src/shared/conf-parser.h
+++ b/src/shared/conf-parser.h
@@ -99,7 +99,6 @@ int config_parse_double(const char *unit, const char *filename, unsigned line, c
int config_parse_bytes_size(const char *unit, const char *filename, unsigned line, const char *section, const char *lvalue, int ltype, const char *rvalue, void *data, void *userdata);
int config_parse_bytes_off(const char *unit, const char *filename, unsigned line, const char *section, const char *lvalue, int ltype, const char *rvalue, void *data, void *userdata);
int config_parse_bool(const char *unit, const char *filename, unsigned line, const char *section, const char *lvalue, int ltype, const char *rvalue, void *data, void *userdata);
-int config_parse_tristate(const char *unit, const char *filename, unsigned line, const char *section, const char *lvalue, int ltype, const char *rvalue, void *data, void *userdata);
int config_parse_string(const char *unit, const char *filename, unsigned line, const char *section, const char *lvalue, int ltype, const char *rvalue, void *data, void *userdata);
int config_parse_path(const char *unit, const char *filename, unsigned line, const char *section, const char *lvalue, int ltype, const char *rvalue, void *data, void *userdata);
int config_parse_strv(const char *unit, const char *filename, unsigned line, const char *section, const char *lvalue, int ltype, const char *rvalue, void *data, void *userdata);
diff --git a/src/shared/util.c b/src/shared/util.c
index 7d41a7ae8d..a6669c5a97 100644
--- a/src/shared/util.c
+++ b/src/shared/util.c
@@ -2924,11 +2924,13 @@ int fchmod_and_fchown(int fd, mode_t mode, uid_t uid, gid_t gid) {
* first change the access mode and only then hand out
* ownership to avoid a window where access is too open. */
- if (fchmod(fd, mode) < 0)
- return -errno;
+ if (mode != (mode_t) -1)
+ if (fchmod(fd, mode) < 0)
+ return -errno;
- if (fchown(fd, uid, gid) < 0)
- return -errno;
+ if (uid != (uid_t) -1 || gid != (gid_t) -1)
+ if (fchown(fd, uid, gid) < 0)
+ return -errno;
return 0;
}
@@ -3040,13 +3042,14 @@ int status_printf(const char *status, bool ellipse, bool ephemeral, const char *
}
int status_welcome(void) {
- int r;
_cleanup_free_ char *pretty_name = NULL, *ansi_color = NULL;
+ int r;
r = parse_env_file("/etc/os-release", NEWLINE,
"PRETTY_NAME", &pretty_name,
"ANSI_COLOR", &ansi_color,
NULL);
+
if (r < 0 && r != -ENOENT)
log_warning("Failed to read /etc/os-release: %s", strerror(-r));
@@ -3700,8 +3703,7 @@ char *resolve_dev_console(char **active) {
}
bool tty_is_vc_resolve(const char *tty) {
- char *active = NULL;
- bool b;
+ _cleanup_free_ char *active = NULL;
assert(tty);
@@ -3714,10 +3716,7 @@ bool tty_is_vc_resolve(const char *tty) {
return false;
}
- b = tty_is_vc(tty);
- free(active);
-
- return b;
+ return tty_is_vc(tty);
}
const char *default_term_for_tty(const char *tty) {
diff --git a/src/udev/udev-builtin-net_setup_link.c b/src/udev/udev-builtin-net_setup_link.c
index e6ffa53400..b7ba8c9060 100644
--- a/src/udev/udev-builtin-net_setup_link.c
+++ b/src/udev/udev-builtin-net_setup_link.c
@@ -23,7 +23,7 @@
#include "udev.h"
#include "log.h"
-link_config_ctx *ctx;
+static link_config_ctx *ctx = NULL;
static int builtin_net_setup_link(struct udev_device *dev, int argc, char **argv, bool test) {
const char *name;