Re: [PATCH 9/9] xfsprogs: fix build warnings in repair

Dave Chinner
2010-01-15T07:08:31Z

On Thu, Jan 14, 2010 at 09:09:12PM +1100, Dave Chinner wrote:
> 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;

This is broken - causes a segv. i have a fixed patch, which I'll
send out once I've got xfstests running again on my test box (using
dash as /bin/sh breaks *lots* of stuff in xfstests).

Cheers,

Dave.
--
Dave Chinner
david@fromorbit.com