• Home
  • Features
  • Pricing
  • Docs
  • Announcements
  • Sign In

systemd / systemd / 14895667988

07 May 2025 08:57PM UTC coverage: 72.225% (-0.007%) from 72.232%
14895667988

push

github

yuwata
network: log_link_message_debug_errno() automatically append %m if necessary

Follow-up for d28746ef5.
Fixes CID#1609753.

0 of 1 new or added line in 1 file covered. (0.0%)

20297 existing lines in 338 files now uncovered.

297407 of 411780 relevant lines covered (72.22%)

695716.85 hits per line

Source File
Press 'n' to go to next uncovered line, 'b' for previous

86.0
/src/network/networkctl-list.c
1
/* SPDX-License-Identifier: LGPL-2.1-or-later */
2

3
#include "sd-network.h"
4

5
#include "alloc-util.h"
6
#include "format-table.h"
7
#include "netif-util.h"
8
#include "networkctl.h"
9
#include "networkctl-description.h"
10
#include "networkctl-link-info.h"
11
#include "networkctl-list.h"
12
#include "networkctl-util.h"
13

14
int list_links(int argc, char *argv[], void *userdata) {
5✔
15
        _cleanup_(sd_bus_flush_close_unrefp) sd_bus *bus = NULL;
5✔
16
        _cleanup_(sd_netlink_unrefp) sd_netlink *rtnl = NULL;
5✔
17
        _cleanup_(link_info_array_freep) LinkInfo *links = NULL;
5✔
18
        _cleanup_(table_unrefp) Table *table = NULL;
5✔
19
        TableCell *cell;
5✔
20
        int c, r;
5✔
21

22
        r = dump_description(argc, argv);
5✔
23
        if (r != 0)
5✔
24
                return r;
25

26
        r = acquire_bus(&bus);
5✔
27
        if (r < 0)
5✔
28
                return r;
29

30
        r = sd_netlink_open(&rtnl);
5✔
31
        if (r < 0)
5✔
UNCOV
32
                return log_error_errno(r, "Failed to connect to netlink: %m");
×
33

34
        c = acquire_link_info(NULL, rtnl, argc > 1 ? argv + 1 : NULL, &links);
5✔
35
        if (c < 0)
5✔
36
                return c;
37

38
        pager_open(arg_pager_flags);
5✔
39

40
        table = table_new("idx", "link", "type", "operational", "setup");
5✔
41
        if (!table)
5✔
UNCOV
42
                return log_oom();
×
43

44
        if (arg_full)
5✔
UNCOV
45
                table_set_width(table, 0);
×
46

47
        table_set_header(table, arg_legend);
5✔
48
        table_set_ersatz_string(table, TABLE_ERSATZ_DASH);
5✔
49

50
        assert_se(cell = table_get_cell(table, 0, 0));
5✔
51
        (void) table_set_minimum_width(table, cell, 3);
5✔
52
        (void) table_set_weight(table, cell, 0);
5✔
53
        (void) table_set_ellipsize_percent(table, cell, 100);
5✔
54
        (void) table_set_align_percent(table, cell, 100);
5✔
55

56
        assert_se(cell = table_get_cell(table, 0, 1));
5✔
57
        (void) table_set_ellipsize_percent(table, cell, 100);
5✔
58

59
        FOREACH_ARRAY(link, links, c) {
33✔
UNCOV
60
                _cleanup_free_ char *setup_state = NULL, *operational_state = NULL;
×
61
                _cleanup_free_ char *t = NULL;
28✔
62
                const char *on_color_operational, *on_color_setup;
28✔
63

64
                (void) sd_network_link_get_operational_state(link->ifindex, &operational_state);
28✔
65
                operational_state_to_color(link->name, operational_state, &on_color_operational, NULL);
28✔
66

67
                (void) sd_network_link_get_setup_state(link->ifindex, &setup_state);
28✔
68
                setup_state_to_color(setup_state, &on_color_setup, NULL);
28✔
69

70
                r = net_get_type_string(link->sd_device, link->iftype, &t);
28✔
71
                if (r == -ENOMEM)
28✔
UNCOV
72
                        return log_oom();
×
73

74
                r = table_add_many(table,
28✔
75
                                   TABLE_INT, link->ifindex,
76
                                   TABLE_STRING, link->name,
77
                                   TABLE_STRING, t,
78
                                   TABLE_STRING, operational_state,
79
                                   TABLE_SET_COLOR, on_color_operational,
80
                                   TABLE_STRING, setup_state ?: "unmanaged",
81
                                   TABLE_SET_COLOR, on_color_setup);
82
                if (r < 0)
28✔
UNCOV
83
                        return table_log_add_error(r);
×
84
        }
85

86
        r = table_print(table, NULL);
5✔
87
        if (r < 0)
5✔
UNCOV
88
                return table_log_print_error(r);
×
89

90
        if (arg_legend)
5✔
91
                printf("\n%i links listed.\n", c);
5✔
92

93
        return 0;
94
}
STATUS · Troubleshooting · Open an Issue · Sales · Support · CAREERS · ENTERPRISE · START FREE · SCHEDULE DEMO
ANNOUNCEMENTS · TWITTER · TOS & SLA · Supported CI Services · What's a CI service? · Automated Testing

© 2026 Coveralls, Inc