Re: [PATCH 2/2] ext2: Add locking for DAX faults

From: Ross Zwisler
Date: Tue Oct 13 2015 - 18:15:35 EST


On Tue, Oct 13, 2015 at 12:35:44AM +0100, Eric Curtin wrote:
> Hi Ross,
>
> For all those int ret declarations. Why not declare and initialize all
> on the same line?
>
> Regards,
> Eric

Because the return value 'ret' is set unconditionally later in the function as
part of a call into the DAX code. This call needs to be made after we've done
appropriate locking, though, which really is the point of the ext2 wrapper for
the DAX function. Setting it to some random value and then unconditionally
overwriting it later in the function is a bad pattern because a) the initial
value is meaningless and b) it can hide coding errors where you are no longer
setting the variable to something meaningful. The "warning: âretâ is used
uninitialized in this function" warnings would otherwise warn you that you've
made a mistake.
--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/