From: David Sterba <dsterba@suse.cz>
To: pengfuyuan <pengfuyuan@kylinos.cn>
Cc: dsterba@suse.cz, Qu Wenruo <quwenruo.btrfs@gmx.com>,
Chris Mason <clm@fb.com>, Josef Bacik <josef@toxicpanda.com>,
David Sterba <dsterba@suse.com>,
linux-btrfs@vger.kernel.org, linux-kernel@vger.kernel.org
Subject: Re: [PATCH] btrfs: Fix csum_tree_block to avoid tripping on -Werror=array-bounds
Date: Mon, 29 May 2023 15:44:23 +0200 [thread overview]
Message-ID: <20230529134423.GE575@twin.jikos.cz> (raw)
In-Reply-To: <871f146c-2fd8-4322-2288-4be90c0baf8a@kylinos.cn>
On Mon, May 29, 2023 at 11:28:59AM +0800, pengfuyuan wrote:
>
> On 2023/5/26 22:35, David Sterba wrote:
> > On Tue, May 23, 2023 at 09:32:12PM +0200, David Sterba wrote:
> >> On Tue, May 23, 2023 at 03:33:22PM +0800, Qu Wenruo wrote:
> >>> On 2023/5/23 15:09, pengfuyuan wrote:
> >>> Although even with such change, I'm still not sure if it's any better or
> >>> worse, as most of the calculation can still be bulky.
> > The final version is
> >
> > for (i = 1; i < num_pages && INLINE_EXTENT_BUFFER_PAGES > 1; i++)
> >
> > ie. 'INLINE_EXTENT_BUFFER_PAGES > 1' can be evaluated at compile time
> > and result in removing the for loop completely.
> >
> > Pengfuyuan, can you please do a build test that it does not report the
> > warning anymore? The diff is:
> >
> > --- a/fs/btrfs/disk-io.c
> > +++ b/fs/btrfs/disk-io.c
> > @@ -88,7 +88,6 @@ static void csum_tree_block(struct extent_buffer *buf, u8 *result)
> > const int first_page_part = min_t(u32, PAGE_SIZE, fs_info->nodesize);
> > SHASH_DESC_ON_STACK(shash, fs_info->csum_shash);
> > char *kaddr;
> > - int i;
> >
> > shash->tfm = fs_info->csum_shash;
> > crypto_shash_init(shash);
> > @@ -96,7 +95,7 @@ static void csum_tree_block(struct extent_buffer *buf, u8 *result)
> > crypto_shash_update(shash, kaddr + BTRFS_CSUM_SIZE,
> > first_page_part - BTRFS_CSUM_SIZE);
> >
> > - for (i = 1; i < num_pages; i++) {
> > + for (int i = 1; i < num_pages && INLINE_EXTENT_BUFFER_PAGES > 1; i++) {
> > kaddr = page_address(buf->pages[i]);
> > crypto_shash_update(shash, kaddr, PAGE_SIZE);
> > }
> > ---
>
> I did a build test on the mips64 architecture, the compilation passed,
> and it no longer reported warnings.
Thanks, patch added to misc-next.
prev parent reply other threads:[~2023-05-29 13:50 UTC|newest]
Thread overview: 8+ messages / expand[flat|nested] mbox.gz Atom feed top
2023-05-23 7:09 pengfuyuan
2023-05-23 7:33 ` Qu Wenruo
2023-05-23 19:32 ` David Sterba
2023-05-23 23:46 ` Qu Wenruo
2023-05-24 9:29 ` David Sterba
2023-05-26 14:35 ` David Sterba
2023-05-29 3:28 ` pengfuyuan
2023-05-29 13:44 ` David Sterba [this message]
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=20230529134423.GE575@twin.jikos.cz \
--to=dsterba@suse.cz \
--cc=clm@fb.com \
--cc=dsterba@suse.com \
--cc=josef@toxicpanda.com \
--cc=linux-btrfs@vger.kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=pengfuyuan@kylinos.cn \
--cc=quwenruo.btrfs@gmx.com \
/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
all inboxes | Powered by JetHome®