[v4,04/11] trace: rework loop on trace points
Checks
Commit Message
Directly skip the block when a trace point does not match the user
criteria.
Signed-off-by: David Marchand <david.marchand@redhat.com>
Acked-by: Jerin Jacob <jerinj@marvell.com>
Acked-by: Sunil Kumar Kori <skori@marvell.com>
---
lib/eal/common/eal_common_trace.c | 34 +++++++++++++++++--------------
1 file changed, 19 insertions(+), 15 deletions(-)
@@ -186,15 +186,18 @@ rte_trace_pattern(const char *pattern, bool enable)
int rc = 0, found = 0;
STAILQ_FOREACH(tp, &tp_list, next) {
- if (fnmatch(pattern, tp->name, 0) == 0) {
- if (enable)
- rc = rte_trace_point_enable(tp->handle);
- else
- rc = rte_trace_point_disable(tp->handle);
- found = 1;
+ if (fnmatch(pattern, tp->name, 0) != 0)
+ continue;
+
+ if (enable)
+ rc = rte_trace_point_enable(tp->handle);
+ else
+ rc = rte_trace_point_disable(tp->handle);
+ if (rc < 0) {
+ found = 0;
+ break;
}
- if (rc < 0)
- return rc;
+ found = 1;
}
return rc | found;
@@ -211,17 +214,18 @@ rte_trace_regexp(const char *regex, bool enable)
return -EINVAL;
STAILQ_FOREACH(tp, &tp_list, next) {
- if (regexec(&r, tp->name, 0, NULL, 0) == 0) {
- if (enable)
- rc = rte_trace_point_enable(tp->handle);
- else
- rc = rte_trace_point_disable(tp->handle);
- found = 1;
- }
+ if (regexec(&r, tp->name, 0, NULL, 0) != 0)
+ continue;
+
+ if (enable)
+ rc = rte_trace_point_enable(tp->handle);
+ else
+ rc = rte_trace_point_disable(tp->handle);
if (rc < 0) {
found = 0;
break;
}
+ found = 1;
}
regfree(&r);