[RFC PATCH] mm/damon/sysfs: add __counted_by() annotation

SeongJae Park
2023-08-25T02:05:20Z

Commit dd06e72e68bc ("Compiler Attributes: Add __counted_by macro")
added __counted_by() annotation. The underlying attribute for the
feature is still under development, but adopting it can improve the
readability of the code. Apply it to four dynamic arrays in DAMON sysfs
code.

Signed-off-by: SeongJae Park <sj@kernel.org>
---
mm/damon/sysfs.c | 8 ++++----
1 file changed, 4 insertions(+), 4 deletions(-)

diff --git a/mm/damon/sysfs.c b/mm/damon/sysfs.c
index 808a8efe0523..36a176f38726 100644
--- a/mm/damon/sysfs.c
+++ b/mm/damon/sysfs.c
@@ -93,7 +93,7 @@ static const struct kobj_type damon_sysfs_region_ktype = {

struct damon_sysfs_regions {
struct kobject kobj;
- struct damon_sysfs_region **regions_arr;
+ struct damon_sysfs_region **regions_arr __counted_by(nr);
int nr;
};

@@ -289,7 +289,7 @@ static const struct kobj_type damon_sysfs_target_ktype = {

struct damon_sysfs_targets {
struct kobject kobj;
- struct damon_sysfs_target **targets_arr;
+ struct damon_sysfs_target **targets_arr __counted_by(nr);
int nr;
};

@@ -812,7 +812,7 @@ static const struct kobj_type damon_sysfs_context_ktype = {

struct damon_sysfs_contexts {
struct kobject kobj;
- struct damon_sysfs_context **contexts_arr;
+ struct damon_sysfs_context **contexts_arr __counted_by(nr);
int nr;
};

@@ -1590,7 +1590,7 @@ static const struct kobj_type damon_sysfs_kdamond_ktype = {

struct damon_sysfs_kdamonds {
struct kobject kobj;
- struct damon_sysfs_kdamond **kdamonds_arr;
+ struct damon_sysfs_kdamond **kdamonds_arr __counted_by(nr);
int nr;
};

--
2.25.1