From: Laurent Fasnacht Date: Mon, 10 Feb 2020 10:17:24 +0000 (+0000) Subject: scanner: remove parser_state->indescs static array X-Git-Tag: v0.9.4~67 X-Git-Url: http://git.ipfire.org/?a=commitdiff_plain;h=ad63cde708fd7a79332b09ae4a06b8a4b345aa72;p=thirdparty%2Fnftables.git scanner: remove parser_state->indescs static array This static array is redundant with the indesc_list structure, but is less flexible. Signed-off-by: Laurent Fasnacht Signed-off-by: Pablo Neira Ayuso --- diff --git a/include/parser.h b/include/parser.h index 949284d9..66db92d8 100644 --- a/include/parser.h +++ b/include/parser.h @@ -15,7 +15,6 @@ struct parser_state { struct input_descriptor *indesc; - struct input_descriptor *indescs[MAX_INCLUDE_DEPTH]; unsigned int indesc_idx; struct list_head indesc_list; diff --git a/src/scanner.l b/src/scanner.l index ecf2354e..e982cd41 100644 --- a/src/scanner.l +++ b/src/scanner.l @@ -668,19 +668,20 @@ addrstring ({macaddr}|{ip4addr}|{ip6addr}) static void scanner_push_indesc(struct parser_state *state, struct input_descriptor *indesc) { - state->indescs[state->indesc_idx] = indesc; - state->indesc = state->indescs[state->indesc_idx++]; list_add_tail(&indesc->list, &state->indesc_list); + state->indesc = indesc; + state->indesc_idx++; } static void scanner_pop_indesc(struct parser_state *state) { state->indesc_idx--; - - if (state->indesc_idx > 0) - state->indesc = state->indescs[state->indesc_idx - 1]; - else + if (!list_empty(&state->indesc_list)) { + state->indesc = list_entry(state->indesc->list.prev, + struct input_descriptor, list); + } else { state->indesc = NULL; + } } static void scanner_pop_buffer(yyscan_t scanner)