return !p || !p[0];
}
+static inline const char *empty_to_null(const char *p) {
+ return isempty(p) ? NULL : p;
+}
+
static inline char *startswith(const char *s, const char *prefix) {
size_t l;
if (r < 0)
return r;
- if (isempty(name))
- name = NULL;
+ name = empty_to_null(name);
if (streq_ptr(name, c->data[PROP_STATIC_HOSTNAME]))
return sd_bus_reply_method_return(m, NULL);
if (r == 0)
return 1; /* No authorization for now, but the async polkit stuff will call us again when it has it */
- if (isempty(name)) {
+ if (isempty(name))
c->data[PROP_STATIC_HOSTNAME] = mfree(c->data[PROP_STATIC_HOSTNAME]);
- } else {
+ else {
char *h;
if (!hostname_is_valid(name, false))
if (r < 0)
return r;
- if (isempty(name))
- name = NULL;
+ name = empty_to_null(name);
if (streq_ptr(name, c->data[prop]))
return sd_bus_reply_method_return(m, NULL);
if (r == 0)
return 1; /* No authorization for now, but the async polkit stuff will call us again when it has it */
- if (isempty(name)) {
+ if (isempty(name))
c->data[prop] = mfree(c->data[prop]);
- } else {
+ else {
char *h;
/* The icon name might ultimately be used as file
Hashmap *polkit_registry;
} Context;
-static const char* nonempty(const char *s) {
- return isempty(s) ? NULL : s;
-}
-
static bool startswith_comma(const char *s, const char *prefix) {
const char *t;
for (p = 0; p < _LOCALE_MAX; p++) {
assert(names[p]);
- r = free_and_strdup(&c->locale[p],
- nonempty(getenv(names[p])));
+ r = free_and_strdup(&c->locale[p], empty_to_null(getenv(names[p])));
if (r < 0)
return r;
}
if (r < 0)
return r;
- if (isempty(keymap))
- keymap = NULL;
-
- if (isempty(keymap_toggle))
- keymap_toggle = NULL;
+ keymap = empty_to_null(keymap);
+ keymap_toggle = empty_to_null(keymap_toggle);
if (!streq_ptr(keymap, c->vc_keymap) ||
!streq_ptr(keymap_toggle, c->vc_keymap_toggle)) {
if (r < 0)
return r;
- if (isempty(layout))
- layout = NULL;
-
- if (isempty(model))
- model = NULL;
-
- if (isempty(variant))
- variant = NULL;
-
- if (isempty(options))
- options = NULL;
+ layout = empty_to_null(layout);
+ model = empty_to_null(model);
+ variant = empty_to_null(variant);
+ options = empty_to_null(options);
if (!streq_ptr(layout, c->x11_layout) ||
!streq_ptr(model, c->x11_model) ||
r = sd_bus_message_read(message, "ss", &user, &path);
if (r < 0)
return r;
- if (isempty(user))
- user = NULL;
+ user = empty_to_null(user);
if (isempty(path))
path = "/bin/sh";
if (!path_is_absolute(path))
assert(bus);
assert(domain);
- if (isempty(name))
- name = NULL;
- if (isempty(type))
- type = NULL;
+ name = empty_to_null(name);
+ type = empty_to_null(type);
if (arg_ifindex > 0 && !if_indextoname(arg_ifindex, ifname))
return log_error_errno(errno, "Failed to resolve interface name for index %i: %m", arg_ifindex);
if (r < 0)
return bus_log_parse_error(r);
- if (isempty(canonical_name))
- canonical_name = NULL;
- if (isempty(canonical_type))
- canonical_type = NULL;
+ canonical_name = empty_to_null(canonical_name);
+ canonical_type = empty_to_null(canonical_type);
if (!streq_ptr(name, canonical_name) ||
!streq_ptr(type, canonical_type) ||
init = cmdline_init;
}
- if (isempty(init))
- init = NULL;
-
+ init = empty_to_null(init);
if (init) {
const char *root_systemd_path = NULL, *root_init_path = NULL;
t[k-1] = 0;
}
- j = strstrip(t+12);
- if (isempty(j))
- j = NULL;
+ j = empty_to_null(strstrip(t+12));
r = free_and_strdup(&chkconfig_description, j);
if (r < 0)
state = LSB_DESCRIPTION;
- j = strstrip(t+12);
- if (isempty(j))
- j = NULL;
+ j = empty_to_null(strstrip(t+12));
r = free_and_strdup(&long_description, j);
if (r < 0)
state = LSB;
- j = strstrip(t+18);
- if (isempty(j))
- j = NULL;
+ j = empty_to_null(strstrip(t+18));
r = free_and_strdup(&short_description, j);
if (r < 0)