diff mbox series

hawkbit: Fix clang's complaints

Message ID 20190201153842.28500-1-christian.storm@siemens.com
State Accepted
Headers show
Series hawkbit: Fix clang's complaints | expand

Commit Message

Storm, Christian Feb. 1, 2019, 3:38 p.m. UTC
Clang rightfully complains that the pointer variables
'json_reply_string' and 'url' may be used uninitialized.
Move their declaration upwards.

Clang also complains about an implicit conversion from
enumeration type 'server_op_res_t' to 'update_state_t'
in an assignment to 'server_hawkbit.update_state'. Fix
this by using the proper enumeration type.

Signed-off-by: Christian Storm <christian.storm@siemens.com>
---
 suricatta/server_hawkbit.c | 6 +++---
 1 file changed, 3 insertions(+), 3 deletions(-)

Comments

Stefano Babic Feb. 2, 2019, 5:18 p.m. UTC | #1
On 01/02/19 16:38, Christian Storm wrote:
> Clang rightfully complains that the pointer variables
> 'json_reply_string' and 'url' may be used uninitialized.
> Move their declaration upwards.
> 
> Clang also complains about an implicit conversion from
> enumeration type 'server_op_res_t' to 'update_state_t'
> in an assignment to 'server_hawkbit.update_state'. Fix
> this by using the proper enumeration type.
> 
> Signed-off-by: Christian Storm <christian.storm@siemens.com>
> ---
>  suricatta/server_hawkbit.c | 6 +++---
>  1 file changed, 3 insertions(+), 3 deletions(-)
> 
> diff --git a/suricatta/server_hawkbit.c b/suricatta/server_hawkbit.c
> index d02ab61..53801e1 100644
> --- a/suricatta/server_hawkbit.c
> +++ b/suricatta/server_hawkbit.c
> @@ -1320,6 +1320,8 @@ server_op_res_t server_send_target_data(void)
>  	bool first = true;
>  	int len = 0;
>  	server_op_res_t result = SERVER_OK;
> +	char *json_reply_string = NULL;
> +	char *url = NULL;
>  
>  	assert(channel != NULL);
>  	len = get_target_data_length();
> @@ -1376,8 +1378,6 @@ server_op_res_t server_send_target_data(void)
>  	}
>  	);
>  
> -	char *url = NULL;
> -	char *json_reply_string = NULL;
>  	channel_data_t channel_data_reply = channel_data_defaults;
>  	char fdate[15 + 1];
>  	time_t now = time(NULL) == (time_t)-1 ? 0 : time(NULL);
> @@ -1789,7 +1789,7 @@ static server_op_res_t server_activation_ipc(ipc_message *msg)
>  	if ((response != SERVER_UPDATE_AVAILABLE) && (response != SERVER_OK))
>  		result = SERVER_EERR;
>  	else {
> -		server_hawkbit.update_state = SERVER_OK;
> +		server_hawkbit.update_state = STATE_OK;
>  
>  		/*
>  		 * Save the state
> 

Acked-by: Stefano Babic <sbabic@denx.de>

Best regards,
Stefano Babic
diff mbox series

Patch

diff --git a/suricatta/server_hawkbit.c b/suricatta/server_hawkbit.c
index d02ab61..53801e1 100644
--- a/suricatta/server_hawkbit.c
+++ b/suricatta/server_hawkbit.c
@@ -1320,6 +1320,8 @@  server_op_res_t server_send_target_data(void)
 	bool first = true;
 	int len = 0;
 	server_op_res_t result = SERVER_OK;
+	char *json_reply_string = NULL;
+	char *url = NULL;
 
 	assert(channel != NULL);
 	len = get_target_data_length();
@@ -1376,8 +1378,6 @@  server_op_res_t server_send_target_data(void)
 	}
 	);
 
-	char *url = NULL;
-	char *json_reply_string = NULL;
 	channel_data_t channel_data_reply = channel_data_defaults;
 	char fdate[15 + 1];
 	time_t now = time(NULL) == (time_t)-1 ? 0 : time(NULL);
@@ -1789,7 +1789,7 @@  static server_op_res_t server_activation_ipc(ipc_message *msg)
 	if ((response != SERVER_UPDATE_AVAILABLE) && (response != SERVER_OK))
 		result = SERVER_EERR;
 	else {
-		server_hawkbit.update_state = SERVER_OK;
+		server_hawkbit.update_state = STATE_OK;
 
 		/*
 		 * Save the state