Re: [PATCH] btrfs: fix a compiler warning of may be used uninitialized

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



On Wed, Sep 30, 2015 at 11:55:13AM +0800, Zhao Lei wrote:
> > AFAICS the codepath that would use uninitialized value of count is not
> > reachable:
> > 
> > 		    add_to_ctl = true
> > 
> > 270                 if (info->offset > root->ino_cache_progress)
> > 271                         add_to_ctl = false;
> > 272                 else if (info->offset + info->bytes >
> > root->ino_cache_progress)
> > 273                         count = root->ino_cache_progress -
> > info->offset + 1;
> > 274                 else
> > 275                         count = info->bytes;
> > 276
> > 277                 rb_erase(&info->offset_index, rbroot);
> > 278                 spin_unlock(rbroot_lock);
> > 279                 if (add_to_ctl)
> > 280                         __btrfs_add_free_space(ctl, info->offset,
> > count);
> > 
> > count is defined iff add_to_ctl == true, so the patch is not necessary. And I'm
> > not quite sure that 0 passed down to __btrfs_add_free_space as 'bytes' makes
> > sense at all.
> 
> Agree above all.
> 
> So I write following description in changelog:
>   "Not real problem, just avoid warning of: ..."
> 
> It is just to avoid complier warning, no function changed.
> A warning in compiler output is not pretty:)

And the compiler is wrong in this case, the code is fine as is. I'd say
go fix you compiler and the output will be pretty :) No really, this
kind of fixes brings false sense of "fixing something in the code".
--
To unsubscribe from this list: send the line "unsubscribe linux-btrfs" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at  http://vger.kernel.org/majordomo-info.html




[Index of Archives]     [Linux Filesystem Development]     [Linux NFS]     [Linux NILFS]     [Linux USB Devel]     [Linux Audio Users]     [Yosemite News]     [Linux Kernel]     [Linux SCSI]

  Powered by Linux