Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > linux.kernel > #1677609

[PATCH] net: constify attribute_group structures.

Path csiph.com!eternal-september.org!feeder.eternal-september.org!aioe.org!bofh.it!news.nic.it!robomod
From Arvind Yadav <arvind.yadav.cs@gmail.com>
Newsgroups linux.kernel
Subject [PATCH] net: constify attribute_group structures.
Date Thu, 29 Jun 2017 13:10:01 +0200
Message-ID <tXFuF-6OW-9@gated-at.bofh.it> (permalink)
Dkim-Signature v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:cc:subject:date:message-id; bh=9qoahZAPIyBU4Hg1OM12YLeJGgSyk+uDdrpeIgrc1Ak=; b=DMHwTOCkCHq9QGNlJvGLgTBCSU82WHMpGV129ENpe/TrxbAWmR7r0e8Wws1mIiGnlj 8j1oQ/TEzzjQodFrk9+S57cqgRQXSrZ2vyQpyXEXZU9/XeL3tzKF8pP6GYsX0tZAJ7Ll xRFBfN7iVVLXNh0558K5I3rEX3tJEtzbLOfBmjo2sdJVGRJ5obFOtz5MGv8vFs+5xUt1 1fmFJKuTRzG2KKagbi+k74NPEK0YjYMQqPf/nY+uKiU8vRv3A7NcgrLqEkihpMQpXvEs +NelAe7KwXjgwXCqstRjukvdoil4wNeBeYWhTPjKFHKkgnrybZx6FsYrz5LiTj5qb+W9 /vOw==
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=9qoahZAPIyBU4Hg1OM12YLeJGgSyk+uDdrpeIgrc1Ak=; b=to4WV6VJQwlD4npTx+UvB3W7IA/2q1Qd/3A417K+FMdXZxRbEVyMZTbXOb/rA1E0eY LhMG62EA1sbSi31IYBavOIJavnZ4QHK32BQkesmEouC0AlZKSzxxFajuAX5jJzkxAbba lRx6H2gPqKkgeAHGPm2xHsFir8rl/gmel/mQIzwjDS5NSgq/0jJ4ZCoN68dgb5E1iNgu D4G5YghpTMs4AfgH97v9ZxHyCuVzdCnzTdipjQ5oiKAkTEgRKMQ1wdBsXtfA3qdhbsI+ ddBRtpVLr9WFZb8XngsjtciXrYGWKBY+poJMZ30PTBKY0nsDzqEZhaHSkG2IrvmGt72q QsTw==
X-Gm-Message-State AKS2vOzqZy6LGejluB8NIN/DI2BfoGQ5xG38P/5SRh3NLDAH2x9TK6EI jlnAKRfgAt4odw==
X-Received by 10.84.198.36 with SMTP id o33mr14561471pld.79.1498734136958; Thu, 29 Jun 2017 04:02:16 -0700 (PDT)
X-Mailer git-send-email 1.9.1
Sender robomod@news.nic.it
List-ID <linux-kernel.vger.kernel.org>
X-Mailing-List linux-kernel@vger.kernel.org
Approved robomod@news.nic.it
Lines 50
Organization linux.* mail to news gateway
X-Original-Cc netdev@vger.kernel.org, linux-kernel@vger.kernel.org
X-Original-Date Thu, 29 Jun 2017 16:31:26 +0530
X-Original-Message-ID <7e920337fab72cc388b20ac95c2e198b84145483.1498733815.git.arvind.yadav.cs@gmail.com>
X-Original-Sender linux-kernel-owner@vger.kernel.org
Xref csiph.com linux.kernel:1677609

Show key headers only | View raw


attribute_groups are not supposed to change at runtime. All functions
working with attribute_groups provided by <linux/device.h> work with const
attribute_group. So mark the non-const structs as const.

File size before:
   text	   data	    bss	    dec	    hex	filename
   9968	   3168	     16	  13152	   3360	net/core/net-sysfs.o

File size After adding 'const':
   text	   data	    bss	    dec	    hex	filename
  10160	   2976	     16	  13152	   3360	net/core/net-sysfs.o

Signed-off-by: Arvind Yadav <arvind.yadav.cs@gmail.com>
---
 net/core/net-sysfs.c | 6 +++---
 1 file changed, 3 insertions(+), 3 deletions(-)

diff --git a/net/core/net-sysfs.c b/net/core/net-sysfs.c
index 65ea0ff..85daa29 100644
--- a/net/core/net-sysfs.c
+++ b/net/core/net-sysfs.c
@@ -622,7 +622,7 @@ static DEVICE_ATTR_RO(name)
 };
 
 
-static struct attribute_group netstat_group = {
+static const struct attribute_group netstat_group = {
 	.name  = "statistics",
 	.attrs  = netstat_attrs,
 };
@@ -632,7 +632,7 @@ static DEVICE_ATTR_RO(name)
 	NULL
 };
 
-static struct attribute_group wireless_group = {
+static const struct attribute_group wireless_group = {
 	.name = "wireless",
 	.attrs = wireless_attrs,
 };
@@ -1200,7 +1200,7 @@ static ssize_t bql_show_inflight(struct netdev_queue *queue,
 	NULL
 };
 
-static struct attribute_group dql_group = {
+static const struct attribute_group dql_group = {
 	.name  = "byte_queue_limits",
 	.attrs  = dql_attrs,
 };
-- 
1.9.1

Back to linux.kernel | Previous | NextNext in thread | Find similar | Unroll thread


Thread

[PATCH] net: constify attribute_group structures. Arvind Yadav <arvind.yadav.cs@gmail.com> - 2017-06-29 13:10 +0200
  Re: [PATCH] net: constify attribute_group structures. David Miller <davem@davemloft.net> - 2017-06-29 22:00 +0200

csiph-web