All of lore.kernel.org
 help / color / mirror / Atom feed
From: Eric Biggers <ebiggers3@gmail.com>
To: linux-xfs@vger.kernel.org
Cc: Eric Biggers <ebiggers@google.com>
Subject: [PATCH] xfs: avoid -Wint-in-bool-context warning in xfs_bmap_util.c
Date: Fri,  2 Jun 2017 21:21:07 -0700	[thread overview]
Message-ID: <20170603042107.17469-1-ebiggers3@gmail.com> (raw)

From: Eric Biggers <ebiggers@google.com>

XFS triggers gcc 7's -Wint-in-bool-context warning (on by default with
-Wall), which warns about arithmetic in a boolean context that has no
effect on the result:

    In file included from fs/xfs/xfs_inode.h:22:0,
                     from fs/xfs/xfs_bmap_util.c:29:
    fs/xfs/xfs_bmap_util.c: In function ‘xfs_swap_extents_check_format’:
    fs/xfs/libxfs/xfs_inode_fork.h:90:30: warning: ‘<<’ in boolean context, did you mean ‘<’ ? [-Wint-in-bool-context]
     #define XFS_IFORK_BOFF(ip)  ((int)((ip)->i_d.di_forkoff << 3))
                                 ~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
    fs/xfs/xfs_bmap_util.c:1620:7: note: in expansion of macro ‘XFS_IFORK_BOFF’
       if (XFS_IFORK_BOFF(ip) &&
           ^~~~~~~~~~~~~~
    fs/xfs/libxfs/xfs_inode_fork.h:90:30: warning: ‘<<’ in boolean context, did you mean ‘<’ ? [-Wint-in-bool-context]
     #define XFS_IFORK_BOFF(ip)  ((int)((ip)->i_d.di_forkoff << 3))
                                 ~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
    fs/xfs/xfs_bmap_util.c:1630:7: note: in expansion of macro ‘XFS_IFORK_BOFF’
       if (XFS_IFORK_BOFF(tip) &&
           ^~~~~~~~~~~~~~

This is more or less a false positive, because the useless arithmetic is
just the left shift in XFS_IFORK_BOFF().  Use XFS_IFORK_Q() instead to
make the warnings go away, while having the same behavior and being more
consistent with other places in XFS which also use XFS_IFORK_Q().

Signed-off-by: Eric Biggers <ebiggers@google.com>
---
 fs/xfs/xfs_bmap_util.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/fs/xfs/xfs_bmap_util.c b/fs/xfs/xfs_bmap_util.c
index 7ac80a1facf2..05a6fdf5976d 100644
--- a/fs/xfs/xfs_bmap_util.c
+++ b/fs/xfs/xfs_bmap_util.c
@@ -1613,7 +1613,7 @@ xfs_swap_extents_check_format(
 	 * extent format...
 	 */
 	if (tip->i_d.di_format == XFS_DINODE_FMT_BTREE) {
-		if (XFS_IFORK_BOFF(ip) &&
+		if (XFS_IFORK_Q(ip) &&
 		    XFS_BMAP_BMDR_SPACE(tip->i_df.if_broot) > XFS_IFORK_BOFF(ip))
 			return -EINVAL;
 		if (XFS_IFORK_NEXTENTS(tip, XFS_DATA_FORK) <=
@@ -1623,7 +1623,7 @@ xfs_swap_extents_check_format(
 
 	/* Reciprocal target->temp btree format checks */
 	if (ip->i_d.di_format == XFS_DINODE_FMT_BTREE) {
-		if (XFS_IFORK_BOFF(tip) &&
+		if (XFS_IFORK_Q(tip) &&
 		    XFS_BMAP_BMDR_SPACE(ip->i_df.if_broot) > XFS_IFORK_BOFF(tip))
 			return -EINVAL;
 		if (XFS_IFORK_NEXTENTS(ip, XFS_DATA_FORK) <=
-- 
2.13.0


             reply	other threads:[~2017-06-03  4:22 UTC|newest]

Thread overview: 3+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2017-06-03  4:21 Eric Biggers [this message]
2017-06-03  4:50 ` [PATCH] xfs: avoid -Wint-in-bool-context warning in xfs_bmap_util.c Darrick J. Wong
2017-06-03  5:23   ` Eric Biggers

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=20170603042107.17469-1-ebiggers3@gmail.com \
    --to=ebiggers3@gmail.com \
    --cc=ebiggers@google.com \
    --cc=linux-xfs@vger.kernel.org \
    /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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.