]> git.ipfire.org Git - thirdparty/nftables.git/commitdiff
scanner: remove parser_state->indescs static array
authorLaurent Fasnacht <fasnacht@protonmail.ch>
Mon, 10 Feb 2020 10:17:24 +0000 (10:17 +0000)
committerPablo Neira Ayuso <pablo@netfilter.org>
Thu, 13 Feb 2020 12:03:15 +0000 (13:03 +0100)
This static array is redundant with the indesc_list structure, but
is less flexible.

Signed-off-by: Laurent Fasnacht <fasnacht@protonmail.ch>
Signed-off-by: Pablo Neira Ayuso <pablo@netfilter.org>
include/parser.h
src/scanner.l

index 949284d9466c62797bfd7d35e33bc25c92f27a65..66db92d8d772037e4f93fd066c035875895ad074 100644 (file)
@@ -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;
 
index ecf2354e3c2f812609553b7148a3fee271d9b58e..e982cd41318b882bacba14d3077c21125565faf4 100644 (file)
@@ -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)