From 953d28cc21d25dc61f886d61d628b577aed4e042 Mon Sep 17 00:00:00 2001 From: Zbigniew Jędrzejewski-Szmek Date: Tue, 23 Feb 2016 08:17:19 -0500 Subject: Fix two typos --- src/basic/hostname-util.c | 5 +++-- src/machine/machinectl.c | 2 +- 2 files changed, 4 insertions(+), 3 deletions(-) (limited to 'src') diff --git a/src/basic/hostname-util.c b/src/basic/hostname-util.c index f900c509a3..5ed98eeb6a 100644 --- a/src/basic/hostname-util.c +++ b/src/basic/hostname-util.c @@ -48,8 +48,9 @@ bool hostname_is_set(void) { char* gethostname_malloc(void) { struct utsname u; - /* This call tries to return something useful, either the actual hostname or it makes something up. The only - * reason it might mail is OOM. It might even return "localhost" if that's set. */ + /* This call tries to return something useful, either the actual hostname + * or it makes something up. The only reason it might fail is OOM. + * It might even return "localhost" if that's set. */ assert_se(uname(&u) >= 0); diff --git a/src/machine/machinectl.c b/src/machine/machinectl.c index 4853139321..4bb712ca5a 100644 --- a/src/machine/machinectl.c +++ b/src/machine/machinectl.c @@ -1763,7 +1763,7 @@ static int transfer_image_common(sd_bus *bus, sd_bus_message *m) { r = sd_bus_call(bus, m, 0, &error, &reply); if (r < 0) { - log_error("Failed transfer image: %s", bus_error_message(&error, -r)); + log_error("Failed to transfer image: %s", bus_error_message(&error, -r)); return r; } -- cgit v1.2.3-54-g00ecf From 6b0132e4e785de7b339da071eb1506adf2362edd Mon Sep 17 00:00:00 2001 From: Zbigniew Jędrzejewski-Szmek Date: Tue, 23 Feb 2016 08:17:19 -0500 Subject: basic: simplify ether_addr_is_null --- src/basic/ether-addr-util.c | 11 ----------- src/basic/ether-addr-util.h | 7 ++++++- 2 files changed, 6 insertions(+), 12 deletions(-) (limited to 'src') diff --git a/src/basic/ether-addr-util.c b/src/basic/ether-addr-util.c index d2c030903b..a4d8d656da 100644 --- a/src/basic/ether-addr-util.c +++ b/src/basic/ether-addr-util.c @@ -43,17 +43,6 @@ char* ether_addr_to_string(const struct ether_addr *addr, char buffer[ETHER_ADDR return buffer; } -bool ether_addr_is_null(const struct ether_addr *addr) { - assert(addr); - - return addr->ether_addr_octet[0] == 0 && - addr->ether_addr_octet[1] == 0 && - addr->ether_addr_octet[2] == 0 && - addr->ether_addr_octet[3] == 0 && - addr->ether_addr_octet[4] == 0 && - addr->ether_addr_octet[5] == 0; -} - bool ether_addr_equal(const struct ether_addr *a, const struct ether_addr *b) { assert(a); assert(b); diff --git a/src/basic/ether-addr-util.h b/src/basic/ether-addr-util.h index 00c5159fe8..074363793e 100644 --- a/src/basic/ether-addr-util.h +++ b/src/basic/ether-addr-util.h @@ -28,5 +28,10 @@ #define ETHER_ADDR_TO_STRING_MAX (3*6) char* ether_addr_to_string(const struct ether_addr *addr, char buffer[ETHER_ADDR_TO_STRING_MAX]); -bool ether_addr_is_null(const struct ether_addr *addr); bool ether_addr_equal(const struct ether_addr *a, const struct ether_addr *b); + +#define ETHER_ADDR_NULL ((const struct ether_addr){}) + +static inline bool ether_addr_is_null(const struct ether_addr *addr) { + return ether_addr_equal(addr, ÐER_ADDR_NULL); +} -- cgit v1.2.3-54-g00ecf From 4c3160f1502e5ebad8cb73ae70cdeead2e534997 Mon Sep 17 00:00:00 2001 From: Zbigniew Jędrzejewski-Szmek Date: Mon, 22 Feb 2016 23:23:56 -0500 Subject: networkctl: only print lldp legend for capabilities that were actually seen --- src/network/networkctl.c | 47 ++++++++++++++++++++++++++++++++++++++++------- 1 file changed, 40 insertions(+), 7 deletions(-) (limited to 'src') diff --git a/src/network/networkctl.c b/src/network/networkctl.c index d1aec9a7dc..07ac15f478 100644 --- a/src/network/networkctl.c +++ b/src/network/networkctl.c @@ -901,10 +901,43 @@ static char *lldp_capabilities_to_string(uint16_t x) { return ret; } +static void lldp_capabilities_legend(uint16_t x) { + unsigned w, i, cols = columns(); + static const char const* table[] = { + "o - Other", + "p - Repeater", + "b - Bridge", + "w - WLAN Access Point", + "r - Router", + "t - Telephone", + "d - DOCSIS cable device", + "a - Station", + "c - Customer VLAN", + "s - Service VLAN", + "m - Two-port MAC Relay (TPMR)", + }; + + if (x == 0) + return; + + printf("\nCapability Flags:\n"); + for (w = 0, i = 0; i < ELEMENTSOF(table); i++) + if (x & (1U << i) || arg_all) { + bool newline; + + newline = w + strlen(table[i]) + (w == 0 ? 0 : 2) > cols; + if (newline) + w = 0; + w += printf("%s%s%s", newline ? "\n" : "", w == 0 ? "" : "; ", table[i]); + } + puts(""); +} + static int link_lldp_status(int argc, char *argv[], void *userdata) { _cleanup_(sd_netlink_unrefp) sd_netlink *rtnl = NULL; _cleanup_free_ LinkInfo *links = NULL; int i, r, c, m = 0; + uint16_t all = 0; r = sd_netlink_open(&rtnl); if (r < 0) @@ -982,8 +1015,10 @@ static int link_lldp_status(int argc, char *argv[], void *userdata) { port_description = pdesc; } - if (sd_lldp_neighbor_get_enabled_capabilities(n, &cc) >= 0) + if (sd_lldp_neighbor_get_enabled_capabilities(n, &cc) >= 0) { capabilities = lldp_capabilities_to_string(cc); + all |= cc; + } printf("%-16s %-17s %-16s %-11s %-17s %-16s\n", links[i].name, @@ -997,12 +1032,10 @@ static int link_lldp_status(int argc, char *argv[], void *userdata) { } } - if (arg_legend) - printf("\nCapability Flags:\n" - "o - Other; p - Repeater; b - Bridge; w - WLAN Access Point; r - Router;\n" - "t - Telephone; d - DOCSIS cable device; a - Station; c - Customer VLAN;\n" - "s - Service VLAN, m - Two-port MAC Relay (TPMR)\n\n" - "%i neighbors listed.\n", m); + if (arg_legend) { + lldp_capabilities_legend(all); + printf("\n%i neighbors listed.\n", m); + } return 0; } -- cgit v1.2.3-54-g00ecf