From: Yu Watanabe Date: Thu, 10 May 2018 16:55:46 +0000 (+0900) Subject: string-util: rename strdash_if_empty() to empty_to_dash() X-Git-Tag: v239~276^2 X-Git-Url: http://git.ipfire.org/gitweb.cgi?a=commitdiff_plain;h=refs%2Fpull%2F8953%2Fhead;p=thirdparty%2Fsystemd.git string-util: rename strdash_if_empty() to empty_to_dash() --- diff --git a/src/basic/string-util.h b/src/basic/string-util.h index 3004b924bd4..5a10eeabfe9 100644 --- a/src/basic/string-util.h +++ b/src/basic/string-util.h @@ -58,7 +58,7 @@ static inline const char *empty_to_null(const char *p) { return isempty(p) ? NULL : p; } -static inline const char *strdash_if_empty(const char *str) { +static inline const char *empty_to_dash(const char *str) { return isempty(str) ? "-" : str; } diff --git a/src/busctl/busctl.c b/src/busctl/busctl.c index f19edfd9874..5c65147caca 100644 --- a/src/busctl/busctl.c +++ b/src/busctl/busctl.c @@ -914,10 +914,6 @@ static int on_property(const char *interface, const char *name, const char *sign return 0; } -static const char *strdash(const char *x) { - return isempty(x) ? "-" : x; -} - static int introspect(int argc, char **argv, void *userdata) { static const struct hash_ops member_hash_ops = { .hash = member_hash_func, @@ -1104,15 +1100,15 @@ static int introspect(int argc, char **argv, void *userdata) { rv = ellipsized; } else - rv = strdash(m->result); + rv = empty_to_dash(m->result); printf("%s%s%-*s%s %-*s %-*s %-*s%s%s%s%s%s%s\n", is_interface ? ansi_highlight() : "", is_interface ? "" : ".", - - !is_interface + (int) name_width, strdash(streq_ptr(m->type, "interface") ? m->interface : m->name), + - !is_interface + (int) name_width, empty_to_dash(streq_ptr(m->type, "interface") ? m->interface : m->name), is_interface ? ansi_normal() : "", - (int) type_width, strdash(m->type), - (int) signature_width, strdash(m->signature), + (int) type_width, empty_to_dash(m->type), + (int) signature_width, empty_to_dash(m->signature), (int) result_width, rv, (m->flags & SD_BUS_VTABLE_DEPRECATED) ? " deprecated" : (m->flags || m->writable ? "" : " -"), (m->flags & SD_BUS_VTABLE_METHOD_NO_REPLY) ? " no-reply" : "", diff --git a/src/machine/machinectl.c b/src/machine/machinectl.c index c16f54c2832..54860bd1a5b 100644 --- a/src/machine/machinectl.c +++ b/src/machine/machinectl.c @@ -335,10 +335,10 @@ static int list_machines(int argc, char *argv[], void *userdata) { r = table_add_many(table, TABLE_STRING, name, TABLE_STRING, class, - TABLE_STRING, strdash_if_empty(service), - TABLE_STRING, strdash_if_empty(os), - TABLE_STRING, strdash_if_empty(version_id), - TABLE_STRING, strdash_if_empty(addresses)); + TABLE_STRING, empty_to_dash(service), + TABLE_STRING, empty_to_dash(os), + TABLE_STRING, empty_to_dash(version_id), + TABLE_STRING, empty_to_dash(addresses)); if (r < 0) return log_error_errno(r, "Failed to add table row: %m"); }