1
0
mirror of https://github.com/systemd/systemd.git synced 2024-11-08 11:27:32 +03:00

core: remove set_default_unit()

The new free_and_strdup() call does pretty much the same thing these
days, no need to keep a private limited purpose version around.
This commit is contained in:
Lennart Poettering 2015-09-23 01:14:34 +02:00
parent 48b9085914
commit e6e242ad2d

View File

@ -254,21 +254,6 @@ static int console_setup(void) {
return 0; return 0;
} }
static int set_default_unit(const char *u) {
char *c;
assert(u);
c = strdup(u);
if (!c)
return -ENOMEM;
free(arg_default_unit);
arg_default_unit = c;
return 0;
}
static int parse_proc_cmdline_item(const char *key, const char *value) { static int parse_proc_cmdline_item(const char *key, const char *value) {
static const char * const rlmap[] = { static const char * const rlmap[] = {
@ -292,12 +277,12 @@ static int parse_proc_cmdline_item(const char *key, const char *value) {
if (streq(key, "systemd.unit") && value) { if (streq(key, "systemd.unit") && value) {
if (!in_initrd()) if (!in_initrd())
return set_default_unit(value); return free_and_strdup(&arg_default_unit, value);
} else if (streq(key, "rd.systemd.unit") && value) { } else if (streq(key, "rd.systemd.unit") && value) {
if (in_initrd()) if (in_initrd())
return set_default_unit(value); return free_and_strdup(&arg_default_unit, value);
} else if (streq(key, "systemd.dump_core") && value) { } else if (streq(key, "systemd.dump_core") && value) {
@ -384,7 +369,7 @@ static int parse_proc_cmdline_item(const char *key, const char *value) {
/* SysV compatibility */ /* SysV compatibility */
for (i = 0; i < ELEMENTSOF(rlmap); i += 2) for (i = 0; i < ELEMENTSOF(rlmap); i += 2)
if (streq(key, rlmap[i])) if (streq(key, rlmap[i]))
return set_default_unit(rlmap[i+1]); return free_and_strdup(&arg_default_unit, rlmap[i+1]);
} }
return 0; return 0;
@ -786,7 +771,7 @@ static int parse_argv(int argc, char *argv[]) {
case ARG_UNIT: case ARG_UNIT:
r = set_default_unit(optarg); r = free_and_strdup(&arg_default_unit, optarg);
if (r < 0) if (r < 0)
return log_error_errno(r, "Failed to set default unit %s: %m", optarg); return log_error_errno(r, "Failed to set default unit %s: %m", optarg);
@ -1339,7 +1324,7 @@ int main(int argc, char *argv[]) {
} }
/* Initialize default unit */ /* Initialize default unit */
r = set_default_unit(SPECIAL_DEFAULT_TARGET); r = free_and_strdup(&arg_default_unit, SPECIAL_DEFAULT_TARGET);
if (r < 0) { if (r < 0) {
log_emergency_errno(r, "Failed to set default unit %s: %m", SPECIAL_DEFAULT_TARGET); log_emergency_errno(r, "Failed to set default unit %s: %m", SPECIAL_DEFAULT_TARGET);
error_message = "Failed to set default unit"; error_message = "Failed to set default unit";