summaryrefslogtreecommitdiff
path: root/src/core
diff options
context:
space:
mode:
author0xAX <0xAX@users.noreply.github.com>2016-10-10 23:11:36 +0300
committerLennart Poettering <lennart@poettering.net>2016-10-10 22:11:36 +0200
commitf6dd106c73abb33af5eb0aaeffcddd11724515e6 (patch)
treeccf8d8c2e1d24d24aac308a0e0be26ad08b1d343 /src/core
parent53c06862c12918ec717ea70918039765212eee95 (diff)
main: use strdup instead of free_and_strdup to initialize default unit (#4335)
Previously we've used free_and_strdup() to fill arg_default_unit with unit name, If we didn't pass default unit name through a kernel command line or command line arguments. But we can use just strdup() instead of free_and_strdup() for this, because we will start fill arg_default_unit only if it wasn't set before.
Diffstat (limited to 'src/core')
-rw-r--r--src/core/main.c6
1 files changed, 3 insertions, 3 deletions
diff --git a/src/core/main.c b/src/core/main.c
index 30d9c43fbb..9985510161 100644
--- a/src/core/main.c
+++ b/src/core/main.c
@@ -1586,9 +1586,9 @@ int main(int argc, char *argv[]) {
/* Initialize default unit */
if (!arg_default_unit) {
- r = free_and_strdup(&arg_default_unit, SPECIAL_DEFAULT_TARGET);
- if (r < 0) {
- log_emergency_errno(r, "Failed to set default unit %s: %m", SPECIAL_DEFAULT_TARGET);
+ arg_default_unit = strdup(SPECIAL_DEFAULT_TARGET);
+ if (!arg_default_unit) {
+ r = log_oom();
error_message = "Failed to set default unit";
goto finish;
}