mm/swap_state: Constify static struct attribute_group
Subsystems (2)
PATCH 1/1 mm/swap_state: Constify static struct attribute_group
The only usage of swap_attr_group is to pass its address to sysfs_create_group() which takes a pointer to const attribute_group. Make it const to allow the compiler to put it in read-only memory.
--- mm/swap_state.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
mm/swap_state.c +1 -1
@@ -901,7 +901,7 @@ static struct attribute *swap_attrs[] = { NULL, }; -static struct attribute_group swap_attr_group = { +static const struct attribute_group swap_attr_group = { .attrs = swap_attrs, };
Signature · 1 line
2.30.0
Quoted 24 lines · Rikard Falkeborn
The only usage of
swap_attr_groupis to pass its address tosysfs_create_group()which takes a pointer to constattribute_group. Make it const to allow the compiler to put it in read-only memory.Signed-off-by Rikard Falkeborn <[email protected]>--- mm/swap_state.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)mm/swap_state.c +1
-2@@ -901,7 +901,7 @@ static struct attribute *swap_attrs[] = { NULL, }; -static struct attribute_group swap_attr_group = { +static const struct attribute_group swap_attr_group = { .attrs = swap_attrs, }; --
Quoted 2 lines
2.30.0
Looks all good to me - there aren't any dependencies on it anywhere else.
Quoted 5 lines · Rikard Falkeborn
The only usage of
swap_attr_groupis to pass its address tosysfs_create_group()which takes a pointer to constattribute_group. Make it const to allow the compiler to put it in read-only memory.Signed-off-by Rikard Falkeborn <[email protected]>
Looks good to me.
Quoted 16 lines
--- mm/swap_state.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)mm/swap_state.c +1
-1@@ -901,7 +901,7 @@ static struct attribute *swap_attrs[] = { NULL, }; -static struct attribute_group swap_attr_group = { +static const struct attribute_group swap_attr_group = { .attrs = swap_attrs, };
Hi:
Quoted 5 lines · Rikard Falkeborn
The only usage of
swap_attr_groupis to pass its address tosysfs_create_group()which takes a pointer to constattribute_group. Make it const to allow the compiler to put it in read-only memory.Signed-off-by Rikard Falkeborn <[email protected]>
Looks good to me. Thanks.
Quoted 18 lines
--- mm/swap_state.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)mm/swap_state.c +1
-1@@ -901,7 +901,7 @@ static struct attribute *swap_attrs[] = { NULL, }; -static struct attribute_group swap_attr_group = { +static const struct attribute_group swap_attr_group = { .attrs = swap_attrs, };