Commit 861fb107 authored by Joe Perches's avatar Joe Perches Committed by Pablo Neira Ayuso

netfilter: Use correct return for seq_show functions

Using seq_has_overflowed doesn't produce the right return value.
Either 0 or -1 is, but 0 is much more common and works well when
seq allocation retries.

I believe this doesn't matter as the initial allocation is always
sufficient, this is just a correctness patch.

Miscellanea:

o Don't use strlen, use *ptr to determine if a string
  should be emitted like all the other tests here
o Delete unnecessary return statements
Signed-off-by: default avatarJoe Perches <joe@perches.com>
Signed-off-by: default avatarPablo Neira Ayuso <pablo@netfilter.org>
parent 55917a21
...@@ -1257,7 +1257,7 @@ static int seq_show(struct seq_file *s, void *v) ...@@ -1257,7 +1257,7 @@ static int seq_show(struct seq_file *s, void *v)
inst->copy_mode, inst->copy_range, inst->copy_mode, inst->copy_range,
inst->queue_dropped, inst->queue_user_dropped, inst->queue_dropped, inst->queue_user_dropped,
inst->id_sequence, 1); inst->id_sequence, 1);
return seq_has_overflowed(s); return 0;
} }
static const struct seq_operations nfqnl_seq_ops = { static const struct seq_operations nfqnl_seq_ops = {
......
...@@ -947,11 +947,9 @@ static int xt_table_seq_show(struct seq_file *seq, void *v) ...@@ -947,11 +947,9 @@ static int xt_table_seq_show(struct seq_file *seq, void *v)
{ {
struct xt_table *table = list_entry(v, struct xt_table, list); struct xt_table *table = list_entry(v, struct xt_table, list);
if (strlen(table->name)) { if (*table->name)
seq_printf(seq, "%s\n", table->name); seq_printf(seq, "%s\n", table->name);
return seq_has_overflowed(seq); return 0;
} else
return 0;
} }
static const struct seq_operations xt_table_seq_ops = { static const struct seq_operations xt_table_seq_ops = {
...@@ -1087,10 +1085,8 @@ static int xt_match_seq_show(struct seq_file *seq, void *v) ...@@ -1087,10 +1085,8 @@ static int xt_match_seq_show(struct seq_file *seq, void *v)
if (trav->curr == trav->head) if (trav->curr == trav->head)
return 0; return 0;
match = list_entry(trav->curr, struct xt_match, list); match = list_entry(trav->curr, struct xt_match, list);
if (*match->name == '\0') if (*match->name)
return 0; seq_printf(seq, "%s\n", match->name);
seq_printf(seq, "%s\n", match->name);
return seq_has_overflowed(seq);
} }
return 0; return 0;
} }
...@@ -1142,10 +1138,8 @@ static int xt_target_seq_show(struct seq_file *seq, void *v) ...@@ -1142,10 +1138,8 @@ static int xt_target_seq_show(struct seq_file *seq, void *v)
if (trav->curr == trav->head) if (trav->curr == trav->head)
return 0; return 0;
target = list_entry(trav->curr, struct xt_target, list); target = list_entry(trav->curr, struct xt_target, list);
if (*target->name == '\0') if (*target->name)
return 0; seq_printf(seq, "%s\n", target->name);
seq_printf(seq, "%s\n", target->name);
return seq_has_overflowed(seq);
} }
return 0; return 0;
} }
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment