From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-9.7 required=3.0 tests=HEADER_FROM_DIFFERENT_DOMAINS, INCLUDES_PATCH,MAILING_LIST_MULTI,SIGNED_OFF_BY,SPF_HELO_NONE,SPF_PASS, URIBL_BLOCKED,USER_AGENT_GIT autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 68FB6C76186 for ; Sat, 20 Jul 2019 16:31:03 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id 4A7552085A for ; Sat, 20 Jul 2019 16:31:03 +0000 (UTC) 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 Content-Transfer-Encoding: 8bit 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; } -- 2.22.0