public inbox for linux-kernel@vger.kernel.org
 help / color / mirror / Atom feed
From: "Gustavo A. R. Silva" <gustavo@embeddedor.com>
To: Al Viro <viro@zeniv.linux.org.uk>,
	"Gustavo A. R. Silva" <gustavoars@kernel.org>
Cc: Mikulas Patocka <mikulas@artax.karlin.mff.cuni.cz>,
	linux-kernel@vger.kernel.org, linux-hardening@vger.kernel.org
Subject: Re: [PATCH][next] fs: hpfs: Avoid multiple -Wflex-array-member-not-at-end warnings
Date: Thu, 6 Feb 2025 11:51:12 +1030	[thread overview]
Message-ID: <08963f1d-7ae8-4fc4-a7dd-133e314c0fb0@embeddedor.com> (raw)
In-Reply-To: <20250205130308.GC1977892@ZenIV>



On 05/02/25 23:33, Al Viro wrote:
> On Tue, Feb 04, 2025 at 02:13:37PM +1030, Gustavo A. R. Silva wrote:
> 
>> +#define anode_btree	container_of(&anode->btree, struct bplus_header, __hdr)
>> +#define ranode_btree	container_of(&ranode->btree, struct bplus_header, __hdr)
>> +#define fnode_btree	container_of(&fnode->btree, struct bplus_header, __hdr)
>> +
>>   /* Find a sector in allocation tree */
>>   
>>   secno hpfs_bplus_lookup(struct super_block *s, struct inode *inode,
>> @@ -27,7 +31,7 @@ secno hpfs_bplus_lookup(struct super_block *s, struct inode *inode,
>>   				a = le32_to_cpu(btree->u.internal[i].down);
>>   				brelse(bh);
>>   				if (!(anode = hpfs_map_anode(s, a, &bh))) return -1;
>> -				btree = &anode->btree;
>> +				btree = anode_btree;
> 
> Just for this - NAK.  And then you proceed to add dozens more of the same.
> 
> If it looks like a variable name, it must not turn out to be a bloody macro;
> if a macro expansion depends upon a local variable with given name existing
> in scope of its use, make that name an explicit argument.  You manage to
> violate both.
> 

Yeah, so the story is that I originally wrote this patch using container_of()
to directly replace all those instances of `&anode->btree`, `&ranoce->btree`
and `&fnode->btree`. But I really didn't like how it turned out, so I changed
it to this form at the last minute, and well, as you pointed out, that wasn't
the best decision.

OK, so the options I see are either using container_of() directly (as I
originally had it), or write a small wrapper to keep the lines shorter.
Probably something like this:

#define GET_BTREE(ptr) \
	container_of(ptr, struct bplus_header, __hdr);

and then of course just using it like this:

	btree = GET_BTREE(&anode->btree);

-Gustavo





      reply	other threads:[~2025-02-06  1:21 UTC|newest]

Thread overview: 3+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2025-02-04  3:43 [PATCH][next] fs: hpfs: Avoid multiple -Wflex-array-member-not-at-end warnings Gustavo A. R. Silva
2025-02-05 13:03 ` Al Viro
2025-02-06  1:21   ` Gustavo A. R. Silva [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=08963f1d-7ae8-4fc4-a7dd-133e314c0fb0@embeddedor.com \
    --to=gustavo@embeddedor.com \
    --cc=gustavoars@kernel.org \
    --cc=linux-hardening@vger.kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=mikulas@artax.karlin.mff.cuni.cz \
    --cc=viro@zeniv.linux.org.uk \
    /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