(str[0] == '-' && str[1] == 0);
}
+static inline const char *empty_or_dash_to_null(const char *p) {
+ return empty_or_dash(p) ? NULL : p;
+}
+
static inline char *startswith(const char *s, const char *prefix) {
size_t l;
if (argc >= 3)
path = argv[2];
- if (empty_or_dash(path))
- path = NULL;
+ path = empty_or_dash_to_null(path);
determine_compression_from_filename(path);
if (argc >= 3)
path = argv[2];
- if (empty_or_dash(path))
- path = NULL;
+ path = empty_or_dash_to_null(path);
determine_compression_from_filename(path);
if (argc >= 2)
path = argv[1];
- if (empty_or_dash(path))
- path = NULL;
+ path = empty_or_dash_to_null(path);
if (argc >= 3)
local = argv[2];
else if (path)
local = basename(path);
- if (empty_or_dash(local))
- local = NULL;
+ local = empty_or_dash_to_null(local);
if (local) {
if (!machine_name_is_valid(local)) {
if (argc >= 2)
path = argv[1];
- if (empty_or_dash(path))
- path = NULL;
+ path = empty_or_dash_to_null(path);
if (argc >= 3)
local = argv[2];
else if (path)
local = basename(path);
- if (empty_or_dash(local))
- local = NULL;
+ local = empty_or_dash_to_null(local);
if (local) {
r = tar_strip_suffixes(local, &ll);
if (argc >= 2)
path = argv[1];
- if (empty_or_dash(path))
- path = NULL;
+ path = empty_or_dash_to_null(path);
if (argc >= 3)
local = argv[2];
else if (path)
local = basename(path);
- if (empty_or_dash(local))
- local = NULL;
+ local = empty_or_dash_to_null(local);
if (local) {
r = raw_strip_suffixes(local, &ll);
local = l;
}
- if (empty_or_dash(local))
- local = NULL;
+ local = empty_or_dash_to_null(local);
if (local) {
r = tar_strip_suffixes(local, &ll);
local = l;
}
- if (empty_or_dash(local))
- local = NULL;
+ local = empty_or_dash_to_null(local);
if (local) {
r = raw_strip_suffixes(local, &ll);
return IN_SET(*s, ',', '\0');
}
-static const char* strnulldash(const char *s) {
- return empty_or_dash(s) ? NULL : s;
-}
-
static const char* systemd_kbd_model_map(void) {
const char* s;
if (!streq(c->vc_keymap, a[0]))
continue;
- if (!streq_ptr(c->x11_layout, strnulldash(a[1])) ||
- !streq_ptr(c->x11_model, strnulldash(a[2])) ||
- !streq_ptr(c->x11_variant, strnulldash(a[3])) ||
- !streq_ptr(c->x11_options, strnulldash(a[4]))) {
+ if (!streq_ptr(c->x11_layout, empty_or_dash_to_null(a[1])) ||
+ !streq_ptr(c->x11_model, empty_or_dash_to_null(a[2])) ||
+ !streq_ptr(c->x11_variant, empty_or_dash_to_null(a[3])) ||
+ !streq_ptr(c->x11_options, empty_or_dash_to_null(a[4]))) {
- if (free_and_strdup(&c->x11_layout, strnulldash(a[1])) < 0 ||
- free_and_strdup(&c->x11_model, strnulldash(a[2])) < 0 ||
- free_and_strdup(&c->x11_variant, strnulldash(a[3])) < 0 ||
- free_and_strdup(&c->x11_options, strnulldash(a[4])) < 0)
+ if (free_and_strdup(&c->x11_layout, empty_or_dash_to_null(a[1])) < 0 ||
+ free_and_strdup(&c->x11_model, empty_or_dash_to_null(a[2])) < 0 ||
+ free_and_strdup(&c->x11_variant, empty_or_dash_to_null(a[3])) < 0 ||
+ free_and_strdup(&c->x11_options, empty_or_dash_to_null(a[4])) < 0)
return -ENOMEM;
modified = true;
return -r;
}
-static const char *nullify_dash(const char *p) {
- return empty_or_dash(p) ? NULL : p;
-}
-
static int import_tar(int argc, char *argv[], void *userdata) {
_cleanup_(sd_bus_message_unrefp) sd_bus_message *m = NULL;
_cleanup_free_ char *ll = NULL, *fn = NULL;
assert(bus);
if (argc >= 2)
- path = nullify_dash(argv[1]);
+ path = empty_or_dash_to_null(argv[1]);
if (argc >= 3)
- local = nullify_dash(argv[2]);
+ local = empty_or_dash_to_null(argv[2]);
else if (path) {
r = path_extract_filename(path, &fn);
if (r < 0)
assert(bus);
if (argc >= 2)
- path = nullify_dash(argv[1]);
+ path = empty_or_dash_to_null(argv[1]);
if (argc >= 3)
- local = nullify_dash(argv[2]);
+ local = empty_or_dash_to_null(argv[2]);
else if (path) {
r = path_extract_filename(path, &fn);
if (r < 0)
assert(bus);
if (argc >= 2)
- path = nullify_dash(argv[1]);
+ path = empty_or_dash_to_null(argv[1]);
if (argc >= 3)
- local = nullify_dash(argv[2]);
+ local = empty_or_dash_to_null(argv[2]);
else if (path) {
r = path_extract_filename(path, &fn);
if (r < 0)
if (argc >= 3)
path = argv[2];
- if (empty_or_dash(path))
- path = NULL;
+ path = empty_or_dash_to_null(path);
if (path) {
determine_compression_from_filename(path);
if (argc >= 3)
path = argv[2];
- if (empty_or_dash(path))
- path = NULL;
+ path = empty_or_dash_to_null(path);
if (path) {
determine_compression_from_filename(path);
local = l;
}
- if (empty_or_dash(local))
- local = NULL;
+ local = empty_or_dash_to_null(local);
if (local) {
r = tar_strip_suffixes(local, &ll);
local = l;
}
- if (empty_or_dash(local))
- local = NULL;
+ local = empty_or_dash_to_null(local);
if (local) {
r = raw_strip_suffixes(local, &ll);