On 16.11.18 г. 9:54 ч., Qu Wenruo wrote:
> The only location is the following code:
> 
>       int level = path->lowest_level + 1;
>       BUG_ON(path->lowest_level + 1 >= BTRFS_MAX_LEVEL);
>       while(level < BTRFS_MAX_LEVEL) {
>               slot = path->slots[level] + 1;
>               ...
>       }
>       path->slots[level] = slot;
> 
> Again, it's the stupid compiler needs some hint for the fact that
> we will always enter the while loop for at least once, thus @slot should
> always be initialized.
> 
> Fix it by assign level after the BUG_ON(), so the stupid compiler knows
> we will always go into the while loop.
> 
> Signed-off-by: Qu Wenruo <w...@suse.com>

I don't get this warning on gcc 7.3. Also from your changelog it's not
really clear what the compiler is confused about.

Codewise lgtm:

Reviewed-by: Nikolay Borisov <nbori...@suse.com>

> ---
>  ctree.c | 3 ++-
>  1 file changed, 2 insertions(+), 1 deletion(-)
> 
> diff --git a/ctree.c b/ctree.c
> index 46e2ccedc0bf..9c9cb0dfdbf2 100644
> --- a/ctree.c
> +++ b/ctree.c
> @@ -2961,11 +2961,12 @@ int btrfs_next_sibling_tree_block(struct 
> btrfs_fs_info *fs_info,
>                                 struct btrfs_path *path)
>  {
>       int slot;
> -     int level = path->lowest_level + 1;
> +     int level;
>       struct extent_buffer *c;
>       struct extent_buffer *next = NULL;
>  
>       BUG_ON(path->lowest_level + 1 >= BTRFS_MAX_LEVEL);
> +     level = path->lowest_level + 1;
>       while(level < BTRFS_MAX_LEVEL) {
>               if (!path->nodes[level])
>                       return 1;
> 

Reply via email to