From: Peng Zhang <zhangpeng.00@bytedance.com>
To: David Binderman <dcb314@hotmail.com>
Cc: "Liam.Howlett@oracle.com" <Liam.Howlett@oracle.com>,
"linux-mm@kvack.org" <linux-mm@kvack.org>,
Linux Kernel Mailing List <linux-kernel@vger.kernel.org>,
maple-tree@lists.infradead.org
Subject: Re: linux-6.3-rc6/lib/maple_tree.c: Two style issues
Date: Mon, 10 Apr 2023 16:23:42 +0800 [thread overview]
Message-ID: <cd5b6ce1-3c2f-97f5-64c5-4c4c90c40627@bytedance.com> (raw)
In-Reply-To: <DB6P189MB0568CB290411B23A176511239C959@DB6P189MB0568.EURP189.PROD.OUTLOOK.COM>
在 2023/4/10 15:05, David Binderman 写道:
> Hello there,
>
> Static analyser cppcheck says:
>
> 1.
>
> linux-6.3-rc6/lib/maple_tree.c:1951:21: style: Array index 'split' is used before limits check. [arrayIndexThenCheck]
>
> Source code is
>
> while (((bn->pivot[split] - min) < slot_count - 1) &&
> (split < slot_count - 1) && (b_end - split > slot_min))
>
> Suggest move limits check to before use.
Hi,
It should be fine here. The upper bound of split is b_end.
The initial state (split = b_end / 2) must not cross the boundary,
and (b_end - split > slot_min) ensures that it will not cross the
boundary in the future.
>
> 2.
>
> linux-6.3-rc6/lib/maple_tree.c:3289:11: warning: Size of pointer 'pivs' used instead of size of its data. [pointerSize]
>
> Source code is
>
> memset(pivs + tmp, 0,
> sizeof(unsigned long *) * (max_p - tmp));
It's not good here, I can fix it.
Thanks.
>
> but
>
> unsigned long *l_pivs, *pivs, gap;
>
> Pointers and long don't have to be the same size. Suggest code rework.
>
> Regards
>
> David Binderman
>
next prev parent reply other threads:[~2023-04-10 8:23 UTC|newest]
Thread overview: 4+ messages / expand[flat|nested] mbox.gz Atom feed top
2023-04-10 7:05 David Binderman
2023-04-10 8:23 ` Peng Zhang [this message]
2023-04-17 14:22 ` David Binderman
2023-04-17 14:58 ` 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=cd5b6ce1-3c2f-97f5-64c5-4c4c90c40627@bytedance.com \
--to=zhangpeng.00@bytedance.com \
--cc=Liam.Howlett@oracle.com \
--cc=dcb314@hotmail.com \
--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