Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux
1
fork

Configure Feed

Select the types of activity you want to include in your feed.

sysfs: transparently handle const pointers in ATTRIBUTE_GROUPS()

To ease the constification process of 'struct attribute', transparently
handle the const pointers in ATTRIBUTE_GROUPS(). A cast is used instead
of assigning to .attrs_new as it keeps the macro smaller. As both
members are aliased to each other the result is identical.

Signed-off-by: Thomas Weißschuh <linux@weissschuh.net>
Link: https://patch.msgid.link/20251029-sysfs-const-attr-prep-v5-2-ea7d745acff4@weissschuh.net
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>

authored by

Thomas Weißschuh and committed by
Greg Kroah-Hartman
964c93b1 f85d90dd

+6 -1
+6 -1
include/linux/sysfs.h
··· 287 287 288 288 #define ATTRIBUTE_GROUPS(_name) \ 289 289 static const struct attribute_group _name##_group = { \ 290 - .attrs = _name##_attrs, \ 290 + .attrs = _Generic(_name##_attrs, \ 291 + struct attribute **: \ 292 + _name##_attrs, \ 293 + const struct attribute *const *: \ 294 + (void *)_name##_attrs \ 295 + ), \ 291 296 }; \ 292 297 __ATTRIBUTE_GROUPS(_name) 293 298