From patchwork Sat Jul 29 06:16:55 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Julia Lawall X-Patchwork-Id: 795169 X-Patchwork-Delegate: davem@davemloft.net Return-Path: X-Original-To: patchwork-incoming@ozlabs.org Delivered-To: patchwork-incoming@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=netdev-owner@vger.kernel.org; receiver=) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by ozlabs.org (Postfix) with ESMTP id 3xKGPF090gz9tW8 for ; Sat, 29 Jul 2017 16:42:57 +1000 (AEST) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1753483AbdG2Gmm (ORCPT ); Sat, 29 Jul 2017 02:42:42 -0400 Received: from mail2-relais-roc.national.inria.fr ([192.134.164.83]:45106 "EHLO mail2-relais-roc.national.inria.fr" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1753178AbdG2GmP (ORCPT ); Sat, 29 Jul 2017 02:42:15 -0400 X-IronPort-AV: E=Sophos;i="5.40,429,1496095200"; d="scan'208";a="285335572" Received: from palace.lip6.fr (HELO localhost.localdomain) ([132.227.105.202]) by mail2-relais-roc.national.inria.fr with ESMTP/TLS/AES128-SHA256; 29 Jul 2017 08:42:12 +0200 From: Julia Lawall To: "David S. Miller" Cc: bhumirks@gmail.com, kernel-janitors@vger.kernel.org, Alexey Kuznetsov , Hideaki YOSHIFUJI , netdev@vger.kernel.org, linux-kernel@vger.kernel.org Subject: [PATCH 1/2] ipv4: constify net_protocol structures Date: Sat, 29 Jul 2017 08:16:55 +0200 Message-Id: <1501309016-16059-2-git-send-email-Julia.Lawall@lip6.fr> X-Mailer: git-send-email 1.9.1 In-Reply-To: <1501309016-16059-1-git-send-email-Julia.Lawall@lip6.fr> References: <1501309016-16059-1-git-send-email-Julia.Lawall@lip6.fr> Sender: netdev-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: netdev@vger.kernel.org The net_protocol structures are only passed as the first argument to inet_add_protocol, which is declared as const. Thus the net_protocol structures themselves can be const. Done with the help of Coccinelle. // @r disable optional_qualifier@ identifier i; position p; @@ static struct net_protocol i@p = { ... }; @ok1@ identifier r.i; expression e1; position p; @@ inet_add_protocol(&i@p,...) @bad@ position p != {r.p,ok1.p}; identifier r.i; struct net_protocol e; @@ e@i@p @depends on !bad disable optional_qualifier@ identifier r.i; @@ static +const struct net_protocol i = { ... }; // Signed-off-by: Julia Lawall --- net/ipv4/af_inet.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/net/ipv4/af_inet.c b/net/ipv4/af_inet.c index 5ce44fb..2e38624 100644 --- a/net/ipv4/af_inet.c +++ b/net/ipv4/af_inet.c @@ -1594,7 +1594,7 @@ u64 snmp_fold_field64(void __percpu *mib, int offt, size_t syncp_offset) }; #endif -static struct net_protocol tcp_protocol = { +static const struct net_protocol tcp_protocol = { .early_demux = tcp_v4_early_demux, .early_demux_handler = tcp_v4_early_demux, .handler = tcp_v4_rcv, @@ -1604,7 +1604,7 @@ u64 snmp_fold_field64(void __percpu *mib, int offt, size_t syncp_offset) .icmp_strict_tag_validation = 1, }; -static struct net_protocol udp_protocol = { +static const struct net_protocol udp_protocol = { .early_demux = udp_v4_early_demux, .early_demux_handler = udp_v4_early_demux, .handler = udp_rcv,