From patchwork Fri Sep 1 15:57:33 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "Darrick J. Wong" X-Patchwork-Id: 9934713 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork.web.codeaurora.org (Postfix) with ESMTP id 272FA6038C for ; Fri, 1 Sep 2017 15:58:05 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 19DB21FF73 for ; Fri, 1 Sep 2017 15:58:05 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 0EA9624B48; Fri, 1 Sep 2017 15:58:05 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-6.9 required=2.0 tests=BAYES_00, RCVD_IN_DNSWL_HI, UNPARSEABLE_RELAY autolearn=ham version=3.3.1 Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 7DA801FF73 for ; Fri, 1 Sep 2017 15:58:04 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1751039AbdIAP6D (ORCPT ); Fri, 1 Sep 2017 11:58:03 -0400 Received: from userp1040.oracle.com ([156.151.31.81]:19389 "EHLO userp1040.oracle.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751968AbdIAP6D (ORCPT ); Fri, 1 Sep 2017 11:58:03 -0400 Received: from userv0021.oracle.com (userv0021.oracle.com [156.151.31.71]) by userp1040.oracle.com (Sentrion-MTA-4.3.2/Sentrion-MTA-4.3.2) with ESMTP id v81FvZ3V008807 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Fri, 1 Sep 2017 15:57:35 GMT Received: from aserv0121.oracle.com (aserv0121.oracle.com [141.146.126.235]) by userv0021.oracle.com (8.14.4/8.14.4) with ESMTP id v81FvZa3028783 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Fri, 1 Sep 2017 15:57:35 GMT Received: from abhmp0005.oracle.com (abhmp0005.oracle.com [141.146.116.11]) by aserv0121.oracle.com (8.14.4/8.13.8) with ESMTP id v81FvZnw010227; Fri, 1 Sep 2017 15:57:35 GMT Received: from localhost (/73.25.142.12) by default (Oracle Beehive Gateway v4.0) with ESMTP ; Fri, 01 Sep 2017 08:57:34 -0700 Date: Fri, 1 Sep 2017 08:57:33 -0700 From: "Darrick J. Wong" To: xfs Cc: Brian Foster , Dave Chinner , Christoph Hellwig Subject: [PATCH] xfs: ASSERT should always evaluate its parameter Message-ID: <20170901155733.GA3775@magnolia> MIME-Version: 1.0 Content-Disposition: inline User-Agent: Mutt/1.5.24 (2015-08-30) X-Source-IP: userv0021.oracle.com [156.151.31.71] Sender: linux-xfs-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-xfs@vger.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP Ensure that ASSERT evalulates its expression argument so that we don't get a ton of compiler warnings in non-warn non-debug mode. Fix up everything that breaks as a result. Signed-off-by: Darrick J. Wong --- fs/xfs/libxfs/xfs_bmap.c | 2 +- fs/xfs/libxfs/xfs_dir2_node.c | 2 -- fs/xfs/xfs_inode.c | 8 ++++++++ fs/xfs/xfs_linux.h | 3 ++- fs/xfs/xfs_trans.c | 2 ++ 5 files changed, 13 insertions(+), 4 deletions(-) -- To unsubscribe from this list: send the line "unsubscribe linux-xfs" in the body of a message to majordomo@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html diff --git a/fs/xfs/libxfs/xfs_bmap.c b/fs/xfs/libxfs/xfs_bmap.c index 9558f5e..883a626 100644 --- a/fs/xfs/libxfs/xfs_bmap.c +++ b/fs/xfs/libxfs/xfs_bmap.c @@ -579,7 +579,7 @@ xfs_bmap_validate_ret( #else #define xfs_bmap_check_leaf_extents(cur, ip, whichfork) do { } while (0) -#define xfs_bmap_validate_ret(bno,len,flags,mval,onmap,nmap) +#define xfs_bmap_validate_ret(bno,len,flags,mval,onmap,nmap) ((void)0) #endif /* DEBUG */ /* diff --git a/fs/xfs/libxfs/xfs_dir2_node.c b/fs/xfs/libxfs/xfs_dir2_node.c index 682e2bf..e57a80b 100644 --- a/fs/xfs/libxfs/xfs_dir2_node.c +++ b/fs/xfs/libxfs/xfs_dir2_node.c @@ -1005,9 +1005,7 @@ xfs_dir2_leafn_rebalance( xfs_dir2_leaf_t *leaf1; /* first leaf structure */ xfs_dir2_leaf_t *leaf2; /* second leaf structure */ int mid; /* midpoint leaf index */ -#if defined(DEBUG) || defined(XFS_WARN) int oldstale; /* old count of stale leaves */ -#endif int oldsum; /* old total leaf count */ int swap; /* swapped leaf blocks */ struct xfs_dir2_leaf_entry *ents1; diff --git a/fs/xfs/xfs_inode.c b/fs/xfs/xfs_inode.c index 5599dda..0eaf1f1 100644 --- a/fs/xfs/xfs_inode.c +++ b/fs/xfs/xfs_inode.c @@ -382,6 +382,14 @@ xfs_isilocked( ASSERT(0); return 0; } +#else +int +xfs_isilocked( + xfs_inode_t *ip, + uint lock_flags) +{ + return 0; +} #endif #ifdef DEBUG diff --git a/fs/xfs/xfs_linux.h b/fs/xfs/xfs_linux.h index c19c999..7c69f08 100644 --- a/fs/xfs/xfs_linux.h +++ b/fs/xfs/xfs_linux.h @@ -260,7 +260,8 @@ static inline uint64_t howmany_64(uint64_t x, uint32_t y) #else /* !DEBUG && !XFS_WARN */ -#define ASSERT(expr) ((void)0) +#define ASSERT(expr) \ + (likely(expr) ? (void)0 : (void)0) #ifndef STATIC # define STATIC static noinline diff --git a/fs/xfs/xfs_trans.c b/fs/xfs/xfs_trans.c index a87f657..45e30ba 100644 --- a/fs/xfs/xfs_trans.c +++ b/fs/xfs/xfs_trans.c @@ -421,9 +421,11 @@ xfs_trans_apply_sb_deltas( /* * Check that superblock mods match the mods made to AGF counters. */ +#if defined(DEBUG) || defined(XFS_WARN) ASSERT((tp->t_fdblocks_delta + tp->t_res_fdblocks_delta) == (tp->t_ag_freeblks_delta + tp->t_ag_flist_delta + tp->t_ag_btree_delta)); +#endif /* * Only update the superblock counters if we are logging them