Skip to contentSkip to conversation

kernel/ksysfs.c: constify attribute_group structures.

PATCH New [email protected] 1 participant 1 message Jul 10, 2017 Driver core

lore
Share & tools
lore
#0 lore raw

PATCH 80/115 kernel/ksysfs.c: constify attribute_group structures.

From: Arvind Yadav <[email protected]>
Subject: kernel/ksysfs.c: constify attribute_group structures.

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

File size before:
text data bss dec hex filename
1120 544 16 1680 690 kernel/ksysfs.o

File size After adding 'const':
text data bss dec hex filename
1160 480 16 1656 678 kernel/ksysfs.o

---

 kernel/ksysfs.c |    2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
kernel/ksysfs.c renamed from kernel/ksysfs.c~kernel-ksysfs-constify-attribute_group-structures +1 -1
diff -puN kernel/ksysfs.c~kernel-ksysfs-constify-attribute_group-structures kernel/ksysfs.c
@@ -234,7 +234,7 @@ static struct attribute * kernel_attrs[]
 	NULL
 };
 
-static struct attribute_group kernel_attr_group = {
+static const struct attribute_group kernel_attr_group = {
 	.attrs = kernel_attrs,
 };
 

_