![]() |
|
Message-ID: <20250414151754.GB288056@port70.net> Date: Mon, 14 Apr 2025 17:17:54 +0200 From: Szabolcs Nagy <nsz@...t70.net> To: Anton Moryakov <ant.v.moryakov@...il.com> Cc: musl@...ts.openwall.com Subject: Re: [PATCH] src: regex: Remove unreachable code in tre_copy_ast() in * Anton Moryakov <ant.v.moryakov@...il.com> [2025-02-16 20:02:11 +0300]: > Static analyzer reported: > UNREACHABLE_CODE This statement in the source code might be unreachable during program execution. > > Corrections explained: > The check if (status != REG_OK) break; inside the while loop was unnecessary > because the loop condition while (status == REG_OK && tre_stack_num_objects(stack) > bottom) > already ensures that status is REG_OK. > > Since status != REG_OK can never be true within the loop, the break statement > was unreachable and has been removed. > > This change does not alter the program's behavior but improves code clarity. > > Triggers found by static analyzer Svace. > > Signed-off-by: Anton Moryakov <ant.v.moryakov@...il.com> fwiw, this change looks ok. it is a cosmetic change only. > > --- > src/regex/regcomp.c | 5 ----- > 1 file changed, 5 deletions(-) > > diff --git a/src/regex/regcomp.c b/src/regex/regcomp.c > index fb24556e..8c637bdc 100644 > --- a/src/regex/regcomp.c > +++ b/src/regex/regcomp.c > @@ -1701,8 +1701,6 @@ tre_copy_ast(tre_mem_t mem, tre_stack_t *stack, tre_ast_node_t *ast, > while (status == REG_OK && tre_stack_num_objects(stack) > bottom) > { > tre_ast_node_t *node; > - if (status != REG_OK) > - break; > > symbol = (tre_copyast_symbol_t)tre_stack_pop_int(stack); > switch (symbol) > @@ -1849,9 +1847,6 @@ tre_expand_ast(tre_mem_t mem, tre_stack_t *stack, tre_ast_node_t *ast, > tre_ast_node_t *node; > tre_expand_ast_symbol_t symbol; > > - if (status != REG_OK) > - break; > - > symbol = (tre_expand_ast_symbol_t)tre_stack_pop_int(stack); > node = tre_stack_pop_voidptr(stack); > switch (symbol) > -- > 2.30.2
Powered by blists - more mailing lists
Confused about mailing lists and their use? Read about mailing lists on Wikipedia and check out these guidelines on proper formatting of your messages.