[PATCH v2] mtd: nand: ecc-hamming: Clarify the logic around rp17

Miquel Raynal miquel.raynal at bootlin.com
Thu Nov 19 16:11:50 EST 2020


On Fri, 2020-10-30 at 17:23:33 UTC, Miquel Raynal wrote:
> This code has been written in 2008 and is fine, but in order to keep
> robots happy, I think it's time to change a little bit this code just
> to clarify the different possible values of eccsize_mult. Indeed, this
> variable may only take the value 1 or 2 because step_size, in the case
> of the software Hamming ECC engine may only be 256 or 512. Depending
> on the value of eccsize_mult, an extra rp17 variable is set, or not
> and triggers the following warning:
> 
>      smatch warnings:
>      ecc_sw_hamming_calculate() error: uninitialized symbol 'rp17'.
> 
> As highlighted by Dan Carpenter, if the only possible values for
> eccsize_mult are 1 and 2, then the code is fine, but "it's hard to
> tell just from looking".
> 
> So instead of shifting step_size, let's use a ternary condition to
> assign to eccsize_mult the only two possible values and clarify the
> driver's logic.
> 
> Now that the situation is clarified for humans, ensure rp17 is
> initialized to 0 to keep compilers and robots silent as well.
> 
> Reported-by: kernel test robot <lkp at intel.com>
> Reported-by: Dan Carpenter <dan.carpenter at oracle.com>
> Signed-off-by: Miquel Raynal <miquel.raynal at bootlin.com>

Applied to https://git.kernel.org/pub/scm/linux/kernel/git/mtd/linux.git nand/next.

Miquel



More information about the linux-mtd mailing list