[PATCH v2] mtd: nand: add ->exec_op() implementation

Antoine Tenart antoine.tenart at free-electrons.com
Thu Dec 7 23:54:50 PST 2017


Hi Miquel,

Be careful when defining macros: avoid to name your arguments with a
value used in the macro that is not meant to be replaced.

On Thu, Dec 07, 2017 at 03:54:34PM +0100, Miquel Raynal wrote:
> +
> +#define NAND_OP_DATA_IN(l, buf, ns)					\
> +	{								\
> +		.type = NAND_OP_DATA_IN_INSTR,				\
> +		.ctx.data = {						\
> +			.len = l,					\
> +			.buf.in = buf,					\

Here.

> +			.force_8bit = false,				\
> +		},							\
> +		.delay_ns = ns,						\
> +	}
> +
> +#define NAND_OP_DATA_OUT(l, buf, ns)					\
> +	{								\
> +		.type = NAND_OP_DATA_OUT_INSTR,				\
> +		.ctx.data = {						\
> +			.len = l,					\
> +			.buf.out = buf,					\

And here.

> +			.force_8bit = false,				\
> +		},							\
> +		.delay_ns = ns,						\
> +	}

It works in your series because these macros are always called with the
second argument being a variable named 'buf', but that's not safe.

Thanks!
Antoine

-- 
Antoine Ténart, Free Electrons
Embedded Linux and Kernel engineering
http://free-electrons.com



More information about the linux-mtd mailing list