Module: kamailio
Branch: 5.2
Commit: b2b8bc03d0658b0786a72e1e589b8b129ee7599e
URL:
https://github.com/kamailio/kamailio/commit/b2b8bc03d0658b0786a72e1e589b8b1…
Author: Victor Seva <linuxmaniac(a)torreviejawireless.org>
Committer: Victor Seva <linuxmaniac(a)torreviejawireless.org>
Date: 2018-11-14T10:58:17+01:00
kazoo: fix compilation warnings
kz_amqp.c:1884:5: warning: variable 'binding'
is used uninitialized whenever 'if' condition is true [-Wsometimes-uninitialized]
if(bind == NULL) {
^~~~~~~~~~~~
kz_amqp.c:1919:5: note: uninitialized use occurs here
if(binding != NULL)
^~~~~~~
kz_amqp.c:1884:2: note: remove the 'if' if its condition is always false
if(bind == NULL) {
^~~~~~~~~~~~~~~~~~
kz_amqp.c:1896:2: note: variable 'binding' is declared here
kz_amqp_binding_ptr binding = shm_malloc(sizeof(kz_amqp_binding));
^
kz_amqp.c:1965:5: warning: variable 'binding' is used uninitialized whenever
'if' condition is true [-Wsometimes-uninitialized]
if(bind == NULL) {
^~~~~~~~~~~~
kz_amqp.c:1992:8: note: uninitialized use occurs here
if(binding != NULL)
^~~~~~~
kz_amqp.c:1965:2: note: remove the 'if' if its condition is always false
if(bind == NULL) {
^~~~~~~~~~~~~~~~~~
kz_amqp.c:1972:2: note: variable 'binding' is declared here
kz_amqp_binding_ptr binding = shm_malloc(sizeof(kz_amqp_binding));
^
kz_amqp.c:2875:5: warning: variable 'json_obj' is used uninitialized whenever
'if' condition is true [-Wsometimes-uninitialized]
if(payload == NULL) {
^~~~~~~~~~~~~~~
kz_amqp.c:2927:5: note: uninitialized use occurs here
if(json_obj)
^~~~~~~~
kz_amqp.c:2875:2: note: remove the 'if' if its condition is always false
if(payload == NULL) {
^~~~~~~~~~~~~~~~~~~~~
kz_amqp.c:2880:2: note: variable 'json_obj' is declared here
json_obj_ptr json_obj = kz_json_parse(payload );
^
3 warnings generated.
(cherry picked from commit 232e8400caf7173e73229627af0270a704824f62)
---
Modified: src/modules/kazoo/kz_amqp.c
---
Diff:
https://github.com/kamailio/kamailio/commit/b2b8bc03d0658b0786a72e1e589b8b1…
Patch:
https://github.com/kamailio/kamailio/commit/b2b8bc03d0658b0786a72e1e589b8b1…
---
diff --git a/src/modules/kazoo/kz_amqp.c b/src/modules/kazoo/kz_amqp.c
index 36e7ea0843..00c8f3fb77 100644
--- a/src/modules/kazoo/kz_amqp.c
+++ b/src/modules/kazoo/kz_amqp.c
@@ -1802,10 +1802,10 @@ int kz_amqp_subscribe(struct sip_msg* msg, char* payload)
str* event_key = NULL;
str* event_subkey = NULL;
-
-
json_obj_ptr json_obj = NULL;
struct json_object* tmpObj = NULL;
+ kz_amqp_bind_ptr bind = NULL;
+ kz_amqp_binding_ptr binding = NULL;
if (fixup_get_svalue(msg, (gparam_p)payload, &payload_s) != 0) {
LM_ERR("cannot get payload value\n");
@@ -1880,7 +1880,7 @@ int kz_amqp_subscribe(struct sip_msg* msg, char* payload)
}
queue = kz_amqp_queue_from_json(&queue_s, tmpObj);
- kz_amqp_bind_ptr bind = kz_amqp_bind_alloc(exchange, exchange_binding, queue, routing,
event_key, event_subkey);
+ bind = kz_amqp_bind_alloc(exchange, exchange_binding, queue, routing, event_key,
event_subkey);
if(bind == NULL) {
LM_ERR("Could not allocate bind struct\n");
goto error;
@@ -1893,7 +1893,7 @@ int kz_amqp_subscribe(struct sip_msg* msg, char* payload)
bind->consistent_worker_key = consistent_worker_key;
- kz_amqp_binding_ptr binding = shm_malloc(sizeof(kz_amqp_binding));
+ binding = shm_malloc(sizeof(kz_amqp_binding));
if(binding == NULL) {
LM_ERR("Could not allocate binding struct\n");
goto error;
@@ -1935,7 +1935,8 @@ int kz_amqp_subscribe_simple(struct sip_msg* msg, char* exchange,
char* exchange
kz_amqp_exchange_ptr exchange_ptr = NULL;
kz_amqp_queue_ptr queue_ptr = NULL;
kz_amqp_routings_ptr routing_ptr = NULL;
-
+ kz_amqp_bind_ptr bind = NULL;
+ kz_amqp_binding_ptr binding = NULL;
if (fixup_get_svalue(msg, (gparam_p)exchange, &exchange_s) != 0) {
LM_ERR("cannot get exchange string value\n");
@@ -1961,7 +1962,7 @@ int kz_amqp_subscribe_simple(struct sip_msg* msg, char* exchange,
char* exchange
queue_ptr = kz_amqp_queue_new(&queue_s);
routing_ptr = kz_amqp_routing_new(routing_key_s.s);
- kz_amqp_bind_ptr bind = kz_amqp_bind_alloc(exchange_ptr, NULL, queue_ptr, routing_ptr,
NULL, NULL);
+ bind = kz_amqp_bind_alloc(exchange_ptr, NULL, queue_ptr, routing_ptr, NULL, NULL);
if(bind == NULL) {
LM_ERR("Could not allocate bind struct\n");
goto error;
@@ -1969,7 +1970,7 @@ int kz_amqp_subscribe_simple(struct sip_msg* msg, char* exchange,
char* exchange
bind->no_ack = 1;
- kz_amqp_binding_ptr binding = shm_malloc(sizeof(kz_amqp_binding));
+ binding = shm_malloc(sizeof(kz_amqp_binding));
if(binding == NULL) {
LM_ERR("Could not allocate binding struct\n");
goto error;
@@ -2870,6 +2871,7 @@ void kz_send_targeted_cmd(int server_id, amqp_bytes_t body)
char* server_id_str = NULL;
kz_amqp_cmd_ptr cmd = NULL;
json_object* JObj = NULL;
+ json_obj_ptr json_obj = NULL;
char* payload = kz_local_amqp_bytes_dup(body);
if(payload == NULL) {
@@ -2877,7 +2879,7 @@ void kz_send_targeted_cmd(int server_id, amqp_bytes_t body)
goto error;
}
- json_obj_ptr json_obj = kz_json_parse(payload );
+ json_obj = kz_json_parse(payload );
if (json_obj == NULL) {
LM_ERR("error parsing json payload\n");
goto error;