mirror of
https://github.com/systemd/systemd.git
synced 2024-11-27 20:23:36 +08:00
core/unit: unit_is_filtered() -> unit_passes_filter() and invert logic
Follow-up for 6d2984d21b
The current semantics of "filtered" in unit_is_filtered()
are actually the contrary of ListUnitsFiltered(). Let's
make things consistent, i.e. return true when the unit
shall be included.
This commit is contained in:
parent
6c8ade3066
commit
6e0f959360
@ -235,7 +235,6 @@ bool strv_fnmatch_full(char* const* patterns, const char *s, int flags, size_t *
|
||||
static inline bool strv_fnmatch(char* const* patterns, const char *s) {
|
||||
return strv_fnmatch_full(patterns, s, 0, NULL);
|
||||
}
|
||||
|
||||
static inline bool strv_fnmatch_or_empty(char* const* patterns, const char *s, int flags) {
|
||||
assert(s);
|
||||
return strv_isempty(patterns) ||
|
||||
|
@ -1218,7 +1218,7 @@ static int list_units_filtered(sd_bus_message *message, void *userdata, sd_bus_e
|
||||
if (k != u->id)
|
||||
continue;
|
||||
|
||||
if (unit_is_filtered(u, states, patterns))
|
||||
if (!unit_passes_filter(u, states, patterns))
|
||||
continue;
|
||||
|
||||
r = reply_unit_info(reply, u);
|
||||
|
@ -6472,20 +6472,20 @@ int unit_arm_timer(
|
||||
return 0;
|
||||
}
|
||||
|
||||
bool unit_is_filtered(Unit *u, char *const *states, char *const *patterns) {
|
||||
bool unit_passes_filter(Unit *u, char * const *states, char * const *patterns) {
|
||||
assert(u);
|
||||
|
||||
if (!strv_isempty(states)) {
|
||||
char *const *unit_states = STRV_MAKE(
|
||||
char * const *unit_states = STRV_MAKE(
|
||||
unit_load_state_to_string(u->load_state),
|
||||
unit_active_state_to_string(unit_active_state(u)),
|
||||
unit_sub_state_to_string(u));
|
||||
|
||||
if (!strv_overlap(states, unit_states))
|
||||
return true;
|
||||
return false;
|
||||
}
|
||||
|
||||
return !strv_isempty(patterns) && !strv_fnmatch_or_empty(patterns, u->id, FNM_NOESCAPE);
|
||||
return strv_fnmatch_or_empty(patterns, u->id, FNM_NOESCAPE);
|
||||
}
|
||||
|
||||
static int unit_get_nice(Unit *u) {
|
||||
|
@ -1040,7 +1040,7 @@ Condition *unit_find_failed_condition(Unit *u);
|
||||
|
||||
int unit_arm_timer(Unit *u, sd_event_source **source, bool relative, usec_t usec, sd_event_time_handler_t handler);
|
||||
|
||||
bool unit_is_filtered(Unit *u, char *const *states, char *const *patterns);
|
||||
bool unit_passes_filter(Unit *u, char * const *states, char * const *patterns);
|
||||
|
||||
int unit_compare_priority(Unit *a, Unit *b);
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user