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.
This commit is contained in:
Lennart Poettering
2019-04-08 12:03:33 +02:00
parent ea505047c5
commit e7b88b7bc1
9 changed files with 32 additions and 32 deletions
+5 -5
View File
@@ -2507,7 +2507,7 @@ static int parse_line(const char *fname, unsigned line, const char *buffer, bool
return -EIO;
}
if (!isempty(buffer) && !streq(buffer, "-")) {
if (!empty_or_dash(buffer)) {
i.argument = strdup(buffer);
if (!i.argument)
return log_oom();
@@ -2704,7 +2704,7 @@ static int parse_line(const char *fname, unsigned line, const char *buffer, bool
free_and_replace(i.path, p);
}
if (!isempty(user) && !streq(user, "-")) {
if (!empty_or_dash(user)) {
const char *u = user;
r = get_user_creds(&u, &i.uid, NULL, NULL, NULL, USER_CREDS_ALLOW_MISSING);
@@ -2716,7 +2716,7 @@ static int parse_line(const char *fname, unsigned line, const char *buffer, bool
i.uid_set = true;
}
if (!isempty(group) && !streq(group, "-")) {
if (!empty_or_dash(group)) {
const char *g = group;
r = get_group_creds(&g, &i.gid, USER_CREDS_ALLOW_MISSING);
@@ -2729,7 +2729,7 @@ static int parse_line(const char *fname, unsigned line, const char *buffer, bool
i.gid_set = true;
}
if (!isempty(mode) && !streq(mode, "-")) {
if (!empty_or_dash(mode)) {
const char *mm = mode;
unsigned m;
@@ -2749,7 +2749,7 @@ static int parse_line(const char *fname, unsigned line, const char *buffer, bool
} else
i.mode = IN_SET(i.type, CREATE_DIRECTORY, TRUNCATE_DIRECTORY, CREATE_SUBVOLUME, CREATE_SUBVOLUME_INHERIT_QUOTA, CREATE_SUBVOLUME_NEW_QUOTA) ? 0755 : 0644;
if (!isempty(age) && !streq(age, "-")) {
if (!empty_or_dash(age)) {
const char *a = age;
if (*a == '~') {