• 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

70.21
/src/systemctl/systemctl-add-dependency.c
1
/* SPDX-License-Identifier: LGPL-2.1-or-later */
2

3
#include "alloc-util.h"
4
#include "bus-error.h"
5
#include "bus-locator.h"
6
#include "systemctl.h"
7
#include "systemctl-add-dependency.h"
8
#include "systemctl-daemon-reload.h"
9
#include "systemctl-util.h"
10

11
int verb_add_dependency(int argc, char *argv[], void *userdata) {
2✔
UNCOV
12
        _cleanup_strv_free_ char **names = NULL;
×
13
        _cleanup_free_ char *target = NULL;
2✔
14
        const char *verb = argv[0];
2✔
15
        UnitDependency dep;
2✔
16
        int r;
2✔
17

18
        if (!argv[1])
2✔
19
                return 0;
20

21
        r = unit_name_mangle_with_suffix(argv[1], "as target",
2✔
22
                                         arg_quiet ? 0 : UNIT_NAME_MANGLE_WARN,
2✔
23
                                         ".target", &target);
24
        if (r < 0)
2✔
UNCOV
25
                return log_error_errno(r, "Failed to mangle unit name: %m");
×
26

27
        r = mangle_names("as dependency", strv_skip(argv, 2), &names);
2✔
28
        if (r < 0)
2✔
29
                return r;
30

31
        if (streq(verb, "add-wants"))
2✔
32
                dep = UNIT_WANTS;
33
        else if (streq(verb, "add-requires"))
1✔
34
                dep = UNIT_REQUIRES;
35
        else
UNCOV
36
                assert_not_reached();
×
37

38
        if (install_client_side()) {
2✔
39
                InstallChange *changes = NULL;
×
UNCOV
40
                size_t n_changes = 0;
×
41

UNCOV
42
                CLEANUP_ARRAY(changes, n_changes, install_changes_free);
×
43

44
                r = unit_file_add_dependency(arg_runtime_scope, unit_file_flags_from_args(), arg_root, names, target, dep, &changes, &n_changes);
×
45
                install_changes_dump(r, "add dependency on", changes, n_changes, arg_quiet);
×
46
                if (r < 0)
×
UNCOV
47
                        return r;
×
48
        } else {
49
                _cleanup_(sd_bus_message_unrefp) sd_bus_message *reply = NULL, *m = NULL;
4✔
50
                _cleanup_(sd_bus_error_free) sd_bus_error error = SD_BUS_ERROR_NULL;
2✔
51
                sd_bus *bus;
2✔
52

53
                r = acquire_bus(BUS_MANAGER, &bus);
2✔
54
                if (r < 0)
2✔
55
                        return r;
56

57
                polkit_agent_open_maybe();
2✔
58

59
                r = bus_message_new_method_call(bus, &m, bus_systemd_mgr, "AddDependencyUnitFiles");
2✔
60
                if (r < 0)
2✔
UNCOV
61
                        return bus_log_create_error(r);
×
62

63
                r = sd_bus_message_append_strv(m, names);
2✔
64
                if (r < 0)
2✔
UNCOV
65
                        return bus_log_create_error(r);
×
66

67
                r = sd_bus_message_append(m, "ssbb", target, unit_dependency_to_string(dep), arg_runtime, arg_force);
2✔
68
                if (r < 0)
2✔
UNCOV
69
                        return bus_log_create_error(r);
×
70

71
                r = sd_bus_call(bus, m, 0, &error, &reply);
2✔
72
                if (r < 0)
2✔
UNCOV
73
                        return log_error_errno(r, "Failed to add dependency: %s", bus_error_message(&error, r));
×
74

75
                r = bus_deserialize_and_dump_unit_file_changes(reply, arg_quiet);
2✔
76
                if (r < 0)
2✔
77
                        return r;
78

79
                if (!arg_no_reload) {
2✔
80
                        r = daemon_reload(ACTION_RELOAD, /* graceful= */ false);
2✔
81
                        if (r < 0)
2✔
82
                                return r;
83
                }
84
        }
85

86
        return 0;
87
}
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