Skip to content

Commit 9042e77

Browse files
t-8chVlastimil Babka (SUSE)
authored andcommitted
mm/slab: constify sysfs attributes
These attributes are never modified, make them read-only. Signed-off-by: Thomas Weißschuh <[email protected]> Reviewed-by: Harry Yoo <[email protected]> Link: https://patch.msgid.link/[email protected] Signed-off-by: Vlastimil Babka (SUSE) <[email protected]>
1 parent 5aa2a02 commit 9042e77

1 file changed

Lines changed: 6 additions & 6 deletions

File tree

mm/slub.c

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -8833,7 +8833,7 @@ static ssize_t show_slab_objects(struct kmem_cache *s,
88338833
return len;
88348834
}
88358835

8836-
#define to_slab_attr(n) container_of(n, struct slab_attribute, attr)
8836+
#define to_slab_attr(n) container_of_const(n, struct slab_attribute, attr)
88378837
#define to_slab(n) container_of(n, struct kmem_cache, kobj)
88388838

88398839
struct slab_attribute {
@@ -8843,10 +8843,10 @@ struct slab_attribute {
88438843
};
88448844

88458845
#define SLAB_ATTR_RO(_name) \
8846-
static struct slab_attribute _name##_attr = __ATTR_RO_MODE(_name, 0400)
8846+
static const struct slab_attribute _name##_attr = __ATTR_RO_MODE(_name, 0400)
88478847

88488848
#define SLAB_ATTR(_name) \
8849-
static struct slab_attribute _name##_attr = __ATTR_RW_MODE(_name, 0600)
8849+
static const struct slab_attribute _name##_attr = __ATTR_RW_MODE(_name, 0600)
88508850

88518851
static ssize_t slab_size_show(struct kmem_cache *s, char *buf)
88528852
{
@@ -9240,7 +9240,7 @@ static ssize_t skip_kfence_store(struct kmem_cache *s,
92409240
SLAB_ATTR(skip_kfence);
92419241
#endif
92429242

9243-
static struct attribute *slab_attrs[] = {
9243+
static const struct attribute *const slab_attrs[] = {
92449244
&slab_size_attr.attr,
92459245
&object_size_attr.attr,
92469246
&objs_per_slab_attr.attr,
@@ -9323,7 +9323,7 @@ static ssize_t slab_attr_show(struct kobject *kobj,
93239323
struct attribute *attr,
93249324
char *buf)
93259325
{
9326-
struct slab_attribute *attribute;
9326+
const struct slab_attribute *attribute;
93279327
struct kmem_cache *s;
93289328

93299329
attribute = to_slab_attr(attr);
@@ -9339,7 +9339,7 @@ static ssize_t slab_attr_store(struct kobject *kobj,
93399339
struct attribute *attr,
93409340
const char *buf, size_t len)
93419341
{
9342-
struct slab_attribute *attribute;
9342+
const struct slab_attribute *attribute;
93439343
struct kmem_cache *s;
93449344

93459345
attribute = to_slab_attr(attr);

0 commit comments

Comments
 (0)