From 4677971a01dc4d92087dab139428cf4eaa189536 Mon Sep 17 00:00:00 2001 From: Phil Sutter Date: Mon, 18 Jun 2018 10:11:46 +0200 Subject: libnftables: Simplify nft_run_cmd_from_buffer footprint With libnftables documentation being upstream and one confirmed external user (nftlb), time to break the API! First of all, the command buffer passed to nft_run_cmd_from_buffer may (and should) be const. One should consider it a bug if that function ever changed it's content. On the other hand, there is no point in passing the buffer's length as separate argument: NULL bytes are not expected to occur in the input, so it is safe to rely upon strlen(). Also, the actual parsers don't require a buffer length passed to them, either. The only use-case for it is when reallocating the buffer to append a final newline character, there strlen() is perfectly sufficient. Suggested-by: Harald Welte Cc: Laura Garcia Liebana Cc: Eric Leblond Cc: Arturo Borrero Gonzalez Signed-off-by: Phil Sutter Signed-off-by: Pablo Neira Ayuso --- src/cli.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'src/cli.c') diff --git a/src/cli.c b/src/cli.c index 241ea010..ca3869ab 100644 --- a/src/cli.c +++ b/src/cli.c @@ -110,7 +110,7 @@ static void cli_complete(char *line) if (hist == NULL || strcmp(hist->line, line)) add_history(line); - nft_run_cmd_from_buffer(cli_nft, line, strlen(line) + 1); + nft_run_cmd_from_buffer(cli_nft, line); xfree(line); } -- cgit v1.2.3