From 821fffb2f13c9d5178df306f3c87edbeaf881a22 Mon Sep 17 00:00:00 2001 From: David Goulet Date: Wed, 19 Jun 2013 16:21:41 -0400 Subject: [PATCH] Fix: consumer add channel return value was positive on error Reported-by: Mathieu Desnoyers Signed-off-by: David Goulet --- src/common/consumer.c | 4 +++- src/common/kernel-consumer/kernel-consumer.c | 2 +- 2 files changed, 4 insertions(+), 2 deletions(-) diff --git a/src/common/consumer.c b/src/common/consumer.c index 6990dd967..96bc33726 100644 --- a/src/common/consumer.c +++ b/src/common/consumer.c @@ -890,6 +890,8 @@ end: /* * Add a channel to the global list protected by a mutex. + * + * On success 0 is returned else a negative value. */ int consumer_add_channel(struct lttng_consumer_channel *channel, struct lttng_consumer_local_data *ctx) @@ -907,7 +909,7 @@ int consumer_add_channel(struct lttng_consumer_channel *channel, /* Channel already exist. Ignore the insertion */ ERR("Consumer add channel key %" PRIu64 " already exists!", channel->key); - ret = LTTNG_ERR_KERN_CHAN_EXIST; + ret = -EEXIST; goto end; } diff --git a/src/common/kernel-consumer/kernel-consumer.c b/src/common/kernel-consumer/kernel-consumer.c index 39b635dc5..11830fc05 100644 --- a/src/common/kernel-consumer/kernel-consumer.c +++ b/src/common/kernel-consumer/kernel-consumer.c @@ -174,7 +174,7 @@ int lttng_kconsumer_recv_cmd(struct lttng_consumer_local_data *ctx, } /* If we received an error in add_channel, we need to report it. */ - if (ret != 0) { + if (ret < 0) { ret = consumer_send_status_msg(sock, ret); if (ret < 0) { goto error_fatal; -- 2.34.1