[PATCH] mtd: Fallback to ->_read/write_oob() when ->_read/write() is missing

Boris Brezillon boris.brezillon at free-electrons.com
Sun Jun 11 23:45:58 PDT 2017


Hi Robert,

Le Mon, 12 Jun 2017 08:24:04 +0200,
Robert Jarzmik <robert.jarzmik at free.fr> a écrit :

> Boris Brezillon <boris.brezillon at free-electrons.com> writes:
> 
> > Some MTD sublayers/drivers are implementing ->_read/write_oob() and
> > providing dummy wrappers for their ->_read/write() implementations.
> > Let the core handle this case instead of duplicating the logic.  
> 
> Hi Boris,
> 
> Unless I'm wrong, you're using mtd_oob_ops structures allocated on the
> stack. This means they are not filled with 0/NULL at initialization, and
> therefore the code is not equivalent to what was before in docg3 for example.
> 
> For example, oobbuf field needs initialization. Is it taken care in the core ?

According to the C99 standard (section 6.7.8.21):

"
If there are fewer initializers in a brace-enclosed list than there are
elements or members of an aggregate, or fewer characters in a string
literal used to initialize an array of known size than there are
elements in the array, the remainder of the aggregate shall be
initialized implicitly the same as objects that have static storage
duration.
"

which should guarantee that uninitialized fields are actually set to 0,
even when the struct is allocated on the stack.

Regards,

Boris



More information about the linux-mtd mailing list