TABLE_STRING, strna(setup_state),
TABLE_SET_COLOR, on_color_setup);
if (r < 0)
- return r;
+ return table_log_add_error(r);
}
r = table_print(table, NULL);
TABLE_EMPTY,
TABLE_STRING, i == 0 ? "Gateway:" : "");
if (r < 0)
- return r;
+ return table_log_add_error(r);
r = in_addr_to_string(local[i].family, &local[i].address, &gateway);
if (r < 0)
} else
r = table_add_cell(table, NULL, TABLE_STRING, with_description ?: gateway);
if (r < 0)
- return r;
+ return table_log_add_error(r);
}
return 0;
TABLE_EMPTY,
TABLE_STRING, i == 0 ? "Address:" : "");
if (r < 0)
- return r;
+ return table_log_add_error(r);
r = in_addr_to_string(local[i].family, &local[i].address, &pretty);
if (r < 0)
} else
r = table_add_cell(table, NULL, TABLE_STRING, pretty);
if (r < 0)
- return r;
+ return table_log_add_error(r);
}
return 0;
table = table_new("label", "prefix/prefixlen");
if (!table)
- return -ENOMEM;
+ return log_oom();
if (arg_full)
table_set_width(table, 0);
r = table_add_cell(table, NULL, TABLE_UINT32, &label);
if (r < 0)
- return r;
+ return table_log_add_error(r);
r = table_add_cell_stringf(table, NULL, "%s/%u", pretty, prefixlen);
if (r < 0)
- return r;
+ return table_log_add_error(r);
}
- return table_print(table, NULL);
+ r = table_print(table, NULL);
+ if (r < 0)
+ return log_error_errno(r, "Failed to print table: %m");
+
+ return 0;
}
static int list_address_labels(int argc, char *argv[], void *userdata) {
TABLE_EMPTY,
TABLE_STRING, c == 0 ? prefix : "");
if (r < 0)
- return r;
+ return table_log_add_error(r);
(void) sd_lldp_neighbor_get_system_name(n, &system_name);
(void) sd_lldp_neighbor_get_port_id_as_string(n, &port_id);
strempty(port_description),
isempty(port_description) ? "" : ")");
if (r < 0)
- return r;
+ return table_log_add_error(r);
c++;
}
TABLE_STRING, c == 0 ? prefix : "",
TABLE_IFINDEX, ifindexes[c]);
if (r < 0)
- return r;
+ return table_log_add_error(r);
}
return 0;
TABLE_STRING, i == l ? prefix : "",
TABLE_STRING, *i);
if (r < 0)
- return r;
+ return table_log_add_error(r);
}
return 0;
TABLE_EMPTY, \
TABLE_STRING, name ":"); \
if (r < 0) \
- return r; \
+ return table_log_add_error(r); \
r = table_add_cell(table, NULL, \
info->has_stats64 ? TABLE_UINT64 : TABLE_UINT32, \
info->has_stats64 ? (void*) &info->stats64.val_name : (void*) &info->stats.val_name); \
if (r < 0) \
- return r;
+ return table_log_add_error(r);
static int dump_statistics(Table *table, const LinkInfo *info) {
int r;
table = table_new("dot", "key", "value");
if (!table)
- return -ENOMEM;
+ return log_oom();
if (arg_full)
table_set_width(table, 0);
TABLE_STRING, special_glyph(SPECIAL_GLYPH_BLACK_CIRCLE),
TABLE_SET_COLOR, on_color_operational);
if (r < 0)
- return r;
+ return table_log_add_error(r);
r = table_add_cell_stringf(table, &cell, "%i: %s", info->ifindex, info->name);
if (r < 0)
- return r;
+ return table_log_add_error(r);
(void) table_set_align_percent(table, cell, 0);
r = table_add_many(table,
TABLE_EMPTY,
TABLE_STRING, "State:");
if (r < 0)
- return r;
+ return table_log_add_error(r);
r = table_add_cell_stringf(table, NULL, "%s%s%s (%s%s%s)",
on_color_operational, strna(operational_state), off_color_operational,
on_color_setup, strna(setup_state), off_color_setup);
if (r < 0)
- return r;
+ return table_log_add_error(r);
- STRV_FOREACH(p, info->alternative_names)
+ STRV_FOREACH(p, info->alternative_names) {
if (p == info->alternative_names)
r = table_add_many(table,
TABLE_EMPTY,
TABLE_EMPTY,
TABLE_EMPTY,
TABLE_STRING, *p);
+ if (r < 0)
+ return table_log_add_error(r);
+ }
if (path) {
r = table_add_many(table,
TABLE_STRING, "Path:",
TABLE_STRING, path);
if (r < 0)
- return r;
+ return table_log_add_error(r);
}
if (driver) {
r = table_add_many(table,
TABLE_STRING, "Driver:",
TABLE_STRING, driver);
if (r < 0)
- return r;
+ return table_log_add_error(r);
}
if (vendor) {
r = table_add_many(table,
TABLE_STRING, "Vendor:",
TABLE_STRING, vendor);
if (r < 0)
- return r;
+ return table_log_add_error(r);
}
if (model) {
r = table_add_many(table,
TABLE_STRING, "Model:",
TABLE_STRING, model);
if (r < 0)
- return r;
+ return table_log_add_error(r);
}
if (info->has_mac_address) {
TABLE_EMPTY,
TABLE_STRING, "HW Address:");
if (r < 0)
- return r;
+ return table_log_add_error(r);
r = table_add_cell_stringf(table, NULL, "%s%s%s%s",
ether_addr_to_string(&info->mac_address, ea),
description ? " (" : "",
strempty(description),
description ? ")" : "");
if (r < 0)
- return r;
+ return table_log_add_error(r);
}
if (info->has_permanent_mac_address) {
TABLE_EMPTY,
TABLE_STRING, "HW Permanent Address:");
if (r < 0)
- return r;
+ return table_log_add_error(r);
r = table_add_cell_stringf(table, NULL, "%s%s%s%s",
ether_addr_to_string(&info->permanent_mac_address, ea),
description ? " (" : "",
strempty(description),
description ? ")" : "");
if (r < 0)
- return r;
+ return table_log_add_error(r);
}
if (info->mtu > 0) {
TABLE_EMPTY,
TABLE_STRING, "MTU:");
if (r < 0)
- return r;
+ return table_log_add_error(r);
r = table_add_cell_stringf(table, NULL, "%" PRIu32 "%s%s%s%s%s%s%s",
info->mtu,
info->min_mtu > 0 || info->max_mtu > 0 ? " (" : "",
info->max_mtu > 0 ? max_str : "",
info->min_mtu > 0 || info->max_mtu > 0 ? ")" : "");
if (r < 0)
- return r;
+ return table_log_add_error(r);
}
if (streq_ptr(info->netdev_kind, "bridge")) {
TABLE_STRING, "Multicast IGMP Version:",
TABLE_UINT8, info->mcast_igmp_version);
if (r < 0)
- return r;
+ return table_log_add_error(r);
} else if (streq_ptr(info->netdev_kind, "vxlan")) {
if (info->vxlan_info.vni > 0) {
TABLE_STRING, "VNI:",
TABLE_UINT32, info->vxlan_info.vni);
if (r < 0)
- return r;
+ return table_log_add_error(r);
}
if (IN_SET(info->vxlan_info.group_family, AF_INET, AF_INET6)) {
info->vxlan_info.group_family == AF_INET ? TABLE_IN_ADDR : TABLE_IN6_ADDR,
&info->vxlan_info.group);
if (r < 0)
- return r;
+ return table_log_add_error(r);
}
if (IN_SET(info->vxlan_info.local_family, AF_INET, AF_INET6)) {
info->vxlan_info.local_family == AF_INET ? TABLE_IN_ADDR : TABLE_IN6_ADDR,
&info->vxlan_info.local);
if (r < 0)
- return r;
+ return table_log_add_error(r);
}
if (info->vxlan_info.dest_port > 0) {
TABLE_STRING, "Destination Port:",
TABLE_UINT16, be16toh(info->vxlan_info.dest_port));
if (r < 0)
- return r;
+ return table_log_add_error(r);
}
if (info->vxlan_info.link > 0) {
TABLE_STRING, "Underlying Device:",
TABLE_IFINDEX, info->vxlan_info.link);
if (r < 0)
- return r;
+ return table_log_add_error(r);
}
}
TABLE_EMPTY,
TABLE_STRING, "WiFi access point:");
if (r < 0)
- return r;
+ return table_log_add_error(r);
if (info->ssid)
esc = cescape(info->ssid);
strnull(esc),
ether_addr_to_string(&info->bssid, buf));
if (r < 0)
- return r;
+ return table_log_add_error(r);
}
if (info->has_bitrates) {
TABLE_EMPTY,
TABLE_STRING, "Bit Rate (Tx/Rx):");
if (r < 0)
- return r;
+ return table_log_add_error(r);
r = table_add_cell_stringf(table, NULL, "%sbps/%sbps",
format_bytes_full(tx, sizeof tx, info->tx_bitrate, 0),
format_bytes_full(rx, sizeof rx, info->rx_bitrate, 0));
if (r < 0)
- return r;
+ return table_log_add_error(r);
}
if (info->has_tx_queues || info->has_rx_queues) {
TABLE_EMPTY,
TABLE_STRING, "Queue Length (Tx/Rx):");
if (r < 0)
- return r;
+ return table_log_add_error(r);
r = table_add_cell_stringf(table, NULL, "%" PRIu32 "/%" PRIu32, info->tx_queues, info->rx_queues);
if (r < 0)
- return r;
+ return table_log_add_error(r);
}
if (info->has_ethtool_link_info) {
TABLE_STRING, "Auto negotiation:",
TABLE_BOOLEAN, info->autonegotiation == AUTONEG_ENABLE);
if (r < 0)
- return r;
+ return table_log_add_error(r);
}
if (info->speed > 0) {
TABLE_STRING, "Speed:",
TABLE_BPS, (uint64_t) info->speed);
if (r < 0)
- return r;
+ return table_log_add_error(r);
}
if (duplex) {
TABLE_STRING, "Duplex:",
TABLE_STRING, duplex);
if (r < 0)
- return r;
+ return table_log_add_error(r);
}
if (port) {
TABLE_STRING, "Port:",
TABLE_STRING, port);
if (r < 0)
- return r;
+ return table_log_add_error(r);
}
}
TABLE_STRING, "Time Zone:",
TABLE_STRING, tz);
if (r < 0)
- return r;
+ return table_log_add_error(r);
}
r = dump_lldp_neighbors(table, "Connected To:", info->ifindex);
r = table_print(table, NULL);
if (r < 0)
- return r;
+ return log_error_errno(r, "Failed to print table: %m");
return show_logs(info);
}
table = table_new("dot", "key", "value");
if (!table)
- return -ENOMEM;
+ return log_oom();
if (arg_full)
table_set_width(table, 0);
TABLE_STRING, "State:",
TABLE_STRING, strna(operational_state),
TABLE_SET_COLOR, on_color_operational);
+ if (r < 0)
+ return table_log_add_error(r);
r = dump_addresses(rtnl, table, 0);
if (r < 0)
r = table_print(table, NULL);
if (r < 0)
- return r;
+ return log_error_errno(r, "Failed to print table: %m");
return show_logs(NULL);
}
"port id",
"port description");
if (!table)
- return -ENOMEM;
+ return log_oom();
if (arg_full)
table_set_width(table, 0);
TABLE_STRING, strna(port_id),
TABLE_STRING, strna(port_description));
if (r < 0)
- return r;
+ return table_log_add_error(r);
m++;
}
r = table_print(table, NULL);
if (r < 0)
- return r;
+ return log_error_errno(r, "Failed to print table: %m");
if (arg_legend) {
lldp_capabilities_legend(all);
TABLE_STRING, "Local time:",
TABLE_STRING, have_time && n > 0 ? a : "n/a");
if (r < 0)
- return log_error_errno(r, "Failed to add cell(s): %m");
+ return table_log_add_error(r);
if (have_time)
n = strftime(a, sizeof a, "%a %Y-%m-%d %H:%M:%S UTC", gmtime_r(&sec, &tm));
TABLE_STRING, "Universal time:",
TABLE_STRING, have_time && n > 0 ? a : "n/a");
if (r < 0)
- return log_error_errno(r, "Failed to add cell(s): %m");
+ return table_log_add_error(r);
if (i->rtc_time > 0) {
time_t rtc_sec;
TABLE_STRING, "RTC time:",
TABLE_STRING, i->rtc_time > 0 && n > 0 ? a : "n/a");
if (r < 0)
- return log_error_errno(r, "Failed to add cell(s): %m");
+ return table_log_add_error(r);
if (have_time)
n = strftime(a, sizeof a, "%Z, %z", localtime_r(&sec, &tm));
r = table_add_cell(table, NULL, TABLE_STRING, "Time zone:");
if (r < 0)
- return log_error_errno(r, "Failed to add cell(s): %m");
+ return table_log_add_error(r);
r = table_add_cell_stringf(table, NULL, "%s (%s)", strna(i->timezone), have_time && n > 0 ? a : "n/a");
if (r < 0)
- return log_error_errno(r, "Failed to add cell(s): %m");
+ return table_log_add_error(r);
/* Restore the $TZ */
TABLE_STRING, "RTC in local TZ:",
TABLE_BOOLEAN, i->rtc_local);
if (r < 0)
- return log_error_errno(r, "Failed to add cell(s): %m");
+ return table_log_add_error(r);
r = table_print(table, NULL);
if (r < 0)
r = table_add_cell(table, NULL, TABLE_STRING, "Server:");
if (r < 0)
- return log_error_errno(r, "Failed to add cell(s): %m");
+ return table_log_add_error(r);
r = table_add_cell_stringf(table, NULL, "%s (%s)", i->server_address, i->server_name);
if (r < 0)
- return log_error_errno(r, "Failed to add cell(s): %m");
+ return table_log_add_error(r);
r = table_add_cell(table, NULL, TABLE_STRING, "Poll interval:");
if (r < 0)
- return log_error_errno(r, "Failed to add cell(s): %m");
+ return table_log_add_error(r);
r = table_add_cell_stringf(table, NULL, "%s (min: %s; max %s)",
format_timespan(ts, sizeof(ts), i->poll_interval, 0),
format_timespan(tmin, sizeof(tmin), i->poll_min, 0),
format_timespan(tmax, sizeof(tmax), i->poll_max, 0));
if (r < 0)
- return log_error_errno(r, "Failed to add cell(s): %m");
+ return table_log_add_error(r);
if (i->packet_count == 0) {
r = table_add_many(table,
TABLE_STRING, "Packet count:",
TABLE_STRING, "0");
if (r < 0)
- return log_error_errno(r, "Failed to add cell(s): %m");
+ return table_log_add_error(r);
r = table_print(table, NULL);
if (r < 0)
TABLE_UINT32, i->stratum,
TABLE_STRING, "Reference:");
if (r < 0)
- return log_error_errno(r, "Failed to add cell(s): %m");
+ return table_log_add_error(r);
if (i->stratum <= 1)
r = table_add_cell(table, NULL, TABLE_STRING, i->reference.str);
else
r = table_add_cell_stringf(table, NULL, "%" PRIX32, be32toh(i->reference.val));
if (r < 0)
- return log_error_errno(r, "Failed to add cell(s): %m");
+ return table_log_add_error(r);
r = table_add_cell(table, NULL, TABLE_STRING, "Precision:");
if (r < 0)
- return log_error_errno(r, "Failed to add cell(s): %m");
+ return table_log_add_error(r);
r = table_add_cell_stringf(table, NULL, "%s (%" PRIi32 ")",
format_timespan(ts, sizeof(ts), DIV_ROUND_UP((nsec_t) (exp2(i->precision) * NSEC_PER_SEC), NSEC_PER_USEC), 0),
i->precision);
if (r < 0)
- return log_error_errno(r, "Failed to add cell(s): %m");
+ return table_log_add_error(r);
r = table_add_cell(table, NULL, TABLE_STRING, "Root distance:");
if (r < 0)
- return log_error_errno(r, "Failed to add cell(s): %m");
+ return table_log_add_error(r);
r = table_add_cell_stringf(table, NULL, "%s (max: %s)",
format_timespan(ts, sizeof(ts), root_distance, 0),
format_timespan(tmax, sizeof(tmax), i->root_distance_max, 0));
if (r < 0)
- return log_error_errno(r, "Failed to add cell(s): %m");
+ return table_log_add_error(r);
r = table_add_cell(table, NULL, TABLE_STRING, "Offset:");
if (r < 0)
- return log_error_errno(r, "Failed to add cell(s): %m");
+ return table_log_add_error(r);
r = table_add_cell_stringf(table, NULL, "%s%s",
offset_sign ? "+" : "-",
format_timespan(ts, sizeof(ts), offset, 0));
if (r < 0)
- return log_error_errno(r, "Failed to add cell(s): %m");
+ return table_log_add_error(r);
r = table_add_many(table,
TABLE_STRING, "Delay:",
TABLE_STRING, "Packet count:",
TABLE_UINT64, i->packet_count);
if (r < 0)
- return log_error_errno(r, "Failed to add cell(s): %m");
+ return table_log_add_error(r);
if (!i->spike) {
r = table_add_cell(table, NULL, TABLE_STRING, "Frequency:");
if (r < 0)
- return log_error_errno(r, "Failed to add cell(s): %m");
+ return table_log_add_error(r);
r = table_add_cell_stringf(table, NULL, "%+.3fppm", (double) i->freq / 0x10000);
if (r < 0)
- return log_error_errno(r, "Failed to add cell(s): %m");
+ return table_log_add_error(r);
}
r = table_print(table, NULL);