[PATCH 7/7] xfsprogs: fix build warnings in repair V2
Dave Chinner
david at fromorbit.com
Mon Jan 18 18:36:53 CST 2010
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. Version 2 fixes
a height overflow in the reworked loop.
Fix the directory name sign warnings by casting to (uchar_t *)
appropriately.
Signed-off-by: Dave Chinner <david at fromorbit.com>
---
repair/btree.c | 12 +++++++-----
repair/phase6.c | 10 +++++-----
2 files changed, 12 insertions(+), 10 deletions(-)
diff --git a/repair/btree.c b/repair/btree.c
index 3141388..22ab4d9 100644
--- a/repair/btree.c
+++ b/repair/btree.c
@@ -194,12 +194,14 @@ 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;
+ do {
+ if (cur->index)
+ break;
cur++;
- }
+ } while (++level < root->height);
+
+ if (level == root->height)
+ 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
More information about the xfs
mailing list