Staging: most: hdm-dim2: constify attribute_group structures
Subsystems (2)
PATCH 1/1 Staging: most: hdm-dim2: constify attribute_group structures
Check for attribute_group structures that are only passed as a second argument to the functions sysfs_remove_group and sysfs_create_group. As these arguments are constant so, attribute_group structures having this property can also be made constant.
Done using coccinelle:
@r1 disable optional_qualifier @
identifier i;
position p;
@@
static struct attribute_group i@p = {...};
@ok1@
identifier r1.i;
position p;
expression e1,e2;
@@
(sysfs_remove_group(e1,&i@p)
|sysfs_create_group(e1,&i@p)
)
@bad@
position p!={r1.p,ok1.p};
identifier r1.i;
@@
i@p
@depends on !bad disable optional_qualifier@
identifier r1.i;
@@
static
+const
struct attribute_group i={...};
@depends on !bad disable optional_qualifier@
identifier r1.i;
@@
+const
struct attribute_group i;
File size before:
text data bss dec hex filename
509 160 0 669 29ddrivers/staging/most/hdm-dim2/dim2_sysfs.o
File size after:
text data bss dec hex filename
565 96 0 661 295drivers/staging/most/hdm-dim2/dim2_sysfs.o
--- drivers/staging/most/hdm-dim2/dim2_sysfs.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/staging/most/hdm-dim2/dim2_sysfs.c +1 -1
@@ -39,7 +39,7 @@ static struct attribute *bus_default_attrs[] = { NULL, }; -static struct attribute_group bus_attr_group = { +static const struct attribute_group bus_attr_group = { .attrs = bus_default_attrs, };
Signature · 1 line
1.9.1
Quoted 45 lines · Bhumika Goyal
Check for
attribute_groupstructures that are only passed as a second argument to the functionssysfs_remove_groupandsysfs_create_group. As these arguments are constant so,attribute_groupstructures having this property can also be made constant.
Done using coccinelle:@r1 disable
optional_qualifier@
identifier i;
position p;
@@
static structattribute_groupi@p = {...};@ok1@
identifier r1.i;
position p;
expression e1,e2;
@@
(sysfs_remove_group(e1,&i@p)
|sysfs_create_group(e1,&i@p)
)@bad@
position p!={r1.p,ok1.p};
identifier r1.i;
@@
i@p@depends on !bad disable optional_qualifier@
identifier r1.i;
@@
static
+const
structattribute_groupi={...};@depends on !bad disable optional_qualifier@
identifier r1.i;
@@
+const
structattribute_groupi;File size before:
text data bss dec hex filename 509 160 0 669 29d
Quoted 8 lines
drivers/staging/most/hdm-dim2/dim2_sysfs.oFile size after:
text data bss dec hex filename 565 96 0 661 295
drivers/staging/most/hdm-dim2/dim2_sysfs.oSigned-off-by Bhumika Goyal <[email protected]>
Quoted 27 lines
--- drivers/staging/most/hdm-dim2/dim2_sysfs.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)drivers/staging/most/hdm-dim2/dim2_sysfs.c +1
-2@@ -39,7 +39,7 @@ static struct attribute *bus_default_attrs[] = { NULL, }; -static struct attribute_group bus_attr_group = { +static const struct attribute_group bus_attr_group = { .attrs = bus_default_attrs, }; --1.9.1
--
You received this message because you are subscribed to the Google Groups "outreachy-kernel" group.
To unsubscribe from this group and stop receiving emails from it, send an email to [email protected]. To post to this group, send email to [email protected].
To view this discussion on the web visit https://groups.google.com/d/msgid/outreachy-kernel/1475161111-24767-1-git-send-email-bhumirks%40gmail.com.
For more options, visit https://groups.google.com/d/optout.