From: Phil Sutter Date: Mon, 22 Jul 2019 10:16:23 +0000 (+0200) Subject: xtables-save: Avoid mixed code and declarations X-Git-Tag: v1.8.4~93 X-Git-Url: http://git.ipfire.org/?a=commitdiff_plain;h=feb155019761cb35a3edfe1152c0aedbdaa65f7f;p=thirdparty%2Fiptables.git xtables-save: Avoid mixed code and declarations Also move time() calls to where they are used. Signed-off-by: Phil Sutter Signed-off-by: Pablo Neira Ayuso --- diff --git a/iptables/xtables-save.c b/iptables/xtables-save.c index 484450f0..ac452f1d 100644 --- a/iptables/xtables-save.c +++ b/iptables/xtables-save.c @@ -71,6 +71,7 @@ __do_output(struct nft_handle *h, const char *tablename, void *data) { struct nftnl_chain_list *chain_list; struct do_output_data *d = data; + time_t now; if (!nft_table_builtin_find(h, tablename)) return 0; @@ -85,19 +86,18 @@ __do_output(struct nft_handle *h, const char *tablename, void *data) if (!chain_list) return 0; - time_t now = time(NULL); - + now = time(NULL); printf("# Generated by %s v%s on %s", prog_name, prog_vers, ctime(&now)); - printf("*%s\n", tablename); + printf("*%s\n", tablename); /* Dump out chain names first, * thereby preventing dependency conflicts */ nft_chain_save(h, chain_list); nft_rule_save(h, tablename, d->counters ? 0 : FMT_NOCOUNTS); + printf("COMMIT\n"); now = time(NULL); - printf("COMMIT\n"); printf("# Completed on %s", ctime(&now)); return 0; }