[U-Boot] [PATCH v5 4/5] mtdparts: add new sub-command "spread"

Scott Wood
2010-08-30T21:01:05Z

On Mon, 30 Aug 2010 13:38:59 -0400
Ben Gardiner <bengardiner@nanometrics.ca> wrote:

> +static void spread_partition(struct mtd_info *mtd, struct part_info *part,
> + uint64_t *next_offset)
> +{
> + uint64_t net_size, padding_size = 0;
> + int truncated;
> +
> + mtd_get_len_incl_bad(mtd, part->offset, part->size, &net_size,
> + &truncated);
> +
> + /*
> + * Absorb bad blocks immediately following this
> + * partition also into the partition, such that
> + * the next partition starts with a good block.
> + */

Why is the first block of a partition special?

> + if (!truncated) {
> + mtd_get_len_incl_bad(mtd, part->offset + net_size,
> + mtd->erasesize, &padding_size, &truncated);
> + padding_size -= mtd->erasesize;

What if this is the last partition? You're relying on an
implementation quick (bug?) that mtd_get_len_incl_bad() will let you
exceed the device size by a block if you start there. If it returned
the more expected zero in such a case, you'll end up subtracting a
block from net_size.

> + }
> +
> + if (truncated) {

} else {

-Scott