Skip to contentSkip to conversation

samples/kobject: make attribute_group const

PATCH In review Meng-Shao.Liu 2 participants 2 messages Jul 15, 2025

lore
Share & tools
lore
#0 lore raw

PATCH 2/2 samples/kobject: make attribute_group const

The attr_group structures are allocated once and never modified at runtime. Also to match the const‑qualified parameter of sysfs_create_group().

No functional change.

---
 samples/kobject/kobject-example.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
samples/kobject/kobject-example.c +1 -1
index e6d7fc18e..36d87ca0b 100644
@@ -102,7 +102,7 @@ static struct attribute *attrs[] = {
  * created for the attributes with the directory being the name of the
  * attribute group.
  */
-static struct attribute_group attr_group = {
+static const struct attribute_group attr_group = {
 	.attrs = attrs,
 };
 
Signature · 1 line
2.43.0
#1 lore raw
Quoted 5 lines · Meng-Shao.Liu

The attr_group structures are allocated once and never modified at runtime. Also to match the const‑qualified parameter of sysfs_create_group().

No functional change.

This line isn't needed, as there is a functional change, it moves it into read-only memory, right?

thanks,

greg k-h