On Thu, Oct 02, 2014 at 08:32:01AM +0800, Anand Jain wrote:
> chunk-recover.c: In function ‘btrfs_calc_stripe_index’:
> chunk-recover.c:1481: warning: ‘index’ may be used uninitialized in this 
> function
> --- a/chunk-recover.c
> +++ b/chunk-recover.c
> @@ -1478,7 +1478,7 @@ static int btrfs_calc_stripe_index(struct chunk_record 
> *chunk, u64 logical)
>       u64 offset = logical - chunk->offset;
>       int stripe_nr;
>       int nr_data_stripes;
> -     int index;
> +     int index = 0;
>  
>       stripe_nr = offset / chunk->stripe_len;
>       if (chunk->type_flags & BTRFS_BLOCK_GROUP_RAID0) {

The catch-all branch does BUG_ON so the compiler probably misses that
for some reason, otherwise the index value is always defined. It would
be better to replace the BUG_ON with "return -1" and handle the error in
the callers.

The BUG_ON happens if there's an unknown block group type, these are
well known and any error here means there's a corruption or unsupported
type. Both condition could be handled in a better way.
--
To unsubscribe from this list: send the line "unsubscribe linux-btrfs" in
the body of a message to [email protected]
More majordomo info at  http://vger.kernel.org/majordomo-info.html

Reply via email to