Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux
1
fork

Configure Feed

Select the types of activity you want to include in your feed.

nilfs2: Constify struct kobj_type

'struct kobj_type' is not modified in this driver. It is only used with
kobject_init_and_add() which takes a "const struct kobj_type *" parameter.

Constifying this structure moves some data to a read-only section, so
increase overall security.

On a x86_64, with allmodconfig:
Before:
======
text data bss dec hex filename
22403 4184 24 26611 67f3 fs/nilfs2/sysfs.o

After:
=====
text data bss dec hex filename
22723 3928 24 26675 6833 fs/nilfs2/sysfs.o

Link: https://lkml.kernel.org/r/20240708143242.3296-1-konishi.ryusuke@gmail.com
Signed-off-by: Christophe JAILLET <christophe.jaillet@wanadoo.fr>
Signed-off-by: Ryusuke Konishi <konishi.ryusuke@gmail.com>
Signed-off-by: Andrew Morton <akpm@linux-foundation.org>

authored by

Christophe JAILLET and committed by
Andrew Morton
fbc8846c 0f3819e8

+3 -3
+3 -3
fs/nilfs2/sysfs.c
··· 56 56 sg_##name##_kobj); \ 57 57 complete(&subgroups->sg_##name##_kobj_unregister); \ 58 58 } \ 59 - static struct kobj_type nilfs_##name##_ktype = { \ 59 + static const struct kobj_type nilfs_##name##_ktype = { \ 60 60 .default_groups = nilfs_##name##_groups, \ 61 61 .sysfs_ops = &nilfs_##name##_attr_ops, \ 62 62 .release = nilfs_##name##_attr_release, \ ··· 166 166 .store = nilfs_snapshot_attr_store, 167 167 }; 168 168 169 - static struct kobj_type nilfs_snapshot_ktype = { 169 + static const struct kobj_type nilfs_snapshot_ktype = { 170 170 .default_groups = nilfs_snapshot_groups, 171 171 .sysfs_ops = &nilfs_snapshot_attr_ops, 172 172 .release = nilfs_snapshot_attr_release, ··· 967 967 .store = nilfs_dev_attr_store, 968 968 }; 969 969 970 - static struct kobj_type nilfs_dev_ktype = { 970 + static const struct kobj_type nilfs_dev_ktype = { 971 971 .default_groups = nilfs_dev_groups, 972 972 .sysfs_ops = &nilfs_dev_attr_ops, 973 973 .release = nilfs_dev_attr_release,