diff mbox series

[v1] core/stream_interface.c: increment progress step

Message ID 20220518151902.1045269-1-viraj.shah@linutronix.de
State Accepted
Headers show
Series [v1] core/stream_interface.c: increment progress step | expand

Commit Message

Viraj Shah May 18, 2022, 3:19 p.m. UTC
Increment the progress step before sending swupdate_progress_end.
On success, this will be needed by swupdate-progress tool to check if
reboot can be done on a successful update.

Currently swupdate_progress_inc_step is only implemented while
installing image from install_single_image. But if image is not specified
in sw-description, and update is done via suricatta or webserver, the progress
step cur_step is never incremented.

If the image is not mentioned in the description file, it makes sense to
send empty string for image handler name and image handler descriptor
to swupdate_progress_inc_step. For the other case, if image is
mentioned, it will hit install_single_image and do the increment of
cur_step in the conventional way.

Signed-off-by: Viraj Shah <viraj.shah@linutronix.de>
---
 core/stream_interface.c | 1 +
 1 file changed, 1 insertion(+)

Comments

Stefano Babic May 18, 2022, 7:42 p.m. UTC | #1
On 18.05.22 17:19, Viraj Shah wrote:
> Increment the progress step before sending swupdate_progress_end.
> On success, this will be needed by swupdate-progress tool to check if
> reboot can be done on a successful update.
> 
> Currently swupdate_progress_inc_step is only implemented while
> installing image from install_single_image. But if image is not specified
> in sw-description, and update is done via suricatta or webserver, the progress
> step cur_step is never incremented.
> 
> If the image is not mentioned in the description file, it makes sense to
> send empty string for image handler name and image handler descriptor
> to swupdate_progress_inc_step. For the other case, if image is
> mentioned, it will hit install_single_image and do the increment of
> cur_step in the conventional way.
> 
> Signed-off-by: Viraj Shah <viraj.shah@linutronix.de>
> ---
>   core/stream_interface.c | 1 +
>   1 file changed, 1 insertion(+)
> 
> diff --git a/core/stream_interface.c b/core/stream_interface.c
> index 57a3192..d8d3934 100644
> --- a/core/stream_interface.c
> +++ b/core/stream_interface.c
> @@ -649,6 +649,7 @@ void *network_initializer(void *data)
>   			notify(FAILURE, RECOVERY_ERROR, ERRORLEVEL, "Image invalid or corrupted. Not installing ...");
>   		}
>   
> +		swupdate_progress_inc_step("", "");

This cause a warning, at least should be casted:

core/stream_interface.c:652:34: warning: passing argument 2 of 
'swupdate_progress_inc_step' discards 'const' qualifier from pointer 
target type [-Wdiscarded-qualifiers]

   652 |   swupdate_progress_inc_step("", "");

       |                                  ^~

In file included from core/stream_interface.c:44:

include/progress.h:21:52: note: expected 'char *' but argument is of 
type 'const char *'

    21 | void swupdate_progress_inc_step(char *image, char *handler_name);


Best regards,
Stefano Babic

>   		swupdate_progress_end(inst.last_install);
>   
>   		/*
Viraj Shah May 19, 2022, 10:37 a.m. UTC | #2
On 5/18/22 21:42, Stefano Babic wrote:
>
>
> On 18.05.22 17:19, Viraj Shah wrote:
>> Increment the progress step before sending swupdate_progress_end.
>> On success, this will be needed by swupdate-progress tool to check if
>> reboot can be done on a successful update.
>>
>> Currently swupdate_progress_inc_step is only implemented while
>> installing image from install_single_image. But if image is not
>> specified
>> in sw-description, and update is done via suricatta or webserver, the
>> progress
>> step cur_step is never incremented.
>>
>> If the image is not mentioned in the description file, it makes sense to
>> send empty string for image handler name and image handler descriptor
>> to swupdate_progress_inc_step. For the other case, if image is
>> mentioned, it will hit install_single_image and do the increment of
>> cur_step in the conventional way.
>>
>> Signed-off-by: Viraj Shah <viraj.shah@linutronix.de>
>> ---
>>   core/stream_interface.c | 1 +
>>   1 file changed, 1 insertion(+)
>>
>> diff --git a/core/stream_interface.c b/core/stream_interface.c
>> index 57a3192..d8d3934 100644
>> --- a/core/stream_interface.c
>> +++ b/core/stream_interface.c
>> @@ -649,6 +649,7 @@ void *network_initializer(void *data)
>>               notify(FAILURE, RECOVERY_ERROR, ERRORLEVEL, "Image
>> invalid or corrupted. Not installing ...");
>>           }
>>   +        swupdate_progress_inc_step("", "");
>
> This cause a warning, at least should be casted:
>
> core/stream_interface.c:652:34: warning: passing argument 2 of
> 'swupdate_progress_inc_step' discards 'const' qualifier from pointer
> target type [-Wdiscarded-qualifiers]
>
>   652 |   swupdate_progress_inc_step("", "");
>
>       |                                  ^~
>
> In file included from core/stream_interface.c:44:
>
> include/progress.h:21:52: note: expected 'char *' but argument is of
> type 'const char *'
>
>    21 | void swupdate_progress_inc_step(char *image, char *handler_name);
This function should have const char * for its arguments, since it is
not modifying them only strlcpy's them.
I will send a patch.
>
>
>
> Best regards,
> Stefano Babic
>
>>           swupdate_progress_end(inst.last_install);
>>             /*
Stefano Babic May 19, 2022, 10:39 a.m. UTC | #3
On 19.05.22 12:37, viraj wrote:
> 
> 
> On 5/18/22 21:42, Stefano Babic wrote:
>>
>>
>> On 18.05.22 17:19, Viraj Shah wrote:
>>> Increment the progress step before sending swupdate_progress_end.
>>> On success, this will be needed by swupdate-progress tool to check if
>>> reboot can be done on a successful update.
>>>
>>> Currently swupdate_progress_inc_step is only implemented while
>>> installing image from install_single_image. But if image is not
>>> specified
>>> in sw-description, and update is done via suricatta or webserver, the
>>> progress
>>> step cur_step is never incremented.
>>>
>>> If the image is not mentioned in the description file, it makes sense to
>>> send empty string for image handler name and image handler descriptor
>>> to swupdate_progress_inc_step. For the other case, if image is
>>> mentioned, it will hit install_single_image and do the increment of
>>> cur_step in the conventional way.
>>>
>>> Signed-off-by: Viraj Shah <viraj.shah@linutronix.de>
>>> ---
>>>    core/stream_interface.c | 1 +
>>>    1 file changed, 1 insertion(+)
>>>
>>> diff --git a/core/stream_interface.c b/core/stream_interface.c
>>> index 57a3192..d8d3934 100644
>>> --- a/core/stream_interface.c
>>> +++ b/core/stream_interface.c
>>> @@ -649,6 +649,7 @@ void *network_initializer(void *data)
>>>                notify(FAILURE, RECOVERY_ERROR, ERRORLEVEL, "Image
>>> invalid or corrupted. Not installing ...");
>>>            }
>>>    +        swupdate_progress_inc_step("", "");
>>
>> This cause a warning, at least should be casted:
>>
>> core/stream_interface.c:652:34: warning: passing argument 2 of
>> 'swupdate_progress_inc_step' discards 'const' qualifier from pointer
>> target type [-Wdiscarded-qualifiers]
>>
>>    652 |   swupdate_progress_inc_step("", "");
>>
>>        |                                  ^~
>>
>> In file included from core/stream_interface.c:44:
>>
>> include/progress.h:21:52: note: expected 'char *' but argument is of
>> type 'const char *'
>>
>>     21 | void swupdate_progress_inc_step(char *image, char *handler_name);
> This function should have const char * for its arguments, since it is
> not modifying them only strlcpy's them.

Exactly.

> I will send a patch.

Thanks.

Best regards,
Stefano Babic

>>
>>
>>
>> Best regards,
>> Stefano Babic
>>
>>>            swupdate_progress_end(inst.last_install);
>>>              /*
>
Stefano Babic May 23, 2022, 7:36 p.m. UTC | #4
On 18.05.22 17:19, Viraj Shah wrote:
> Increment the progress step before sending swupdate_progress_end.
> On success, this will be needed by swupdate-progress tool to check if
> reboot can be done on a successful update.
> 
> Currently swupdate_progress_inc_step is only implemented while
> installing image from install_single_image. But if image is not specified
> in sw-description, and update is done via suricatta or webserver, the progress
> step cur_step is never incremented.
> 
> If the image is not mentioned in the description file, it makes sense to
> send empty string for image handler name and image handler descriptor
> to swupdate_progress_inc_step. For the other case, if image is
> mentioned, it will hit install_single_image and do the increment of
> cur_step in the conventional way.
> 
> Signed-off-by: Viraj Shah <viraj.shah@linutronix.de>
> ---
>   core/stream_interface.c | 1 +
>   1 file changed, 1 insertion(+)
> 
> diff --git a/core/stream_interface.c b/core/stream_interface.c
> index 57a3192..d8d3934 100644
> --- a/core/stream_interface.c
> +++ b/core/stream_interface.c
> @@ -649,6 +649,7 @@ void *network_initializer(void *data)
>   			notify(FAILURE, RECOVERY_ERROR, ERRORLEVEL, "Image invalid or corrupted. Not installing ...");
>   		}
>   
> +		swupdate_progress_inc_step("", "");
>   		swupdate_progress_end(inst.last_install);
>   
>   		/*

Applied to -master, thanks !

Best regards,
Stefano Babic
diff mbox series

Patch

diff --git a/core/stream_interface.c b/core/stream_interface.c
index 57a3192..d8d3934 100644
--- a/core/stream_interface.c
+++ b/core/stream_interface.c
@@ -649,6 +649,7 @@  void *network_initializer(void *data)
 			notify(FAILURE, RECOVERY_ERROR, ERRORLEVEL, "Image invalid or corrupted. Not installing ...");
 		}
 
+		swupdate_progress_inc_step("", "");
 		swupdate_progress_end(inst.last_install);
 
 		/*