linux-mm.kvack.org archive mirror
 help / color / mirror / Atom feed
From: Peng Zhang <zhangpeng.00@bytedance.com>
To: Liam.Howlett@oracle.com, dan.carpenter@linaro.org,
	akpm@linux-foundation.org
Cc: linux-kernel@vger.kernel.org, linux-mm@kvack.org,
	maple-tree@lists.infradead.org,
	Peng Zhang <zhangpeng.00@bytedance.com>
Subject: [PATCH v2 1/5] maple_tree: Move the check forward to avoid static check warning
Date: Mon, 20 Nov 2023 15:09:33 +0800	[thread overview]
Message-ID: <20231120070937.35481-2-zhangpeng.00@bytedance.com> (raw)
In-Reply-To: <20231120070937.35481-1-zhangpeng.00@bytedance.com>

Put the check for gap before its reference to avoid Smatch static check
warnings. This is not a bug, it's just a validation program. Even with this
change, Smatch may still generate warnings because MT_BUG_ON() doesn't
necessarily stop the program. It may require fixing Smatch itself to avoid
these warnings.

Reported-by: Dan Carpenter <dan.carpenter@linaro.org>
Closes: http://lists.infradead.org/pipermail/maple-tree/2023-November/003046.html
Signed-off-by: Peng Zhang <zhangpeng.00@bytedance.com>
---
 lib/maple_tree.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/lib/maple_tree.c b/lib/maple_tree.c
index aaba453b0d30..067b186202d7 100644
--- a/lib/maple_tree.c
+++ b/lib/maple_tree.c
@@ -7249,6 +7249,7 @@ static void mas_validate_gaps(struct ma_state *mas)
 
 counted:
 	if (mt == maple_arange_64) {
+		MT_BUG_ON(mas->tree, !gaps);
 		offset = ma_meta_gap(node, mt);
 		if (offset > i) {
 			pr_err("gap offset %p[%u] is invalid\n", node, offset);
@@ -7261,7 +7262,6 @@ static void mas_validate_gaps(struct ma_state *mas)
 			MT_BUG_ON(mas->tree, 1);
 		}
 
-		MT_BUG_ON(mas->tree, !gaps);
 		for (i++ ; i < mt_slot_count(mte); i++) {
 			if (gaps[i] != 0) {
 				pr_err("gap %p[%u] beyond node limit != 0\n",
-- 
2.20.1



  reply	other threads:[~2023-11-20  7:09 UTC|newest]

Thread overview: 7+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2023-11-20  7:09 [PATCH v2 0/5] Some cleanups of maple tree Peng Zhang
2023-11-20  7:09 ` Peng Zhang [this message]
2023-11-20  7:09 ` [PATCH v2 2/5] maple_tree: Avoid ascending when mas->min is also the parent's minimum Peng Zhang
2023-11-20  7:09 ` [PATCH v2 3/5] maple_tree: Remove an unused parameter for ma_meta_end() Peng Zhang
2023-11-20  7:09 ` [PATCH v2 4/5] maple_tree: Delete one of the two identical checks Peng Zhang
2023-11-20  7:09 ` [PATCH v2 5/5] maple_tree: Simplify mas_leaf_set_meta() Peng Zhang
2023-11-20 15:43 ` [PATCH v2 0/5] Some cleanups of maple tree Liam R. Howlett

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=20231120070937.35481-2-zhangpeng.00@bytedance.com \
    --to=zhangpeng.00@bytedance.com \
    --cc=Liam.Howlett@oracle.com \
    --cc=akpm@linux-foundation.org \
    --cc=dan.carpenter@linaro.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-mm@kvack.org \
    --cc=maple-tree@lists.infradead.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