summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorPhil Sutter <phil@nwl.cc>2019-07-22 12:16:23 +0200
committerPablo Neira Ayuso <pablo@netfilter.org>2019-07-23 21:14:40 +0200
commitfeb155019761cb35a3edfe1152c0aedbdaa65f7f (patch)
tree0a0b076b84e21f96bfc5e96c64590cc933c9c3d0
parent80e1d5cba738d0b9b7f5ffab8e5e7d02d6b06eeb (diff)
xtables-save: Avoid mixed code and declarations
Also move time() calls to where they are used. Signed-off-by: Phil Sutter <phil@nwl.cc> Signed-off-by: Pablo Neira Ayuso <pablo@netfilter.org>
-rw-r--r--iptables/xtables-save.c8
1 files changed, 4 insertions, 4 deletions
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;
}