Patchwork mtd: cmdlinepart: fix the wrong partitions number when truncating occurs

login
register
mail settings
Submitter Huang Shijie
Date Aug. 18, 2012, 4:51 p.m.
Message ID <1345308662-24023-1-git-send-email-shijie8@gmail.com>
Download mbox | patch
Permalink /patch/178424/
State New
Headers show

Comments

Huang Shijie - Aug. 18, 2012, 4:51 p.m.
When the partition truncating occurs, the old code misses the truncated
partition. So the partitions number is not right.

This patch fixes it. Alao add a `break` to shortcut the code in this
case.

Signed-off-by: Huang Shijie <shijie8@gmail.com>
---
 drivers/mtd/cmdlinepart.c |    3 ++-
 1 files changed, 2 insertions(+), 1 deletions(-)
Artem Bityutskiy - Aug. 24, 2012, 3:43 p.m.
On Sat, 2012-08-18 at 12:51 -0400, Huang Shijie wrote:
> diff --git a/drivers/mtd/cmdlinepart.c b/drivers/mtd/cmdlinepart.c
> index 4558e0f..fc960a3 100644
> --- a/drivers/mtd/cmdlinepart.c
> +++ b/drivers/mtd/cmdlinepart.c
> @@ -344,7 +344,8 @@ static int parse_cmdline_partitions(struct mtd_info *master,
>  					       "%s: partitioning exceeds flash size, truncating\n",
>  					       part->mtd_id);
>  					part->parts[i].size = master->size - offset;
> -					part->num_parts = i;
> +					part->num_parts = i + 1;
> +					break;
>  				}
>  				offset += part->parts[i].size;
>  			}

I do not understand this change. Could you explain some more which
problem you solve and how?
Huang Shijie - Aug. 24, 2012, 4:22 p.m.
On Fri, Aug 24, 2012 at 11:43 AM, Artem Bityutskiy <dedekind1@gmail.com> wrote:
> On Sat, 2012-08-18 at 12:51 -0400, Huang Shijie wrote:
>> diff --git a/drivers/mtd/cmdlinepart.c b/drivers/mtd/cmdlinepart.c
>> index 4558e0f..fc960a3 100644
>> --- a/drivers/mtd/cmdlinepart.c
>> +++ b/drivers/mtd/cmdlinepart.c
>> @@ -344,7 +344,8 @@ static int parse_cmdline_partitions(struct mtd_info *master,
>>                                              "%s: partitioning exceeds flash size, truncating\n",
>>                                              part->mtd_id);
>>                                       part->parts[i].size = master->size - offset;
>> -                                     part->num_parts = i;
>> +                                     part->num_parts = i + 1;
>> +                                     break;
>>                               }
>>                               offset += part->parts[i].size;
>>                       }
>
> I do not understand this change. Could you explain some more which
> problem you solve and how?
ok.

I will explain more in the next version as well as another patch.

thanks
Huang Shijie

>
> --
> Best Regards,
> Artem Bityutskiy

Patch

diff --git a/drivers/mtd/cmdlinepart.c b/drivers/mtd/cmdlinepart.c
index 4558e0f..fc960a3 100644
--- a/drivers/mtd/cmdlinepart.c
+++ b/drivers/mtd/cmdlinepart.c
@@ -344,7 +344,8 @@  static int parse_cmdline_partitions(struct mtd_info *master,
 					       "%s: partitioning exceeds flash size, truncating\n",
 					       part->mtd_id);
 					part->parts[i].size = master->size - offset;
-					part->num_parts = i;
+					part->num_parts = i + 1;
+					break;
 				}
 				offset += part->parts[i].size;
 			}