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 9/9] xfsprogs: fix build warnings in repair
Date: Thu, 14 Jan 2010 21:09:12 +1100	[thread overview]
Message-ID: <1263463752-5052-10-git-send-email-david@fromorbit.com> (raw)
In-Reply-To: <1263463752-5052-1-git-send-email-david@fromorbit.com>

Rewrite the loop in btree_get_prev() so that the compiler
can see that it returns if the cur->index is zero so it
doesn't complain about possible array bound underflows
when getting the key out of the buffer.

Fix the directory name sign warnings by casting to (uchar_t *)
appropriately.

Signed-off-by: Dave Chinner <david@fromorbit.com>
---
 repair/btree.c  |    9 +++++----
 repair/phase6.c |   10 +++++-----
 2 files changed, 10 insertions(+), 9 deletions(-)

diff --git a/repair/btree.c b/repair/btree.c
index 3141388..b53b4e4 100644
--- a/repair/btree.c
+++ b/repair/btree.c
@@ -194,12 +194,13 @@ btree_get_prev(
 	}
 
 	/* else need to go up and back down the tree to find the previous */
-
-	while (cur->index == 0) {
-		if (++level == root->height)
-			return NULL;
+	while (++level < root->height) {
+		if (cur->index)
+			break;
 		cur++;
 	}
+	if (cur->index == 0)
+		return NULL;
 
 	/* the key is in the current level */
 	if (key)
diff --git a/repair/phase6.c b/repair/phase6.c
index d056063..884ad62 100644
--- a/repair/phase6.c
+++ b/repair/phase6.c
@@ -35,7 +35,7 @@ static struct cred		zerocr;
 static struct fsxattr 		zerofsx;
 static xfs_ino_t		orphanage_ino;
 
-static struct xfs_name 		xfs_name_dot = {".", 1};
+static struct xfs_name 		xfs_name_dot = {(uchar_t *)".", 1};
 
 /*
  * Data structures used to keep track of directories where the ".."
@@ -145,7 +145,7 @@ dir_hash_add(
 
 	ASSERT(!hashtab->names_duped);
 
-	xname.name = name;
+	xname.name = (uchar_t *)name;
 	xname.len = namelen;
 
 	junk = name[0] == '/';
@@ -355,7 +355,7 @@ dir_hash_dup_names(dir_hash_tab_t *hashtab)
 	for (p = hashtab->first; p; p = p->nextbyorder) {
 		name = malloc(p->name.len);
 		memcpy(name, p->name.name, p->name.len);
-		p->name.name = name;
+		p->name.name = (uchar_t *)name;
 	}
 	hashtab->names_duped = 1;
 }
@@ -843,7 +843,7 @@ mk_orphanage(xfs_mount_t *mp)
 		do_error(_("%d - couldn't iget root inode to obtain %s\n"),
 			i, ORPHANAGE);
 
-	xname.name = ORPHANAGE;
+	xname.name = (uchar_t *)ORPHANAGE;
 	xname.len = strlen(ORPHANAGE);
 	if (libxfs_dir_lookup(NULL, pip, &xname, &ino, NULL) == 0)
 		return ino;
@@ -944,7 +944,7 @@ mv_orphanage(
 
 	ASSERT(xfs_sb_version_hasdirv2(&mp->m_sb));
 
-	xname.name = fname;
+	xname.name = (uchar_t *)fname;
 	xname.len = snprintf(fname, sizeof(fname), "%llu",
 				(unsigned long long)ino);
 
-- 
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 ` [PATCH 2/9] xfsprogs: Fix miscellaneous " Dave Chinner
2010-01-17 11:53   ` 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 ` Dave Chinner [this message]
2010-01-15  7:09   ` [PATCH 9/9] xfsprogs: fix build warnings in repair 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-10-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