Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
Groups > linux.kernel > #1677666 > unrolled thread
| Started by | Arvind Yadav <arvind.yadav.cs@gmail.com> |
|---|---|
| First post | 2017-06-29 14:10 +0200 |
| Last post | 2017-06-29 18:20 +0200 |
| Articles | 2 — 2 participants |
Back to article view | Back to linux.kernel
[PATCH] kernel: ksysfs: constify attribute_group structures. Arvind Yadav <arvind.yadav.cs@gmail.com> - 2017-06-29 14:10 +0200
Re: [PATCH] kernel: ksysfs: constify attribute_group structures. Kees Cook <keescook@chromium.org> - 2017-06-29 18:20 +0200
| From | Arvind Yadav <arvind.yadav.cs@gmail.com> |
|---|---|
| Date | 2017-06-29 14:10 +0200 |
| Subject | [PATCH] kernel: ksysfs: constify attribute_group structures. |
| Message-ID | <tXGqL-7pH-49@gated-at.bofh.it> |
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
[toc] | [next] | [standalone]
| From | Kees Cook <keescook@chromium.org> |
|---|---|
| Date | 2017-06-29 18:20 +0200 |
| Message-ID | <tXKkF-1nd-21@gated-at.bofh.it> |
| In reply to | #1677666 |
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
[toc] | [prev] | [standalone]
Back to top | Article view | linux.kernel
csiph-web