On Thu, Dec 17, 2020 at 02:13:37PM +0800, Qu Wenruo wrote:
> 
> 
> On 2020/12/17 下午1:59, Nikolay Borisov wrote:
> > 
> > 
> > On 17.12.20 г. 7:55 ч., Nikolay Borisov wrote:
> >>
> >>
> >> On 17.12.20 г. 6:57 ч., Qu Wenruo wrote:
> >>> In btrfs_invalidatepage() we re-declare @tree variable as
> >>> btrfs_ordered_inode_tree.
> >>>
> >>> Remove such variable shadowing which can be very confusing.
> >>
> >> You can't do that, because lock_extent_bits expects extent_io_tree !
> >>
> > 
> > Ok, nvm, you just factored the var at the beginning of the functions.
> > OTOH since the ordered tree is used just for lock/unlock why not do
> > spin_(un)lock(&inode->ordered_tree->lock);
> > 
> Oh, that indeed looks better and since Su is also complaining about the 
> declaration at the beginning of the function, I guess that's the better 
> way to go.

The preferred style is to declare variables in the closest scope, so
there's not a huge blob of declarations that are randomly used inside
nested blocks. It's more like a recommendation, eg. when the function is
short and there are a few variables  used inside a for/while.

Reply via email to