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

systemd / systemd / 21499436527

29 Jan 2026 03:41PM UTC coverage: 72.796% (+0.3%) from 72.47%
21499436527

push

github

web-flow
Rework error propagation in systemctl preset (#40504)

16 of 20 new or added lines in 6 files covered. (80.0%)

181 existing lines in 39 files now uncovered.

311368 of 427728 relevant lines covered (72.8%)

1143681.81 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 "sd-bus.h"
4

5
#include "alloc-util.h"
6
#include "bus-error.h"
7
#include "bus-locator.h"
8
#include "bus-unit-util.h"
9
#include "bus-util.h"
10
#include "install.h"
11
#include "log.h"
12
#include "string-util.h"
13
#include "strv.h"
14
#include "systemctl.h"
15
#include "systemctl-add-dependency.h"
16
#include "systemctl-daemon-reload.h"
17
#include "systemctl-util.h"
18
#include "unit-name.h"
19

20
int verb_add_dependency(int argc, char *argv[], void *userdata) {
2✔
21
        _cleanup_strv_free_ char **names = NULL;
×
22
        _cleanup_free_ char *target = NULL;
2✔
23
        const char *verb = argv[0];
2✔
24
        UnitDependency dep;
2✔
25
        int r;
2✔
26

27
        if (!argv[1])
2✔
28
                return 0;
29

30
        r = unit_name_mangle_with_suffix(argv[1], "as target",
2✔
31
                                         arg_quiet ? 0 : UNIT_NAME_MANGLE_WARN,
2✔
32
                                         ".target", &target);
33
        if (r < 0)
2✔
34
                return log_error_errno(r, "Failed to mangle unit name: %m");
×
35

36
        r = mangle_names("as dependency", strv_skip(argv, 2), &names);
2✔
37
        if (r < 0)
2✔
38
                return r;
39

40
        if (streq(verb, "add-wants"))
2✔
41
                dep = UNIT_WANTS;
42
        else if (streq(verb, "add-requires"))
1✔
43
                dep = UNIT_REQUIRES;
44
        else
45
                assert_not_reached();
×
46

47
        if (install_client_side() != INSTALL_CLIENT_SIDE_NO) {
2✔
48
                InstallChange *changes = NULL;
×
49
                size_t n_changes = 0;
×
50

51
                CLEANUP_ARRAY(changes, n_changes, install_changes_free);
×
52

53
                r = unit_file_add_dependency(arg_runtime_scope, unit_file_flags_from_args(), arg_root, names, target, dep, &changes, &n_changes);
×
NEW
54
                r = install_changes_dump(r, "add dependency on", changes, n_changes, arg_quiet);
×
55
                if (r < 0)
×
56
                        return r;
×
57
        } else {
58
                _cleanup_(sd_bus_message_unrefp) sd_bus_message *reply = NULL, *m = NULL;
4✔
59
                _cleanup_(sd_bus_error_free) sd_bus_error error = SD_BUS_ERROR_NULL;
2✔
60
                sd_bus *bus;
2✔
61

62
                r = acquire_bus(BUS_MANAGER, &bus);
2✔
63
                if (r < 0)
2✔
64
                        return r;
65

66
                polkit_agent_open_maybe();
2✔
67

68
                r = bus_message_new_method_call(bus, &m, bus_systemd_mgr, "AddDependencyUnitFiles");
2✔
69
                if (r < 0)
2✔
70
                        return bus_log_create_error(r);
×
71

72
                r = sd_bus_message_append_strv(m, names);
2✔
73
                if (r < 0)
2✔
74
                        return bus_log_create_error(r);
×
75

76
                r = sd_bus_message_append(m, "ssbb", target, unit_dependency_to_string(dep), arg_runtime, arg_force);
2✔
77
                if (r < 0)
2✔
78
                        return bus_log_create_error(r);
×
79

80
                r = sd_bus_call(bus, m, 0, &error, &reply);
2✔
81
                if (r < 0)
2✔
82
                        return log_error_errno(r, "Failed to add dependency: %s", bus_error_message(&error, r));
×
83

84
                r = bus_deserialize_and_dump_unit_file_changes(reply, arg_quiet);
2✔
85
                if (r < 0)
2✔
86
                        return r;
87

88
                if (!arg_no_reload) {
2✔
89
                        r = daemon_reload(ACTION_RELOAD, /* graceful= */ false);
2✔
90
                        if (r < 0)
2✔
91
                                return r;
92
                }
93
        }
94

95
        return 0;
96
}
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