[lttng-dev] [PATCH lttng-tools] Fix: notification test: resources leak and return handling

Jonathan Rajotte jonathan.rajotte-julien at efficios.com
Fri Jun 2 18:52:30 UTC 2017


Fixes CID #1375913, 1375912, 1375911 1375910 1375909 1375908

Signed-off-by: Jonathan Rajotte <jonathan.rajotte-julien at efficios.com>
---
 tests/regression/tools/notification/base_client.c  | 25 ++++++++++++++++++----
 tests/regression/tools/notification/notification.c |  2 ++
 2 files changed, 23 insertions(+), 4 deletions(-)

diff --git a/tests/regression/tools/notification/base_client.c b/tests/regression/tools/notification/base_client.c
index 21a8ac3f..7fbaa9e4 100644
--- a/tests/regression/tools/notification/base_client.c
+++ b/tests/regression/tools/notification/base_client.c
@@ -297,7 +297,9 @@ end:
 	if (trigger) {
 		lttng_unregister_trigger(trigger);
 	}
-	lttng_notification_channel_unsubscribe(notification_channel, condition);
+	if (lttng_notification_channel_unsubscribe(notification_channel, condition)) {
+		printf("error: channel unsubscribe error\n");
+	}
 	lttng_trigger_destroy(trigger);
 	lttng_condition_destroy(condition);
 	lttng_action_destroy(action);
@@ -330,12 +332,27 @@ int handle_condition(
 	}
 
 	/* Fetch info to test */
-	lttng_condition_buffer_usage_get_session_name(condition,
+	ret = lttng_condition_buffer_usage_get_session_name(condition,
 			&condition_session_name);
-	lttng_condition_buffer_usage_get_channel_name(condition,
+	if (ret) {
+		printf("error: session name could not be fetched\n");
+		ret = 1;
+		goto end;
+	}
+	ret = lttng_condition_buffer_usage_get_channel_name(condition,
 			&condition_channel_name);
-	lttng_condition_buffer_usage_get_domain_type(condition,
+	if (ret) {
+		printf("error: channel name could not be fetched\n");
+		ret = 1;
+		goto end;
+	}
+	ret = lttng_condition_buffer_usage_get_domain_type(condition,
 			&condition_domain_type);
+	if (ret) {
+		printf("error: domain type could not be fetched\n");
+		ret = 1;
+		goto end;
+	}
 
 	if (strcmp(condition_session_name, session_name) != 0) {
 		printf("error: session name differs\n");
diff --git a/tests/regression/tools/notification/notification.c b/tests/regression/tools/notification/notification.c
index f69e884a..4a0c6dc9 100644
--- a/tests/regression/tools/notification/notification.c
+++ b/tests/regression/tools/notification/notification.c
@@ -68,6 +68,7 @@ int write_pipe(const char *path, uint8_t data)
 	ret = write(fd, &data , sizeof(data));
 	if (ret < 1) {
 		perror("Named pipe write failed");
+		ret = close(fd);
 		ret = -1;
 		goto end;
 	}
@@ -563,6 +564,7 @@ end:
 	lttng_trigger_destroy(trigger);
 	lttng_action_destroy(action);
 	lttng_condition_destroy(low_condition);
+	lttng_condition_destroy(high_condition);
 	lttng_condition_destroy(dummy_invalid_condition);
 	lttng_condition_destroy(dummy_condition);
 }
-- 
2.11.0



More information about the lttng-dev mailing list