public inbox for linux-xfs@vger.kernel.org
 help / color / mirror / Atom feed
* [PATCH 0/2] xfs: warning fixes needed for libxfs
@ 2010-01-19  0:41 Dave Chinner
  2010-01-19  0:41 ` [PATCH 1/2] xfs: suppress spurious uninitialised var warning in xfs_bmapi() Dave Chinner
  2010-01-19  0:41 ` [PATCH 2/2] xfs: rearrange xfs_mod_sb() to avoid array subscript warning Dave Chinner
  0 siblings, 2 replies; 6+ messages in thread
From: Dave Chinner @ 2010-01-19  0:41 UTC (permalink / raw)
  To: xfs

These two patches are needed to suppress warnings in libxfs. The
changes are being made to the kernel code so that a resync of the
kernel code to the userspace libxfs will fix these warnings.

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

^ permalink raw reply	[flat|nested] 6+ messages in thread

* [PATCH 1/2] xfs: suppress spurious uninitialised var warning in xfs_bmapi()
  2010-01-19  0:41 [PATCH 0/2] xfs: warning fixes needed for libxfs Dave Chinner
@ 2010-01-19  0:41 ` Dave Chinner
  2010-01-19  9:22   ` Christoph Hellwig
  2010-01-19  0:41 ` [PATCH 2/2] xfs: rearrange xfs_mod_sb() to avoid array subscript warning Dave Chinner
  1 sibling, 1 reply; 6+ messages in thread
From: Dave Chinner @ 2010-01-19  0:41 UTC (permalink / raw)
  To: xfs

Initialise the xfs_bmalloca_t structure to zero to avoid uninitialised
variable warnings. This is done by zeroing the arg structure rather than
using the uninitialised_var() trick so we know for certain that the
structure is correctly initialised as xfs_bmapi is a very complex
function and it is difficult to prove warnings are spurious.

Signed-off-by: Dave Chinner <david@fromorbit.com>
---
 fs/xfs/xfs_bmap.c |    2 +-
 1 files changed, 1 insertions(+), 1 deletions(-)

diff --git a/fs/xfs/xfs_bmap.c b/fs/xfs/xfs_bmap.c
index 7c6d9ac..1869fb9 100644
--- a/fs/xfs/xfs_bmap.c
+++ b/fs/xfs/xfs_bmap.c
@@ -4471,7 +4471,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 */
-- 
1.6.5

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

^ permalink raw reply related	[flat|nested] 6+ messages in thread

* [PATCH 2/2] xfs: rearrange xfs_mod_sb() to avoid array subscript warning
  2010-01-19  0:41 [PATCH 0/2] xfs: warning fixes needed for libxfs Dave Chinner
  2010-01-19  0:41 ` [PATCH 1/2] xfs: suppress spurious uninitialised var warning in xfs_bmapi() Dave Chinner
@ 2010-01-19  0:41 ` Dave Chinner
  2010-01-19  9:23   ` Christoph Hellwig
  1 sibling, 1 reply; 6+ messages in thread
From: Dave Chinner @ 2010-01-19  0:41 UTC (permalink / raw)
  To: xfs

gcc warns of an array subscript out of bounds in xfs_mod_sb().
The code is written in such a way that if the array subscript is
out of bounds, then it will assert fail. Rearrange the code to
avoid the bounds check warning.

Signed-off-by: Dave Chinner <david@fromorbit.com>
---
 fs/xfs/xfs_mount.c |    7 +++----
 1 files changed, 3 insertions(+), 4 deletions(-)

diff --git a/fs/xfs/xfs_mount.c b/fs/xfs/xfs_mount.c
index 0df5045..d95bd18 100644
--- a/fs/xfs/xfs_mount.c
+++ b/fs/xfs/xfs_mount.c
@@ -1631,15 +1631,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 */
+	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

^ permalink raw reply related	[flat|nested] 6+ messages in thread

* Re: [PATCH 1/2] xfs: suppress spurious uninitialised var warning in xfs_bmapi()
  2010-01-19  0:41 ` [PATCH 1/2] xfs: suppress spurious uninitialised var warning in xfs_bmapi() Dave Chinner
@ 2010-01-19  9:22   ` Christoph Hellwig
  0 siblings, 0 replies; 6+ messages in thread
From: Christoph Hellwig @ 2010-01-19  9:22 UTC (permalink / raw)
  To: Dave Chinner; +Cc: xfs

On Tue, Jan 19, 2010 at 11:41:50AM +1100, Dave Chinner wrote:
> Initialise the xfs_bmalloca_t structure to zero to avoid uninitialised
> variable warnings. This is done by zeroing the arg structure rather than
> using the uninitialised_var() trick so we know for certain that the
> structure is correctly initialised as xfs_bmapi is a very complex
> function and it is difficult to prove warnings are spurious.
> 
> Signed-off-by: Dave Chinner <david@fromorbit.com>

Looks good,


Reviewed-by: Christoph Hellwig <hch@lst.de>

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

^ permalink raw reply	[flat|nested] 6+ messages in thread

* Re: [PATCH 2/2] xfs: rearrange xfs_mod_sb() to avoid array subscript warning
  2010-01-19  0:41 ` [PATCH 2/2] xfs: rearrange xfs_mod_sb() to avoid array subscript warning Dave Chinner
@ 2010-01-19  9:23   ` Christoph Hellwig
  2010-01-19 11:11     ` Dave Chinner
  0 siblings, 1 reply; 6+ messages in thread
From: Christoph Hellwig @ 2010-01-19  9:23 UTC (permalink / raw)
  To: Dave Chinner; +Cc: xfs

On Tue, Jan 19, 2010 at 11:41:51AM +1100, Dave Chinner wrote:
> gcc warns of an array subscript out of bounds in xfs_mod_sb().
> The code is written in such a way that if the array subscript is
> out of bounds, then it will assert fail. Rearrange the code to
> avoid the bounds check warning.

Does it avoid the warning also for non-debug builds where the assert
goes away?  Anyway, the reordering is correct, so:


Reviewed-by: Christoph Hellwig <hch@lst.de>

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

^ permalink raw reply	[flat|nested] 6+ messages in thread

* Re: [PATCH 2/2] xfs: rearrange xfs_mod_sb() to avoid array subscript warning
  2010-01-19  9:23   ` Christoph Hellwig
@ 2010-01-19 11:11     ` Dave Chinner
  0 siblings, 0 replies; 6+ messages in thread
From: Dave Chinner @ 2010-01-19 11:11 UTC (permalink / raw)
  To: Christoph Hellwig; +Cc: xfs

On Tue, Jan 19, 2010 at 04:23:20AM -0500, Christoph Hellwig wrote:
> On Tue, Jan 19, 2010 at 11:41:51AM +1100, Dave Chinner wrote:
> > gcc warns of an array subscript out of bounds in xfs_mod_sb().
> > The code is written in such a way that if the array subscript is
> > out of bounds, then it will assert fail. Rearrange the code to
> > avoid the bounds check warning.
> 
> Does it avoid the warning also for non-debug builds where the assert
> goes away?  Anyway, the reordering is correct, so:

Yes.

Cheers,

Dave.
-- 
Dave Chinner
david@fromorbit.com

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

^ permalink raw reply	[flat|nested] 6+ messages in thread

end of thread, other threads:[~2010-01-19 11:10 UTC | newest]

Thread overview: 6+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2010-01-19  0:41 [PATCH 0/2] xfs: warning fixes needed for libxfs Dave Chinner
2010-01-19  0:41 ` [PATCH 1/2] xfs: suppress spurious uninitialised var warning in xfs_bmapi() Dave Chinner
2010-01-19  9:22   ` Christoph Hellwig
2010-01-19  0:41 ` [PATCH 2/2] xfs: rearrange xfs_mod_sb() to avoid array subscript warning Dave Chinner
2010-01-19  9:23   ` Christoph Hellwig
2010-01-19 11:11     ` Dave Chinner

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox