[PATCH v2 3/3] mtd: cmdlinepart: check the partitions
Artem Bityutskiy
dedekind1 at gmail.com
Tue Sep 4 04:19:45 EDT 2012
On Tue, 2012-09-04 at 15:43 +0800, Huang Shijie wrote:
> +enum partition_check_result {
> + PARTITION_GOOD,
> + PARTITION_OVERLAPPED,
> + PARTITION_HOLE,
> + PARTITION_TOO_MUCH_CONT,
> +};
Could you please kill these constants, they are not really needed I
think.
> +/* The partitions have been sorted well by the @offset. */
> +static inline int check_partitions(struct mtd_partition *parts, int num_parts)
> +{
> + int i;
> + uint64_t offset = 0;
> + int offset_continuous_cnt = 0;
> +
> + for (i = 0; i < num_parts; i++) {
> + if (parts[i].offset == OFFSET_CONTINUOUS) {
> + offset_continuous_cnt++;
> + continue;
> + }
> +
> + /* find a hole. */
> + if (parts[i].offset > offset)
> + return PARTITION_HOLE;
Just print the error messages in this function and return -EINVAL.
> @@ -285,13 +333,37 @@ static int mtdpart_setup_real(char *s)
> /* sort the partitions */
> sort_partitons(parts, num_parts);
>
> - /* link into chain */
> - this_mtd->next = partitions;
> - partitions = this_mtd;
> + /* check the partitions */
> + ret = check_partitions(parts, num_parts);
Just do
if (ret)
return ret;
and kill the huge 'switch' that you added.
--
Best Regards,
Artem Bityutskiy
-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 836 bytes
Desc: This is a digitally signed message part
URL: <http://lists.infradead.org/pipermail/linux-mtd/attachments/20120904/293eb97b/attachment.sig>
More information about the linux-mtd
mailing list