[PATCH 2/3] xfsprogs: Fix miscellaneous warnings in libxfs
Dave Chinner
david at fromorbit.com
Thu Jan 14 02:43:50 CST 2010
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 at 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
More information about the xfs
mailing list