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