[PATCH 2/2] mtd: cmdlinepart: skip partitions truncated to zero

Shmulik Ladkani shmulik.ladkani at gmail.com
Mon Dec 17 02:07:43 EST 2012


Thanks Chris,

On Sun, 16 Dec 2012 19:59:30 -0500 Christopher Cordahi <christophercordahi at nanometrics.ca> wrote:
> Perform flash size truncation before skipping zero sized partition
> so that if the result is a zero sized, it will be skipped like the
> others.
> 
> Signed-off-by: Christopher Cordahi <christophercordahi at nanometrics.ca>

Acked-by: Shmulik Ladkani <shmulik.ladkani at gmail.com>

> @@ -330,6 +330,14 @@ static int parse_cmdline_partitions(struct mtd_info *master,
>  		if (part->parts[i].size == SIZE_REMAINING)
>  			part->parts[i].size = master->size - offset;
>  
> +		if (offset + part->parts[i].size > master->size) {
> +			printk(KERN_WARNING ERRP
> +			       "%s: partitioning exceeds flash size, truncating\n",
> +			       part->mtd_id);
> +			part->parts[i].size = master->size - offset;
> +		}
> +		offset += part->parts[i].size;
> +
>  		if (part->parts[i].size == 0) {
>  			printk(KERN_WARNING ERRP
>  			       "%s: skipping zero sized partition\n",
> @@ -338,16 +346,7 @@ static int parse_cmdline_partitions(struct mtd_info *master,
>  			memmove(&part->parts[i], &part->parts[i + 1],
>  				sizeof(*part->parts) * (part->num_parts - i));
>  			i--;
> -			continue;
>  		}

Taking another look (this relates to your prev patch as well), maybe
it would be cleaner to avoid the "i--" by converting this 'for' loop to a
'while' loop, executing the "i++" at the end of the loop, keeping the
explicit 'continue' in the 'size == 0' case.

Regards,
Shmulik



More information about the linux-mtd mailing list