You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@celix.apache.org by gr...@apache.org on 2017/03/08 10:37:24 UTC

celix git commit: Fixed new Coverity issues

Repository: celix
Updated Branches:
  refs/heads/develop 8cecba96f -> 9259626d4


Fixed new Coverity issues


Project: http://git-wip-us.apache.org/repos/asf/celix/repo
Commit: http://git-wip-us.apache.org/repos/asf/celix/commit/9259626d
Tree: http://git-wip-us.apache.org/repos/asf/celix/tree/9259626d
Diff: http://git-wip-us.apache.org/repos/asf/celix/diff/9259626d

Branch: refs/heads/develop
Commit: 9259626d4a53ad9d4f1e3e6a9a87eb1018a7b86f
Parents: 8cecba9
Author: gricciardi <gr...@apache.org>
Authored: Wed Mar 8 11:37:10 2017 +0100
Committer: gricciardi <gr...@apache.org>
Committed: Wed Mar 8 11:37:10 2017 +0100

----------------------------------------------------------------------
 etcdlib/private/src/etcd.c                            | 14 ++++++++------
 pubsub/pubsub_admin_udp_mc/private/src/large_udp.c    |  2 ++
 .../private/src/topic_publication.c                   |  4 +++-
 .../discovery/private/src/endpoint_discovery_poller.c | 10 ++++++----
 4 files changed, 19 insertions(+), 11 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/celix/blob/9259626d/etcdlib/private/src/etcd.c
----------------------------------------------------------------------
diff --git a/etcdlib/private/src/etcd.c b/etcdlib/private/src/etcd.c
index 97045ee..ff9f827 100644
--- a/etcdlib/private/src/etcd.c
+++ b/etcdlib/private/src/etcd.c
@@ -298,12 +298,14 @@ int etcd_set_with_check(const char* key, const char* value, int ttl, bool always
 	char *etcd_value;
 	int result = 0;
 	if (etcd_get(key, &etcd_value, NULL) == 0) {
-		if (strcmp(etcd_value, value) != 0) {
-			fprintf(stderr, "[ETCDLIB] WARNING: value already exists and is different\n");
-			fprintf(stderr, "   key       = %s\n", key);
-			fprintf(stderr, "   old value = %s\n", etcd_value);
-			fprintf(stderr, "   new value = %s\n", value);
-			result = -1;
+		if(etcd_value!=NULL){
+			if (strcmp(etcd_value, value) != 0) {
+				fprintf(stderr, "[ETCDLIB] WARNING: value already exists and is different\n");
+				fprintf(stderr, "   key       = %s\n", key);
+				fprintf(stderr, "   old value = %s\n", etcd_value);
+				fprintf(stderr, "   new value = %s\n", value);
+				result = -1;
+			}
 			free(etcd_value);
 		}
 	}

http://git-wip-us.apache.org/repos/asf/celix/blob/9259626d/pubsub/pubsub_admin_udp_mc/private/src/large_udp.c
----------------------------------------------------------------------
diff --git a/pubsub/pubsub_admin_udp_mc/private/src/large_udp.c b/pubsub/pubsub_admin_udp_mc/private/src/large_udp.c
index 8e838be..f9e167b 100644
--- a/pubsub/pubsub_admin_udp_mc/private/src/large_udp.c
+++ b/pubsub/pubsub_admin_udp_mc/private/src/large_udp.c
@@ -328,6 +328,8 @@ bool largeUdp_dataAvailable(largeUdp_pt handle, int fd, unsigned int *index, uns
 		msg.msg_iov[1].iov_base = &udpPartList->data[header.offset];
 		msg.msg_iov[1].iov_len = header.part_msg_size;
 		if(recvmsg(fd, &msg, 0)<0){
+			free(udpPartList->data);
+			free(udpPartList);
 			result=false;
 		}
 		else{

http://git-wip-us.apache.org/repos/asf/celix/blob/9259626d/pubsub/pubsub_admin_udp_mc/private/src/topic_publication.c
----------------------------------------------------------------------
diff --git a/pubsub/pubsub_admin_udp_mc/private/src/topic_publication.c b/pubsub/pubsub_admin_udp_mc/private/src/topic_publication.c
index ddda528..ce70385 100644
--- a/pubsub/pubsub_admin_udp_mc/private/src/topic_publication.c
+++ b/pubsub/pubsub_admin_udp_mc/private/src/topic_publication.c
@@ -246,7 +246,9 @@ static celix_status_t pubsub_topicPublicationGetService(void* handle, bundle_pt
 		bound->getCount++;
 	}
 
-	*service = bound->service;
+	if(bound!=NULL){
+		*service = bound->service;
+	}
 
 	celixThreadMutex_unlock(&(publish->tp_lock));
 

http://git-wip-us.apache.org/repos/asf/celix/blob/9259626d/remote_services/discovery/private/src/endpoint_discovery_poller.c
----------------------------------------------------------------------
diff --git a/remote_services/discovery/private/src/endpoint_discovery_poller.c b/remote_services/discovery/private/src/endpoint_discovery_poller.c
index b92e9f5..73fb7ba 100644
--- a/remote_services/discovery/private/src/endpoint_discovery_poller.c
+++ b/remote_services/discovery/private/src/endpoint_discovery_poller.c
@@ -247,8 +247,8 @@ celix_status_t endpointDiscoveryPoller_poll(endpoint_discovery_poller_pt poller,
 	arrayList_createWithEquals(endpointDiscoveryPoller_endpointDescriptionEquals, &updatedEndpoints);
 	status = endpointDiscoveryPoller_getEndpoints(poller, url, &updatedEndpoints);
 
-	if (status == CELIX_SUCCESS && updatedEndpoints!=NULL) {
-		if (updatedEndpoints) {
+	if (status == CELIX_SUCCESS) {
+		if (updatedEndpoints!=NULL) {
 			for (unsigned int i = arrayList_size(currentEndpoints); i > 0; i--) {
 				endpoint_description_pt endpoint = arrayList_get(currentEndpoints, i - 1);
 
@@ -270,11 +270,13 @@ celix_status_t endpointDiscoveryPoller_poll(endpoint_discovery_poller_pt poller,
 
 				}
 			}
-
-			arrayList_destroy(updatedEndpoints);
 		}
 	}
 
+	if(updatedEndpoints!=NULL){
+		arrayList_destroy(updatedEndpoints);
+	}
+
 	return status;
 }