perf tools: Fix regcomp() error detection in SDT probes
PATCH 1/1 perf tools: Fix regcomp() error detection in SDT probes
The regcomp() function returns 0 on success and a non-zero error code on failure, not negative values. The current code incorrectly checks for ret < 0, which would miss positive error codes returned by regcomp().
Fix the error checking in sdt_init_op_regex() and arch_sdt_arg_parse_op() to properly check for non-zero return values using ret != 0, ensuring all regcomp() failures are correctly detected and handled.
Signed-off-by Kaushlendra Kumar <[email protected]>
--- tools/perf/arch/x86/util/perf_regs.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-)
tools/perf/arch/x86/util/perf_regs.c +2 -2
@@ -156,7 +156,7 @@ static int sdt_init_op_regex(void)return 0 ; ret =regcomp (&sdt_op_regex,SDT_OP_REGEX ,REG_EXTENDED ); -if (ret <0 ) { +if (ret !=0 ) {pr_debug4 ("Regex compilation error.\n" );return ret; }
@@ -215,7 +215,7 @@ int arch_sdt_arg_parse_op(char *old_op, char **new_op)char prefix[3 ] = {0 }; ret =sdt_init_op_regex (); -if (ret <0 ) +if (ret !=0 )return ret;/*
Signature · 1 line
2.34.1