On Sun, 2012-08-26 at 13:21 -0400, Huang Shijie wrote:
> +/* There are only several partitions, so the Bubble sort is enough. */
> +static inline void sort_partitons(struct mtd_partition *parts, int num_parts)
> +{
> +     int i, j;
> +
> +     if (num_parts < 2)
> +             return;

Not necessary, the for loop should work for this case.
> +
> +     if (parts[0].offset == OFFSET_CONTINUOUS)
> +             return;

Hmm, I guess the sorting function should not have this check. You
probably can just sort normally these ones, they will be the last ones.

And then we can do a separate pass where we check for overlapping
partitions and multiple OFFSET_CONTINUOUS.

> +
> +     /* sort by the offset */
> +     for (i = 0; i < num_parts - 1; i++) {
> +             for (j = 1; j < num_parts - i; j++) {
> +                     if (parts[j - 1].offset > parts[j].offset) {
> +                             struct mtd_partition tmp;
> +
> +                             tmp = parts[j - 1];
> +                             parts[j - 1] = parts[j];
> +                             parts[j] = tmp;
> +                     }
> +             }
> +     }
> +     return;
> +}


-- 
Best Regards,
Artem Bityutskiy

Attachment: signature.asc
Description: This is a digitally signed message part

Reply via email to