]> git.ipfire.org Git - thirdparty/nftables.git/commitdiff
scanner: use list_is_first() from scanner_pop_indesc()
authorPablo Neira Ayuso <pablo@netfilter.org>
Thu, 13 Feb 2020 12:27:18 +0000 (13:27 +0100)
committerPablo Neira Ayuso <pablo@netfilter.org>
Thu, 13 Feb 2020 12:31:31 +0000 (13:31 +0100)
!list_empty() always stands true since the list is never empty
when calling scanner_pop_indesc().

Check for list_is_first() which actually tells us this is the
initial input file, hence, state->indesc is set to NULL.

Signed-off-by: Pablo Neira Ayuso <pablo@netfilter.org>
include/list.h
src/scanner.l

index 75d29212401012034964db7c9e6327741001076d..9c4da81749dede81fe981e4fcedd6a4bdee8136a 100644 (file)
@@ -33,6 +33,17 @@ static inline void init_list_head(struct list_head *list)
        list->prev = list;
 }
 
+/**
+ * list_is_first -- tests whether @list is the first entry in list @head
+ * @list: the entry to test
+ * @head: the head of the list
+ */
+static inline int list_is_first(const struct list_head *list,
+                               const struct list_head *head)
+{
+       return list->prev == head;
+}
+
 /*
  * Insert a new entry between two known consecutive entries.
  *
index ed29833b6fc49e648d5da11a2dd3c78c439cb295..3932883b9adee8039f95c8bc6458b4512dd7f418 100644 (file)
@@ -678,7 +678,7 @@ static void scanner_push_indesc(struct parser_state *state,
 
 static void scanner_pop_indesc(struct parser_state *state)
 {
-       if (!list_empty(&state->indesc_list)) {
+       if (!list_is_first(&state->indesc->list, &state->indesc_list)) {
                state->indesc = list_entry(state->indesc->list.prev,
                                           struct input_descriptor, list);
        } else {