linux-mm.kvack.org archive mirror
 help / color / mirror / Atom feed
From: SeongJae Park <sj@kernel.org>
To: Kees Cook <keescook@chromium.org>,
	Andrew Morton <akpm@linux-foundation.org>
Cc: SeongJae Park <sj@kernel.org>,
	damon@lists.linux.dev, linux-mm@kvack.org,
	linux-kernel@vger.kernel.org
Subject: [RFC PATCH] mm/damon/sysfs: add __counted_by() annotation
Date: Fri, 25 Aug 2023 02:04:41 +0000	[thread overview]
Message-ID: <20230825020441.65431-1-sj@kernel.org> (raw)

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



             reply	other threads:[~2023-08-25  2:04 UTC|newest]

Thread overview: 3+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2023-08-25  2:04 SeongJae Park [this message]
2023-08-25 21:32 ` Kees Cook
2023-08-26  0:54   ` SeongJae Park

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20230825020441.65431-1-sj@kernel.org \
    --to=sj@kernel.org \
    --cc=akpm@linux-foundation.org \
    --cc=damon@lists.linux.dev \
    --cc=keescook@chromium.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-mm@kvack.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox