summaryrefslogtreecommitdiff
path: root/src/analyze/analyze.c
diff options
context:
space:
mode:
Diffstat (limited to 'src/analyze/analyze.c')
-rw-r--r--src/analyze/analyze.c46
1 files changed, 26 insertions, 20 deletions
diff --git a/src/analyze/analyze.c b/src/analyze/analyze.c
index ab7fb53269..d1ff156d12 100644
--- a/src/analyze/analyze.c
+++ b/src/analyze/analyze.c
@@ -582,8 +582,7 @@ static int analyze_plot(sd_bus *bus) {
if (u->activating < boot->userspace_time ||
u->activating > boot->finish_time) {
- free(u->name);
- u->name = NULL;
+ u->name = mfree(u->name);
continue;
}
@@ -845,11 +844,8 @@ static int list_dependencies_one(sd_bus *bus, const char *name, unsigned int lev
STRV_FOREACH(c, deps) {
times = hashmap_get(unit_times_hashmap, *c);
- if (times && times->activated
- && times->activated <= boot->finish_time
- && (service_longest - times->activated) <= arg_fuzz) {
+ if (times && times->activated && times->activated <= boot->finish_time && (service_longest - times->activated) <= arg_fuzz)
to_print++;
- }
}
if (!to_print)
@@ -1016,7 +1012,7 @@ static int analyze_time(sd_bus *bus) {
return 0;
}
-static int graph_one_property(sd_bus *bus, const UnitInfo *u, const char* prop, const char *color, char* patterns[]) {
+static int graph_one_property(sd_bus *bus, const UnitInfo *u, const char* prop, const char *color, char* patterns[], char* from_patterns[], char* to_patterns[]) {
_cleanup_strv_free_ char **units = NULL;
char **unit;
int r;
@@ -1028,9 +1024,9 @@ static int graph_one_property(sd_bus *bus, const UnitInfo *u, const char* prop,
match_patterns = strv_fnmatch(patterns, u->id, 0);
- if (!strv_isempty(arg_dot_from_patterns) &&
+ if (!strv_isempty(from_patterns) &&
!match_patterns &&
- !strv_fnmatch(arg_dot_from_patterns, u->id, 0))
+ !strv_fnmatch(from_patterns, u->id, 0))
return 0;
r = bus_get_unit_property_strv(bus, u->unit_path, prop, &units);
@@ -1042,9 +1038,9 @@ static int graph_one_property(sd_bus *bus, const UnitInfo *u, const char* prop,
match_patterns2 = strv_fnmatch(patterns, *unit, 0);
- if (!strv_isempty(arg_dot_to_patterns) &&
+ if (!strv_isempty(to_patterns) &&
!match_patterns2 &&
- !strv_fnmatch(arg_dot_to_patterns, *unit, 0))
+ !strv_fnmatch(to_patterns, *unit, 0))
continue;
if (!strv_isempty(patterns) && !match_patterns && !match_patterns2)
@@ -1056,35 +1052,35 @@ static int graph_one_property(sd_bus *bus, const UnitInfo *u, const char* prop,
return 0;
}
-static int graph_one(sd_bus *bus, const UnitInfo *u, char *patterns[]) {
+static int graph_one(sd_bus *bus, const UnitInfo *u, char *patterns[], char *from_patterns[], char *to_patterns[]) {
int r;
assert(bus);
assert(u);
if (arg_dot == DEP_ORDER ||arg_dot == DEP_ALL) {
- r = graph_one_property(bus, u, "After", "green", patterns);
+ r = graph_one_property(bus, u, "After", "green", patterns, from_patterns, to_patterns);
if (r < 0)
return r;
}
if (arg_dot == DEP_REQUIRE ||arg_dot == DEP_ALL) {
- r = graph_one_property(bus, u, "Requires", "black", patterns);
+ r = graph_one_property(bus, u, "Requires", "black", patterns, from_patterns, to_patterns);
if (r < 0)
return r;
- r = graph_one_property(bus, u, "RequiresOverridable", "black", patterns);
+ r = graph_one_property(bus, u, "RequiresOverridable", "black", patterns, from_patterns, to_patterns);
if (r < 0)
return r;
- r = graph_one_property(bus, u, "RequisiteOverridable", "darkblue", patterns);
+ r = graph_one_property(bus, u, "RequisiteOverridable", "darkblue", patterns, from_patterns, to_patterns);
if (r < 0)
return r;
- r = graph_one_property(bus, u, "Wants", "grey66", patterns);
+ r = graph_one_property(bus, u, "Wants", "grey66", patterns, from_patterns, to_patterns);
if (r < 0)
return r;
- r = graph_one_property(bus, u, "Conflicts", "red", patterns);
+ r = graph_one_property(bus, u, "Conflicts", "red", patterns, from_patterns, to_patterns);
if (r < 0)
return r;
- r = graph_one_property(bus, u, "ConflictedBy", "red", patterns);
+ r = graph_one_property(bus, u, "ConflictedBy", "red", patterns, from_patterns, to_patterns);
if (r < 0)
return r;
}
@@ -1138,6 +1134,8 @@ static int dot(sd_bus *bus, char* patterns[]) {
_cleanup_bus_message_unref_ sd_bus_message *reply = NULL;
_cleanup_bus_error_free_ sd_bus_error error = SD_BUS_ERROR_NULL;
_cleanup_strv_free_ char **expanded_patterns = NULL;
+ _cleanup_strv_free_ char **expanded_from_patterns = NULL;
+ _cleanup_strv_free_ char **expanded_to_patterns = NULL;
int r;
UnitInfo u;
@@ -1145,6 +1143,14 @@ static int dot(sd_bus *bus, char* patterns[]) {
if (r < 0)
return r;
+ r = expand_patterns(bus, arg_dot_from_patterns, &expanded_from_patterns);
+ if (r < 0)
+ return r;
+
+ r = expand_patterns(bus, arg_dot_to_patterns, &expanded_to_patterns);
+ if (r < 0)
+ return r;
+
r = sd_bus_call_method(
bus,
"org.freedesktop.systemd1",
@@ -1167,7 +1173,7 @@ static int dot(sd_bus *bus, char* patterns[]) {
while ((r = bus_parse_unit_info(reply, &u)) > 0) {
- r = graph_one(bus, &u, expanded_patterns);
+ r = graph_one(bus, &u, expanded_patterns, expanded_from_patterns, expanded_to_patterns);
if (r < 0)
return r;
}