[iptables,07/12] xtables-save: Avoid mixed code and declarations
diff mbox series

Message ID 20190720163026.15410-8-phil@nwl.cc
State Changes Requested
Delegated to: Pablo Neira
Headers show
Series
  • Larger xtables-save review
Related show

Commit Message

Phil Sutter July 20, 2019, 4:30 p.m. UTC
Also move time() calls to where they are used.

Signed-off-by: Phil Sutter <phil@nwl.cc>
---
 iptables/xtables-save.c | 8 ++++----
 1 file changed, 4 insertions(+), 4 deletions(-)

Patch
diff mbox series

diff --git a/iptables/xtables-save.c b/iptables/xtables-save.c
index 484450f03354f..ac452f1dd6f14 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;
 }