Re: [PATCH 2/5] xfs: factor data block addition from xfs_dir2_node_addname_int()

Christoph Hellwig
2018-10-26T20:38:28Z

On Fri, Oct 26, 2018 at 09:52:45PM +1100, Dave Chinner wrote:
> Which causes build warnings because gcc can't work out the code flow
> if I leave it alone. And seeing as I use -Werror on the fs/xfs/
> directories, that breaks the build.
>
> So I'd prefer to leave it like this without a transient build
> warning....

With this incremental patch I don't see any warning, and I really
can't see how it could cause any warnings:

(it is basically a revert of a tiny part of your patch).

diff --git a/fs/xfs/libxfs/xfs_dir2_node.c b/fs/xfs/libxfs/xfs_dir2_node.c
index df109763db39..4ab2447cd343 100644
--- a/fs/xfs/libxfs/xfs_dir2_node.c
+++ b/fs/xfs/libxfs/xfs_dir2_node.c
@@ -1916,7 +1916,6 @@ xfs_dir2_node_addname_int(

/* setup current free block buffer */
free = fbp->b_addr;
- bests = dp->d_ops->free_bests_p(free);

/* we're going to have to log the free block index later */
logfree = 1;
@@ -1932,9 +1931,6 @@ xfs_dir2_node_addname_int(
-1, &dbp);
if (error)
return error;
-
- /* suppress gcc maybe-used-initialised warning */
- bests = dp->d_ops->free_bests_p(free);
}

/* setup for data block up now */
@@ -1972,6 +1968,7 @@ xfs_dir2_node_addname_int(
xfs_dir2_data_log_header(args, dbp);

/* If the freespace block entry is now wrong, update it. */
+ bests = dp->d_ops->free_bests_p(free); /* gcc is so stupid */
if (bests[findex] != bf[0].length) {
bests[findex] = bf[0].length;
logfree = 1;