Browse code

kazoo: fix build warning

> Warning: kz_amqp.c:2271:6: warning: variable 'num_headers' is used uninitialized whenever 'if' condition is true [-Wsometimes-uninitialized]
> if(idx == -1) {
> ^~~~~~~~~
> kz_amqp.c:2327:6: note: uninitialized use occurs here
> if (num_headers > 0) {
> ^~~~~~~~~~~
> kz_amqp.c:2271:3: note: remove the 'if' if its condition is always false
> if(idx == -1) {
> ^~~~~~~~~~~~~~~
> kz_amqp.c:2281:5: note: variable 'num_headers' is declared here
> int num_headers = 0;
> ^
> 1 warning generated.

Victor Seva authored on 01/07/2022 13:10:55
Showing 1 changed files
... ...
@@ -2259,7 +2259,8 @@ int kz_amqp_send_ex(kz_amqp_server_ptr srv, kz_amqp_cmd_ptr cmd, kz_amqp_channel
2259 2259
 	amqp_bytes_t routing_key = {0,0};
2260 2260
 	amqp_bytes_t payload = {0,0};
2261 2261
 	int ret = -1;
2262
-    json_obj_ptr json_obj = NULL;
2262
+	json_obj_ptr json_obj = NULL;
2263
+	int num_headers = 0;
2263 2264
 
2264 2265
 	amqp_basic_properties_t props;
2265 2266
 	memset(&props, 0, sizeof(amqp_basic_properties_t));
... ...
@@ -2278,7 +2279,6 @@ int kz_amqp_send_ex(kz_amqp_server_ptr srv, kz_amqp_cmd_ptr cmd, kz_amqp_channel
2278 2279
     routing_key = amqp_bytes_malloc_dup(amqp_cstring_bytes(cmd->routing_key));
2279 2280
     payload = amqp_bytes_malloc_dup(amqp_cstring_bytes(cmd->payload));
2280 2281
 
2281
-    int num_headers = 0;
2282 2282
     if ( (cmd->headers != NULL) &&  (strlen (cmd->headers) > 0 ) ) {
2283 2283
         num_headers = add_amqp_headers(cmd->headers, &props);
2284 2284
     }