public inbox for linux-xfs@vger.kernel.org
 help / color / mirror / Atom feed
From: Dave Chinner <david@fromorbit.com>
To: xfs@oss.sgi.com
Subject: [PATCH 2/9] xfsprogs: Fix miscellaneous warnings in libxfs
Date: Thu, 14 Jan 2010 21:09:05 +1100	[thread overview]
Message-ID: <1263463752-5052-3-git-send-email-david@fromorbit.com> (raw)
In-Reply-To: <1263463752-5052-1-git-send-email-david@fromorbit.com>

These are questionable fixes but they do shut up the warnings with
as little change as possible. The first couple are questionable
because they are a result of the compiler (gcc 4.3.4) trying to be
smart but failing.

The uninitialised variable warnings in xfs_bmapi() is spurious, as
certain fields are unused in certain situations but gcc can't work
that out.  It is easily suppressed by initialising the structure to
zero.

xfs_mod_sb() is dumping out an array subscript bound warning that is
spurious. The code is correct and will assert fail on out of bounds
indexes. A simple reorder of the first and last offset calculations
makes the warning go away (a good sign of compiler fail if ever
there was one).

Changing xfs_alloc_mark_busy() from a macro to a static inline
definition is needed for the compiler to see that variables passed
to that function are actually used.

Signed-off-by: Dave Chinner <david@fromorbit.com>
---
 libxfs/xfs.h       |    5 +++--
 libxfs/xfs_bmap.c  |    2 +-
 libxfs/xfs_mount.c |    9 ++++-----
 3 files changed, 8 insertions(+), 8 deletions(-)

diff --git a/libxfs/xfs.h b/libxfs/xfs.h
index 8e94dad..abe8700 100644
--- a/libxfs/xfs.h
+++ b/libxfs/xfs.h
@@ -288,9 +288,10 @@ roundup_pow_of_two(uint v)
 #define xfs_ilock(ip,mode)				((void) 0)
 #define xfs_iunlock(ip,mode)				((void) 0)
 
-/* space allocation */
+/* space allocation - use static inlines to avoid unused var warnings */
 #define xfs_alloc_search_busy(tp,ag,b,len)	((void) 0)
-#define xfs_alloc_mark_busy(tp,ag,b,len)	((void) 0)
+static inline void xfs_alloc_mark_busy(xfs_trans_t *tp,
+	xfs_agnumber_t agno, xfs_agblock_t bno, xfs_extlen_t len) {}
 #define xfs_rotorstep				1
 #define xfs_bmap_rtalloc(a)			(ENOSYS)
 #define xfs_rtpick_extent(mp,tp,len,p)		(ENOSYS)
diff --git a/libxfs/xfs_bmap.c b/libxfs/xfs_bmap.c
index cf1123a..4cc6431 100644
--- a/libxfs/xfs_bmap.c
+++ b/libxfs/xfs_bmap.c
@@ -4274,7 +4274,7 @@ xfs_bmapi(
 	xfs_fsblock_t	abno;		/* allocated block number */
 	xfs_extlen_t	alen;		/* allocated extent length */
 	xfs_fileoff_t	aoff;		/* allocated file offset */
-	xfs_bmalloca_t	bma;		/* args for xfs_bmap_alloc */
+	xfs_bmalloca_t	bma = { 0 };	/* args for xfs_bmap_alloc */
 	xfs_btree_cur_t	*cur;		/* bmap btree cursor */
 	xfs_fileoff_t	end;		/* end of mapped file region */
 	int		eof;		/* we've hit the end of extents */
diff --git a/libxfs/xfs_mount.c b/libxfs/xfs_mount.c
index 02bff42..662c8d2 100644
--- a/libxfs/xfs_mount.c
+++ b/libxfs/xfs_mount.c
@@ -400,15 +400,14 @@ xfs_mod_sb(xfs_trans_t *tp, __int64_t fields)
 
 	xfs_sb_to_disk(XFS_BUF_TO_SBP(bp), &mp->m_sb, fields);
 
-	/* find modified range */
+	/* find modified range - get last first to avoid spurious warning */
+	f = (xfs_sb_field_t)xfs_highbit64((__uint64_t)fields);
+	ASSERT((1LL << f) & XFS_SB_MOD_BITS);
+	last = xfs_sb_info[f + 1].offset - 1;
 
 	f = (xfs_sb_field_t)xfs_lowbit64((__uint64_t)fields);
 	ASSERT((1LL << f) & XFS_SB_MOD_BITS);
 	first = xfs_sb_info[f].offset;
 
-	f = (xfs_sb_field_t)xfs_highbit64((__uint64_t)fields);
-	ASSERT((1LL << f) & XFS_SB_MOD_BITS);
-	last = xfs_sb_info[f + 1].offset - 1;
-
 	xfs_trans_log_buf(tp, bp, first, last);
 }
-- 
1.6.5

_______________________________________________
xfs mailing list
xfs@oss.sgi.com
http://oss.sgi.com/mailman/listinfo/xfs

  parent reply	other threads:[~2010-01-14 10:12 UTC|newest]

Thread overview: 19+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2010-01-14 10:09 [PATCH 0/9] xfsprogs: fix build warnings V2 Dave Chinner
2010-01-14 10:09 ` [PATCH 1/9] xfsprogs: fix sign warnings in libxfs Dave Chinner
2010-01-17 12:10   ` Christoph Hellwig
2010-01-14 10:09 ` Dave Chinner [this message]
2010-01-17 11:53   ` [PATCH 2/9] xfsprogs: Fix miscellaneous " Christoph Hellwig
2010-01-14 10:09 ` [PATCH 3/9] xfsprogs: fix missing error check in xfs_rtfree_range " Dave Chinner
2010-01-17 11:52   ` Christoph Hellwig
2010-01-14 10:09 ` [PATCH 4/9] xfsprogs: fix warning in adfs superblock probe Dave Chinner
2010-01-17 12:11   ` Christoph Hellwig
2010-01-14 10:09 ` [PATCH 5/9] xfsprogs: fix some trivial warnings in xfs_db Dave Chinner
2010-01-17 12:12   ` Christoph Hellwig
2010-01-14 10:09 ` [PATCH 6/9] xfsprogs: fix trivial warnings in xfs_fsr Dave Chinner
2010-01-17 11:51   ` Christoph Hellwig
2010-01-14 10:09 ` [PATCH 7/9] xfsprogs: fix print format warnings in xfs_io Dave Chinner
2010-01-17 11:51   ` Christoph Hellwig
2010-01-14 10:09 ` [PATCH 8/9] xfsprogs: fix sign warning in mkfs directory code Dave Chinner
2010-01-17 12:13   ` Christoph Hellwig
2010-01-14 10:09 ` [PATCH 9/9] xfsprogs: fix build warnings in repair Dave Chinner
2010-01-15  7:09   ` Dave Chinner

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=1263463752-5052-3-git-send-email-david@fromorbit.com \
    --to=david@fromorbit.com \
    --cc=xfs@oss.sgi.com \
    /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