From: Qu Wenruo <quwenruo.btrfs@gmx.com>
To: dsterba@suse.cz, Qu Wenruo <wqu@suse.com>, linux-btrfs@vger.kernel.org
Subject: Re: [PATCH 2/2] btrfs: tree-checker: Avoid using max() for stack array allocation
Date: Wed, 26 Sep 2018 08:19:46 +0800	[thread overview]
Message-ID: <848c89dd-2165-fcc8-9da7-0876a4e5a19c@gmx.com> (raw)
In-Reply-To: <20180925153428.GF3255@twin.jikos.cz>
[-- Attachment #1.1: Type: text/plain, Size: 1762 bytes --]
On 2018/9/25 下午11:34, David Sterba wrote:
> On Tue, Sep 25, 2018 at 08:06:26AM +0800, Qu Wenruo wrote:
>> Although BTRFS_NAME_LEN and XATTR_NAME_MAX is the same value (255),
>> max(BTRFS_NAME_LEN, XATTR_NAME_MAX) should be optimized as const at
>> runtime.
>>
>> However S390x' arch dependent option "-mwarn-dynamicstack" could still
>> report it as dyanamic stack allocation.
>>
>> Just use BTRFS_NAME_LEN directly to avoid such false alert.
> 
> Same reasoning as for the NAME_MAX, these are different things.
> 
>> Signed-off-by: Qu Wenruo <wqu@suse.com>
>> ---
>>  fs/btrfs/tree-checker.c | 2 +-
>>  1 file changed, 1 insertion(+), 1 deletion(-)
>>
>> diff --git a/fs/btrfs/tree-checker.c b/fs/btrfs/tree-checker.c
>> index db835635372f..4c045609909b 100644
>> --- a/fs/btrfs/tree-checker.c
>> +++ b/fs/btrfs/tree-checker.c
>> @@ -336,7 +336,7 @@ static int check_dir_item(struct btrfs_fs_info *fs_info,
>>  		 */
>>  		if (key->type == BTRFS_DIR_ITEM_KEY ||
>>  		    key->type == BTRFS_XATTR_ITEM_KEY) {
>> -			char namebuf[max(BTRFS_NAME_LEN, XATTR_NAME_MAX)];
>> +			char namebuf[BTRFS_NAME_LEN];
> 
> The updated implementation of max() can now handle the expression
> without a warning, with sufficiently new compiler so I don't think we
> need to fix that.
Yes, it's mostly a workaround to make S390 happy.
And if it can be fixed by kernel config/compiler, it doesn't make much
sense to fix it here.
So please discard these 2 patches.
Thanks,
Qu
> 
> Alternatively, you could use BTRFS_NAME_LEN and add a
> BUILD_BUG_ON(BTRFS_NAME_LEN < XATTR_NAME_MAX) with a comment why.
> 
>>  
>>  			read_extent_buffer(leaf, namebuf,
>>  					(unsigned long)(di + 1), name_len);
>> -- 
>> 2.19.0
[-- Attachment #2: OpenPGP digital signature --]
[-- Type: application/pgp-signature, Size: 488 bytes --]
next prev parent reply	other threads:[~2018-09-26  0:20 UTC|newest]
Thread overview: 6+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2018-09-25  0:06 [PATCH 1/2] btrfs: Use NAME_MAX to replace intermediate number of BTRFS_NAME_LEN Qu Wenruo
2018-09-25  0:06 ` [PATCH 2/2] btrfs: tree-checker: Avoid using max() for stack array allocation Qu Wenruo
2018-09-25 15:34   ` David Sterba
2018-09-26  0:19     ` Qu Wenruo [this message]
2018-09-25  1:03 ` [PATCH 1/2] btrfs: Use NAME_MAX to replace intermediate number of BTRFS_NAME_LEN Su Yue
2018-09-25 15:29 ` David Sterba
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=848c89dd-2165-fcc8-9da7-0876a4e5a19c@gmx.com \
    --to=quwenruo.btrfs@gmx.com \
    --cc=dsterba@suse.cz \
    --cc=linux-btrfs@vger.kernel.org \
    --cc=wqu@suse.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;
as well as URLs for NNTP newsgroup(s).