From patchwork Wed Sep 27 11:44:52 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Harsha Sharma X-Patchwork-Id: 819101 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; dkim=fail reason="signature verification failed" (2048-bit key; unprotected) header.d=gmail.com header.i=@gmail.com header.b="Ocd0F88E"; dkim-atps=neutral Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by ozlabs.org (Postfix) with ESMTP id 3y2GJr25Brz9tXb for ; Wed, 27 Sep 2017 21:47:24 +1000 (AEST) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1751985AbdI0LrK (ORCPT ); Wed, 27 Sep 2017 07:47:10 -0400 Received: from mail-pg0-f65.google.com ([74.125.83.65]:34225 "EHLO mail-pg0-f65.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1750854AbdI0LrJ (ORCPT ); Wed, 27 Sep 2017 07:47:09 -0400 Received: by mail-pg0-f65.google.com with SMTP id u18so8964024pgo.1; Wed, 27 Sep 2017 04:47:09 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:cc:subject:date:message-id; bh=gwRgVbP/BnI5fmhvhXKdFZ1JOUTXhe80a6s2mXNx25s=; b=Ocd0F88EiE7UXg4HyhLUqdUtMIMzMjB5lSkWHs8L+zJvNHxYMfQIE3xqia/bUM5uhS yw+8mxJyi+aaEqC3qkUqNo5xsl6d3zhKc/n2m2U4B/9b/AvoTiE3+q3NkpZI+n5Z+oKz hdwa4W+XBhIElk1Zul5uqlq/Q9DU6k8svr7uF+Xs6uABLsPToC1OajEj6nNKPQ23mKuz 4isYDZXVZYzyeXsXIu4bGpDYMgYA8CcGcsUDTZARvzx2umI0E0pwmn0VKBcfaNDbGqHs Th16XrUYB8vsz8YMcJynDsto0P7PHWqOtJC0k99yt0avIi4pR01sashQVffZmzW7SVuk lkmw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id; bh=gwRgVbP/BnI5fmhvhXKdFZ1JOUTXhe80a6s2mXNx25s=; b=nqyytm1srfztn9vqCTNdDcJv/DaiNYocQZxhsnw39JV2odWJoEmV7frXgXKmjUW9ta ILLeNM7LCYS/jmxoKDEsoNHVAZJX7qjfjNJcJI71fHkO49dL8SDJ3A1l6QfIFPVYAjbd FmiGorEpc+t/JsDtlwFQGJXqWAeDGSAfFu0xvAv2tVowQyf1TfX412hs58ZZoU+IebAY MccDmmMhM0WrM6nCCP4WokBPZ4fwtXzQIt4ccISzrE3512Smb6s3cWepF8NddLf5yiKy EJL7ZcMsD9YPHbdfF83snOO83/iStWnNfeiH89gZalwDf26lSOjxuA0q3CzIFo/BU+BV S+VA== X-Gm-Message-State: AHPjjUgOCneJq6bFDx2ySjC/S7llJ3nJlldRiW21/vKdYTkDhczGLFPU V4IU2X28Zmvc5EbjR5Ns/Bc= X-Google-Smtp-Source: AOwi7QDmwcw7yx9J5lt9DwHt6VX3t82I+4v0NMsiUGbMi7JCl/DDlVljknvYrlvIWsIW01w2iMurpQ== X-Received: by 10.99.43.4 with SMTP id r4mr1091267pgr.380.1506512827299; Wed, 27 Sep 2017 04:47:07 -0700 (PDT) Received: from localhost.localdomain ([103.37.201.27]) by smtp.gmail.com with ESMTPSA id m24sm21038048pfj.28.2017.09.27.04.47.04 (version=TLS1_2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Wed, 27 Sep 2017 04:47:06 -0700 (PDT) From: Harsha Sharma To: pablo@netfilter.org Cc: netfilter-devel@vger.kernel.org, linux-kernel@vger.kernel.org, outreachy-kernel@googlegroups.com, Harsha Sharma Subject: [PATCH] iptables: Constify option struct Date: Wed, 27 Sep 2017 17:14:52 +0530 Message-Id: <1506512692-7872-1-git-send-email-harshasharmaiitr@gmail.com> X-Mailer: git-send-email 1.9.1 Sender: netfilter-devel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: netfilter-devel@vger.kernel.org The struct of type option is only used to initialise a field inside the xtables_globals struct and is not modified anywhere. Done using following coccinelle semantic patch @r1 disable optional_qualifier@ identifier s,i; position p; @@ static struct option i@p[] ={...}; @ok1@ identifier r1.i; expression e; position p; @@ e = i@p @bad@ position p != {r1.p,ok1.p}; identifier r1.i; @@ e@i@p @depends on !bad disable optional_qualifier@ identifier r1.i; @@ static +const struct option i[] = { ... }; Signed-off-by: Harsha Sharma --- iptables/ip6tables.c | 2 +- iptables/iptables.c | 2 +- iptables/xtables-eb.c | 2 +- iptables/xtables.c | 2 +- 4 files changed, 4 insertions(+), 4 deletions(-) diff --git a/iptables/ip6tables.c b/iptables/ip6tables.c index 49bd006..0f6fa31 100644 --- a/iptables/ip6tables.c +++ b/iptables/ip6tables.c @@ -78,7 +78,7 @@ static const char optflags[] static const char unsupported_rev[] = " [unsupported revision]"; -static struct option original_opts[] = { +static const struct option original_opts[] = { {.name = "append", .has_arg = 1, .val = 'A'}, {.name = "delete", .has_arg = 1, .val = 'D'}, {.name = "check" , .has_arg = 1, .val = 'C'}, diff --git a/iptables/iptables.c b/iptables/iptables.c index 69d19fe..e930fe2 100644 --- a/iptables/iptables.c +++ b/iptables/iptables.c @@ -75,7 +75,7 @@ static const char optflags[] static const char unsupported_rev[] = " [unsupported revision]"; -static struct option original_opts[] = { +static const struct option original_opts[] = { {.name = "append", .has_arg = 1, .val = 'A'}, {.name = "delete", .has_arg = 1, .val = 'D'}, {.name = "check", .has_arg = 1, .val = 'C'}, diff --git a/iptables/xtables-eb.c b/iptables/xtables-eb.c index c8b5d4f..60ec935 100644 --- a/iptables/xtables-eb.c +++ b/iptables/xtables-eb.c @@ -247,7 +247,7 @@ static int get_current_chain(const char *chain) /* Default command line options. Do not mess around with the already * assigned numbers unless you know what you are doing */ -static struct option ebt_original_options[] = +static const struct option ebt_original_options[] = { { "append" , required_argument, 0, 'A' }, { "insert" , required_argument, 0, 'I' }, diff --git a/iptables/xtables.c b/iptables/xtables.c index ac11325..aebe7d7 100644 --- a/iptables/xtables.c +++ b/iptables/xtables.c @@ -59,7 +59,7 @@ static const char cmdflags[] = { 'I', 'D', 'D', 'R', 'A', 'L', 'F', 'Z', static const char optflags[] = { 'n', 's', 'd', 'p', 'j', 'v', 'x', 'i', 'o', '0', 'c', 'f'}; -static struct option original_opts[] = { +static const struct option original_opts[] = { {.name = "append", .has_arg = 1, .val = 'A'}, {.name = "delete", .has_arg = 1, .val = 'D'}, {.name = "check", .has_arg = 1, .val = 'C'},