diff options
author | Lennart Poettering <lennart@poettering.net> | 2019-04-08 12:03:33 +0200 |
---|---|---|
committer | Lennart Poettering <lennart@poettering.net> | 2019-04-08 12:03:33 +0200 |
commit | e7b88b7bc1b33af3966349ca59ecd3d25c3e8504 (patch) | |
tree | d0ebd1d919bca2916a84c89351b77007ad30ec46 /src/machine | |
parent | ea505047c542ee0a6d242c9c1bb6683b553b58db (diff) | |
download | systemd-e7b88b7bc1b33af3966349ca59ecd3d25c3e8504.tar.gz |
tree-wide: introduce empty_or_dash() helper
At quite a few places we check isempty() || streq(…, "-"), let's add a
helper to simplify that, and replace that by a single function call.
Diffstat (limited to 'src/machine')
-rw-r--r-- | src/machine/machinectl.c | 16 |
1 files changed, 5 insertions, 11 deletions
diff --git a/src/machine/machinectl.c b/src/machine/machinectl.c index c8607bcec3..d6e9c8c03c 100644 --- a/src/machine/machinectl.c +++ b/src/machine/machinectl.c @@ -1994,13 +1994,7 @@ static int transfer_image_common(sd_bus *bus, sd_bus_message *m) { } static const char *nullify_dash(const char *p) { - if (isempty(p)) - return NULL; - - if (streq(p, "-")) - return NULL; - - return p; + return empty_or_dash(p) ? NULL : p; } static int import_tar(int argc, char *argv[], void *userdata) { @@ -2230,7 +2224,7 @@ static int export_tar(int argc, char *argv[], void *userdata) { if (argc >= 3) path = argv[2]; - if (isempty(path) || streq(path, "-")) + if (empty_or_dash(path)) path = NULL; if (path) { @@ -2280,7 +2274,7 @@ static int export_raw(int argc, char *argv[], void *userdata) { if (argc >= 3) path = argv[2]; - if (isempty(path) || streq(path, "-")) + if (empty_or_dash(path)) path = NULL; if (path) { @@ -2338,7 +2332,7 @@ static int pull_tar(int argc, char *argv[], void *userdata) { local = l; } - if (isempty(local) || streq(local, "-")) + if (empty_or_dash(local)) local = NULL; if (local) { @@ -2402,7 +2396,7 @@ static int pull_raw(int argc, char *argv[], void *userdata) { local = l; } - if (isempty(local) || streq(local, "-")) + if (empty_or_dash(local)) local = NULL; if (local) { |