diff mbox series

[1/4] Drop unused partitions list from main structure

Message ID 1516204847-24082-1-git-send-email-sbabic@denx.de
State Accepted
Headers show
Series [1/4] Drop unused partitions list from main structure | expand

Commit Message

Stefano Babic Jan. 17, 2018, 4 p.m. UTC
Partitions are just a special case of image in SWUpdate
and they are collected into the general image list.
Drop the partitions list because it is unused.

Signed-off-by: Stefano Babic <sbabic@denx.de>
---
 core/parser.c      | 2 --
 core/swupdate.c    | 1 -
 include/swupdate.h | 1 -
 parser/parser.c    | 1 -
 4 files changed, 5 deletions(-)

Comments

Stefan Herbrechtsmeier Jan. 17, 2018, 7:08 p.m. UTC | #1
Hi Stefano,

Am 17.01.2018 um 17:00 schrieb Stefano Babic:
> Read the type from sw-description and sets it to
> "ubipartition" just as default.
>
> Signed-off-by: Stefano Babic <sbabic@denx.de>
> ---
>   parser/parser.c | 9 +++++++--
>   1 file changed, 7 insertions(+), 2 deletions(-)
>
> diff --git a/parser/parser.c b/parser/parser.c
> index 0b190b8..66a0ba9 100644
> --- a/parser/parser.c
> +++ b/parser/parser.c
> @@ -301,9 +301,14 @@ static int parse_partitions(parsertype p, void *cfg, struct swupdate_cfg *swcfg)
>   			ERROR("No memory: malloc failed\n");
>   			return -ENOMEM;
>   		}
> +		if (parse_common_attributes(p, elem, partition) < 0) {
> +			free(partition);
> +			return -1;
> +		}
>   		GET_FIELD_STRING(p, elem, "name", partition->volname);

The parse_common_attributes function also sets the id.name to the name 
value. Maybe we should manually clear it.

> -		GET_FIELD_STRING(p, elem, "device", partition->device);
> -		strncpy(partition->type, "ubipartition", sizeof(partition->type));
> +
> +		if (!strlen(partition->type))
> +			strncpy(partition->type, "ubipartition", sizeof(partition->type));
>   		partition->is_partitioner = 1;
>   
>   		partition->provided = 1;

Best regards
   Stefan
Stefano Babic Jan. 17, 2018, 7:57 p.m. UTC | #2
Hi Stefan,

On 17/01/2018 20:08, Stefan Herbrechtsmeier wrote:
> Hi Stefano,
> 
> Am 17.01.2018 um 17:00 schrieb Stefano Babic:
>> Read the type from sw-description and sets it to
>> "ubipartition" just as default.
>>
>> Signed-off-by: Stefano Babic <sbabic@denx.de>
>> ---
>>   parser/parser.c | 9 +++++++--
>>   1 file changed, 7 insertions(+), 2 deletions(-)
>>
>> diff --git a/parser/parser.c b/parser/parser.c
>> index 0b190b8..66a0ba9 100644
>> --- a/parser/parser.c
>> +++ b/parser/parser.c
>> @@ -301,9 +301,14 @@ static int parse_partitions(parsertype p, void
>> *cfg, struct swupdate_cfg *swcfg)
>>               ERROR("No memory: malloc failed\n");
>>               return -ENOMEM;
>>           }
>> +        if (parse_common_attributes(p, elem, partition) < 0) {
>> +            free(partition);
>> +            return -1;
>> +        }
>>           GET_FIELD_STRING(p, elem, "name", partition->volname);
> 
> The parse_common_attributes function also sets the id.name to the name
> value. Maybe we should manually clear it.
> 

True, I have simply ignored because this is a partition and does not
have any version.


>> -        GET_FIELD_STRING(p, elem, "device", partition->device);
>> -        strncpy(partition->type, "ubipartition",
>> sizeof(partition->type));
>> +
>> +        if (!strlen(partition->type))
>> +            strncpy(partition->type, "ubipartition",
>> sizeof(partition->type));
>>           partition->is_partitioner = 1;
>>             partition->provided = 1;
> 

Best regards
Stefano
diff mbox series

Patch

diff --git a/core/parser.c b/core/parser.c
index 09f38bf..d6f73bd 100644
--- a/core/parser.c
+++ b/core/parser.c
@@ -132,8 +132,6 @@  int parse(struct swupdate_cfg *sw, const char *descfile)
 	ret = check_handler_list(&sw->scripts, SCRIPT_HANDLER, "scripts");
 	ret |= check_handler_list(&sw->images, IMAGE_HANDLER | FILE_HANDLER,
 					"images / files");
-	ret |= check_handler_list(&sw->partitions, PARTITION_HANDLER,
-					"partitions");
 	ret |= check_handler_list(&sw->bootscripts, BOOTLOADER_HANDLER,
 					"bootloader");
 	if (ret)
diff --git a/core/swupdate.c b/core/swupdate.c
index 62b0e35..430bb96 100644
--- a/core/swupdate.c
+++ b/core/swupdate.c
@@ -425,7 +425,6 @@  static void swupdate_init(struct swupdate_cfg *sw)
 	/* Initialize internal tree to store configuration */
 	memset(sw, 0, sizeof(*sw));
 	LIST_INIT(&sw->images);
-	LIST_INIT(&sw->partitions);
 	LIST_INIT(&sw->hardware);
 	LIST_INIT(&sw->scripts);
 	LIST_INIT(&sw->bootloader);
diff --git a/include/swupdate.h b/include/swupdate.h
index c88d638..db9abbf 100644
--- a/include/swupdate.h
+++ b/include/swupdate.h
@@ -120,7 +120,6 @@  struct swupdate_cfg {
 	struct hwlist hardware;
 	struct swver installed_sw_list;
 	struct imglist images;
-	struct imglist partitions;
 	struct imglist scripts;
 	struct imglist bootscripts;
 	struct dict bootloader;
diff --git a/parser/parser.c b/parser/parser.c
index f07559d..0f3eed3 100644
--- a/parser/parser.c
+++ b/parser/parser.c
@@ -629,7 +629,6 @@  static int parser(parsertype p, void *cfg, struct swupdate_cfg *swcfg)
 		lua_parser_exit(L);
 
 	if (LIST_EMPTY(&swcfg->images) &&
-	    LIST_EMPTY(&swcfg->partitions) &&
 	    LIST_EMPTY(&swcfg->scripts) &&
 	    LIST_EMPTY(&swcfg->bootloader)) {
 		ERROR("Found nothing to install\n");