From patchwork Sat Jul 20 16:30:21 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Phil Sutter X-Patchwork-Id: 1134402 X-Patchwork-Delegate: pablo@netfilter.org Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Authentication-Results: ozlabs.org; spf=none (mailfrom) smtp.mailfrom=vger.kernel.org (client-ip=209.132.180.67; helo=vger.kernel.org; envelope-from=netfilter-devel-owner@vger.kernel.org; receiver=) Authentication-Results: ozlabs.org; dmarc=none (p=none dis=none) header.from=nwl.cc Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by ozlabs.org (Postfix) with ESMTP id 45rYK33qbCz9sNC for ; Sun, 21 Jul 2019 02:31:03 +1000 (AEST) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726655AbfGTQbD (ORCPT ); Sat, 20 Jul 2019 12:31:03 -0400 Received: from orbyte.nwl.cc ([151.80.46.58]:40904 "EHLO orbyte.nwl.cc" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726300AbfGTQbC (ORCPT ); Sat, 20 Jul 2019 12:31:02 -0400 Received: from localhost ([::1]:53994 helo=tatos) by orbyte.nwl.cc with esmtp (Exim 4.91) (envelope-from ) id 1hosGD-0005Sy-BQ; Sat, 20 Jul 2019 18:31:01 +0200 From: Phil Sutter To: Pablo Neira Ayuso Cc: netfilter-devel@vger.kernel.org Subject: [iptables PATCH 07/12] xtables-save: Avoid mixed code and declarations Date: Sat, 20 Jul 2019 18:30:21 +0200 Message-Id: <20190720163026.15410-8-phil@nwl.cc> X-Mailer: git-send-email 2.22.0 In-Reply-To: <20190720163026.15410-1-phil@nwl.cc> References: <20190720163026.15410-1-phil@nwl.cc> MIME-Version: 1.0 Sender: netfilter-devel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: netfilter-devel@vger.kernel.org Also move time() calls to where they are used. Signed-off-by: Phil Sutter --- iptables/xtables-save.c | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) 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; }