Hello,

Add missing return value checks to pthread operations.
Detected by clang 3.8 -O2 -Wunused-value.

Replace strcmp(var, "") with strlen(var) to workaround Clang bug 20144.
https://llvm.org/bugs/show_bug.cgi?id=20144

-- 
Petr^2 Spacek
From ccfcc54d15eee928ac9005f902bc5c79da8360e5 Mon Sep 17 00:00:00 2001
From: Petr Spacek <pspa...@redhat.com>
Date: Tue, 1 Mar 2016 13:37:59 +0100
Subject: [PATCH] Replace strcmp(var, "") with strlen(var) to workaround Clang
 bug 20144.

https://llvm.org/bugs/show_bug.cgi?id=20144
---
 src/fs.c          | 2 +-
 src/ldap_helper.c | 2 +-
 2 files changed, 2 insertions(+), 2 deletions(-)

diff --git a/src/fs.c b/src/fs.c
index 7cbee986ccb00bb1bb63be4d734cde06ca77ce4a..09b71d70ea4f15bc5122df1960933f47f0d44eda 100644
--- a/src/fs.c
+++ b/src/fs.c
@@ -85,7 +85,7 @@ fs_dirs_create(const char *path) {
 	     end != NULL;
 	     end = strchr(end + 1, '/')) {
 		*end = '\0';
-		if (strcmp(curr_path, "") != 0)
+		if (strlen(curr_path) > 0)
 			/* Absolute paths would have first component empty. */
 			CHECK(fs_dir_create(curr_path));
 		*end = '/';
diff --git a/src/ldap_helper.c b/src/ldap_helper.c
index 415786d31776d8780f44e75f48674c47a2f61b21..7c50348beef421571e52cf03243e70aa55c0cc88 100644
--- a/src/ldap_helper.c
+++ b/src/ldap_helper.c
@@ -366,7 +366,7 @@ validate_local_instance_settings(ldap_instance_t *inst, settings_set_t *set) {
 	/* Use instance name as default working directory */
 	CHECK(str_new(inst->mctx, &buff));
 	CHECK(setting_get_str("directory", inst->local_settings, &dir_name));
-	dir_default = (strcmp(dir_name, "") == 0);
+	dir_default = (strlen(dir_name) == 0);
 	if (dir_default == ISC_TRUE) {
 		CHECK(str_cat_char(buff, "dyndb-ldap/"));
 		CHECK(str_cat_char(buff, inst->db_name));
-- 
2.5.0

From e8e0f3d814820972e21a11e2961467f4b770ea20 Mon Sep 17 00:00:00 2001
From: Petr Spacek <pspa...@redhat.com>
Date: Tue, 1 Mar 2016 14:32:45 +0100
Subject: [PATCH] Add missing return value checks to pthread operations.

Detected by clang 3.8 -O2 -Wunused-value.
---
 src/semaphore.c    |  2 +-
 src/settings.c     |  2 +-
 src/syncrepl.c     | 13 +++++++------
 src/zone_manager.c | 10 ++++++----
 4 files changed, 15 insertions(+), 12 deletions(-)

diff --git a/src/semaphore.c b/src/semaphore.c
index 9a502f11e07dc5c4e07549b923cfd05028251493..d86019db42beee6aededfd6a2a01aaa86d7981d9 100644
--- a/src/semaphore.c
+++ b/src/semaphore.c
@@ -46,7 +46,7 @@ semaphore_init(semaphore_t *sem, int value)
 
 	result = isc_condition_init(&sem->cond);
 	if (result != ISC_R_SUCCESS)
-		isc_mutex_destroy(&sem->mutex);
+		DESTROYLOCK(&sem->mutex);
 
 	return result;
 }
diff --git a/src/settings.c b/src/settings.c
index 0f516861f7bef8626cfc90e7e4cabde0ab915cdb..5755f83c4c92125b19af00dd724d9927c4bdc89c 100644
--- a/src/settings.c
+++ b/src/settings.c
@@ -532,7 +532,7 @@ settings_set_free(settings_set_t **set) {
 		mctx = (*set)->mctx;
 
 		if ((*set)->lock != NULL) {
-			isc_mutex_destroy((*set)->lock);
+			DESTROYLOCK((*set)->lock);
 			SAFE_MEM_PUT_PTR(mctx, (*set)->lock);
 		}
 
diff --git a/src/syncrepl.c b/src/syncrepl.c
index 94e161997a5eaf19cc71816cfe8fc0fee17d31f4..5ee1eb1aeb75ac4dbece9d429dca117465bef782 100644
--- a/src/syncrepl.c
+++ b/src/syncrepl.c
@@ -120,7 +120,7 @@ finish(isc_task_t *task, isc_event_t *event) {
 	log_debug(1, "sync_barrier_wait(): finish reached");
 	LOCK(&bev->sctx->mutex);
 	sync_state_change(bev->sctx, sync_finished, ISC_FALSE);
-	isc_condition_broadcast(&bev->sctx->cond);
+	BROADCAST(&bev->sctx->cond);
 	UNLOCK(&bev->sctx->mutex);
 	activate_zones(task, inst);
 
@@ -274,9 +274,10 @@ sync_ctx_init(isc_mem_t *mctx, ldap_instance_t *inst, sync_ctx_t **sctxp) {
 
 cleanup:
 	if (lock_ready == ISC_TRUE)
-		isc_mutex_destroy(&sctx->mutex);
+		DESTROYLOCK(&sctx->mutex);
 	if (cond_ready == ISC_TRUE)
-		isc_condition_init(&sctx->cond);
+		RUNTIME_CHECK(isc_condition_destroy(&sctx->cond)
+			      == ISC_R_SUCCESS);
 	if (refcount_ready == ISC_TRUE)
 		isc_refcount_destroy(&sctx->task_cnt);
 	MEM_PUT_AND_DETACH(sctx);
@@ -308,11 +309,11 @@ sync_ctx_free(sync_ctx_t **sctxp) {
 		isc_refcount_decrement(&sctx->task_cnt, NULL);
 		SAFE_MEM_PUT_PTR(sctx->mctx, taskel);
 	}
-	isc_condition_destroy(&sctx->cond);
+	RUNTIME_CHECK(isc_condition_destroy(&sctx->cond) == ISC_R_SUCCESS);
 	isc_refcount_destroy(&sctx->task_cnt);
 	UNLOCK(&sctx->mutex);
 
-	isc_mutex_destroy(&(*sctxp)->mutex);
+	DESTROYLOCK(&(*sctxp)->mutex);
 	MEM_PUT_AND_DETACH(*sctxp);
 }
 
@@ -438,7 +439,7 @@ sync_barrier_wait(sync_ctx_t *sctx, const char *inst_name) {
 
 	log_debug(1, "sync_barrier_wait(): wait until all events are processed");
 	while (sctx->state != sync_finished)
-		isc_condition_wait(&sctx->cond, &sctx->mutex);
+		WAIT(&sctx->cond, &sctx->mutex);
 	log_debug(1, "sync_barrier_wait(): all events were processed");
 
 cleanup:
diff --git a/src/zone_manager.c b/src/zone_manager.c
index 6f7c57dd05dcbfdffa6b823399bb5b0bd4a33129..93e3fe5675713876d02ce52d036aa2f8a90e288e 100644
--- a/src/zone_manager.c
+++ b/src/zone_manager.c
@@ -58,7 +58,8 @@ destroy_manager(void)
 	db_instance_t *db_inst;
 	db_instance_t *next;
 
-	isc_once_do(&initialize_once, initialize_manager);
+	RUNTIME_CHECK(isc_once_do(&initialize_once, initialize_manager)
+		      == ISC_R_SUCCESS);
 
 	LOCK(&instance_list_lock);
 	db_inst = HEAD(instance_list);
@@ -105,7 +106,8 @@ manager_create_db_instance(isc_mem_t *mctx, const char *name,
 	REQUIRE(name != NULL);
 	REQUIRE(dyndb_args != NULL);
 
-	isc_once_do(&initialize_once, initialize_manager);
+	RUNTIME_CHECK(isc_once_do(&initialize_once, initialize_manager)
+		      == ISC_R_SUCCESS);
 
 	result = find_db_instance(name, &db_inst);
 	if (result == ISC_R_SUCCESS) {
@@ -149,8 +151,8 @@ manager_get_ldap_instance(const char *name, ldap_instance_t **ldap_inst)
 	REQUIRE(name != NULL);
 	REQUIRE(ldap_inst != NULL);
 
-	isc_once_do(&initialize_once, initialize_manager);
-
+	RUNTIME_CHECK(isc_once_do(&initialize_once, initialize_manager)
+		      == ISC_R_SUCCESS);
 	db_inst = NULL;
 	CHECK(find_db_instance(name, &db_inst));
 
-- 
2.5.0

-- 
Manage your subscription for the Freeipa-devel mailing list:
https://www.redhat.com/mailman/listinfo/freeipa-devel
Contribute to FreeIPA: http://www.freeipa.org/page/Contribute/Code

Reply via email to