Skip to contentSkip to conversation

mm/swap_state: Constify static struct attribute_group

PATCH Applied Rikard Falkeborn 4 participants 4 messages Feb 1, 2021 – Feb 2, 2021

Subsystems (2)
lore
Share & tools
lore
#0 lore raw

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
index d0d417efeecc..3cdee7b11da9 100644
@@ -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
Reviewed-by on v1 1/1
#1 lore raw
Quoted 24 lines · Rikard Falkeborn

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 -2
index d0d417efeecc..3cdee7b11da9 100644
@@ -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.

Acked-by on v1 1/1
#2 lore raw
In reply to Rikard Falkeborn
Quoted 5 lines · Rikard Falkeborn

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.

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
index d0d417efeecc..3cdee7b11da9 100644
@@ -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,
 };
Reviewed-by on v1 1/1
#3 lore raw
In reply to Rikard Falkeborn

Hi:

Quoted 5 lines · Rikard Falkeborn

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.

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
index d0d417efeecc..3cdee7b11da9 100644
@@ -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,
 };