From a5e89843a77c234f1f858737b676161ff8ee0227 Mon Sep 17 00:00:00 2001 From: Phil Sutter Date: Wed, 20 Jun 2018 09:22:00 +0200 Subject: [PATCH] cli: Drop pointless check in cli_append_multiline() Bugzilla: https://bugzilla.redhat.com/show_bug.cgi?id=1504157 Upstream Status: nftables commit f51ed1db70abd Conflicts: Context change due to missing commit 4c15b4008c249 ("cli: Use nft_run_cmd_from_buffer()") commit f51ed1db70abdbb909e81bc670ffdfa05f421257 Author: Phil Sutter Date: Thu Mar 1 15:00:27 2018 +0100 cli: Drop pointless check in cli_append_multiline() The function is called from cli_complete after it has checked for line to be != NULL. The other part of the conditional, namely multiline being NULL, is perfectly valid (if the last read line didn't end with backslash. Hence drop the conditional completely. Since variable eof is not used anywhere outside of the dropped conditional, get rid of it completely. Signed-off-by: Phil Sutter Signed-off-by: Pablo Neira Ayuso --- src/cli.c | 12 ++---------- 1 file changed, 2 insertions(+), 10 deletions(-) diff --git a/src/cli.c b/src/cli.c index cadc3af..53427a0 100644 --- a/src/cli.c +++ b/src/cli.c @@ -46,21 +46,13 @@ static struct mnl_socket *cli_nf_sock; static void *scanner; static char histfile[PATH_MAX]; static char *multiline; -static bool eof; static char *cli_append_multiline(char *line) { + size_t len = strlen(line); bool complete = false; - size_t len; char *s; - if (line == NULL && multiline == NULL) { - eof = true; - return NULL; - } - - len = strlen(line); - if (len == 0) return NULL; @@ -174,7 +166,7 @@ int cli_init(struct nft_ctx *nft, struct mnl_socket *nf_sock, state = _state; scanner = scanner_init(state); - while (!eof) + while (true) rl_callback_read_char(); return 0; } -- 1.8.3.1