All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH] kernel: ksysfs: constify attribute_group structures.
@ 2017-06-29 12:01 Arvind Yadav
  2017-06-29 16:14 ` Kees Cook
  0 siblings, 1 reply; 2+ messages in thread
From: Arvind Yadav @ 2017-06-29 12:01 UTC (permalink / raw)
  To: rmk+kernel, keescook, akpm, dyoung, hbathini; +Cc: ptesarik, linux-kernel

attribute_groups are not supposed to change at runtime. All functions
working with attribute_groups provided by <linux/sysfs.h> work with const
attribute_group. So mark the non-const structs as const.

File size before:
   text	   data	    bss	    dec	    hex	filename
   1120	    544	     16	   1680	    690	kernel/ksysfs.o

File size After adding 'const':
   text	   data	    bss	    dec	    hex	filename
   1160	    480	     16	   1656	    678	kernel/ksysfs.o

Signed-off-by: Arvind Yadav <arvind.yadav.cs@gmail.com>
---
 kernel/ksysfs.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/kernel/ksysfs.c b/kernel/ksysfs.c
index 23cd706..df1a9aa 100644
--- a/kernel/ksysfs.c
+++ b/kernel/ksysfs.c
@@ -234,7 +234,7 @@ static ssize_t notes_read(struct file *filp, struct kobject *kobj,
 	NULL
 };
 
-static struct attribute_group kernel_attr_group = {
+static const struct attribute_group kernel_attr_group = {
 	.attrs = kernel_attrs,
 };
 
-- 
1.9.1

^ permalink raw reply related	[flat|nested] 2+ messages in thread

* Re: [PATCH] kernel: ksysfs: constify attribute_group structures.
  2017-06-29 12:01 [PATCH] kernel: ksysfs: constify attribute_group structures Arvind Yadav
@ 2017-06-29 16:14 ` Kees Cook
  0 siblings, 0 replies; 2+ messages in thread
From: Kees Cook @ 2017-06-29 16:14 UTC (permalink / raw)
  To: Arvind Yadav, Andrew Morton
  Cc: Russell King, Dave Young, Hari Bathini, Petr Tesarik, LKML

On Thu, Jun 29, 2017 at 5:01 AM, Arvind Yadav <arvind.yadav.cs@gmail.com> wrote:
> attribute_groups are not supposed to change at runtime. All functions
> working with attribute_groups provided by <linux/sysfs.h> work with const
> attribute_group. So mark the non-const structs as const.
>
> File size before:
>    text    data     bss     dec     hex filename
>    1120     544      16    1680     690 kernel/ksysfs.o
>
> File size After adding 'const':
>    text    data     bss     dec     hex filename
>    1160     480      16    1656     678 kernel/ksysfs.o
>
> Signed-off-by: Arvind Yadav <arvind.yadav.cs@gmail.com>

Thanks! Always nice to get more const structures. :)

Andrew, can you pick this up?

Acked-by: Kees Cook <keescook@chromium.org>

-Kees

> ---
>  kernel/ksysfs.c | 2 +-
>  1 file changed, 1 insertion(+), 1 deletion(-)
>
> diff --git a/kernel/ksysfs.c b/kernel/ksysfs.c
> index 23cd706..df1a9aa 100644
> --- a/kernel/ksysfs.c
> +++ b/kernel/ksysfs.c
> @@ -234,7 +234,7 @@ static ssize_t notes_read(struct file *filp, struct kobject *kobj,
>         NULL
>  };
>
> -static struct attribute_group kernel_attr_group = {
> +static const struct attribute_group kernel_attr_group = {
>         .attrs = kernel_attrs,
>  };
>
> --
> 1.9.1
>



-- 
Kees Cook
Pixel Security

^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2017-06-29 16:14 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2017-06-29 12:01 [PATCH] kernel: ksysfs: constify attribute_group structures Arvind Yadav
2017-06-29 16:14 ` Kees Cook

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.