From: Francis Deslauriers Date: Fri, 5 May 2017 17:45:36 +0000 (-0400) Subject: Fix: Exclusion check iterates multiple times on same array X-Git-Tag: v2.11.0-rc1~602 X-Git-Url: https://git.lttng.org./?a=commitdiff_plain;h=8aa579d4f55ead9a3e14f5fde3be039eedc891ea;p=lttng-tools.git Fix: Exclusion check iterates multiple times on same array When specifying exclusions not contained in the event string warning message is printed more than once. For example, running the following command: lttng enable-event -u 'event_name_*' --exclude=not_event,other_event,my_event Will result in this warning: Warning: Event event_name_*: not_event does not exclude any events from event_name_* Warning: Event event_name_*: other_event does not exclude any events from event_name_* Warning: Event event_name_*: my_event does not exclude any events from event_name_* Warning: Event event_name_*: other_event does not exclude any events from event_name_* Warning: Event event_name_*: my_event does not exclude any events from event_name_* Warning: Event event_name_*: my_event does not exclude any events from event_name_* The following should be printed: Warning: Event event_name_*: not_event does not exclude any events from event_name_* Warning: Event event_name_*: other_event does not exclude any events from event_name_* Warning: Event event_name_*: my_event does not exclude any events from event_name_* This is due to a bad indexing of the exclusions array. Since we are already iterating on the exclusions array, pass the exclusions directly with check_exclusion_subset(). Signed-off-by: Francis Deslauriers Signed-off-by: Jérémie Galarneau --- diff --git a/src/bin/lttng/commands/enable_events.c b/src/bin/lttng/commands/enable_events.c index cc79b0b74..0c001fd9e 100644 --- a/src/bin/lttng/commands/enable_events.c +++ b/src/bin/lttng/commands/enable_events.c @@ -504,24 +504,6 @@ end: return ret; } -static -int check_exclusions_subsets(const char *event_name, - char * const *exclusions) -{ - int ret = 0; - char * const *item; - - for (item = exclusions; *item; item++) { - ret = check_exclusion_subsets(event_name, *item); - if (ret) { - goto end; - } - } - -end: - return ret; -} - static int create_exclusion_list_and_validate(const char *event_name, const char *exclusions_arg, @@ -554,8 +536,7 @@ int create_exclusion_list_and_validate(const char *event_name, for (exclusion = exclusions; *exclusion; exclusion++) { if (!strutils_is_star_glob_pattern(*exclusion) || strutils_is_star_at_the_end_only_glob_pattern(*exclusion)) { - ret = check_exclusions_subsets( - event_name, exclusion); + ret = check_exclusion_subsets(event_name, *exclusion); if (ret) { goto error; }