From 9a06e8d4d3891d5ddcafa6253236baff3b6ad518 Mon Sep 17 00:00:00 2001 From: =?utf8?q?J=C3=A9r=C3=A9mie=20Galarneau?= Date: Tue, 8 Mar 2016 10:03:55 -0500 Subject: [PATCH] Fix: use of unsigned variable to check for negative return MIME-Version: 1.0 Content-Type: text/plain; charset=utf8 Content-Transfer-Encoding: 8bit Reported by Coverity Scan, CID 1352682. Signed-off-by: Jérémie Galarneau --- src/common/ust-consumer/ust-consumer.c | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/src/common/ust-consumer/ust-consumer.c b/src/common/ust-consumer/ust-consumer.c index a17c48f2f..d0f7ac53e 100644 --- a/src/common/ust-consumer/ust-consumer.c +++ b/src/common/ust-consumer/ust-consumer.c @@ -1718,7 +1718,8 @@ int lttng_ustconsumer_recv_cmd(struct lttng_consumer_local_data *ctx, } case LTTNG_CONSUMER_LOST_PACKETS: { - uint64_t ret; + int ret; + uint64_t lost_packets; struct lttng_ht_iter iter; struct lttng_ht *ht; struct lttng_consumer_stream *stream; @@ -1738,13 +1739,13 @@ int lttng_ustconsumer_recv_cmd(struct lttng_consumer_local_data *ctx, * to extract the information we need, we default to 0 if not * found (no packets lost if the channel is not yet in use). */ - ret = 0; + lost_packets = 0; cds_lfht_for_each_entry_duplicate(ht->ht, ht->hash_fct(&id, lttng_ht_seed), ht->match_fct, &id, &iter.iter, stream, node_session_id.node) { if (stream->chan->key == key) { - ret = stream->chan->lost_packets; + lost_packets = stream->chan->lost_packets; break; } } @@ -1757,7 +1758,8 @@ int lttng_ustconsumer_recv_cmd(struct lttng_consumer_local_data *ctx, health_code_update(); /* Send back returned value to session daemon */ - ret = lttcomm_send_unix_sock(sock, &ret, sizeof(ret)); + ret = lttcomm_send_unix_sock(sock, &lost_packets, + sizeof(lost_packets)); if (ret < 0) { PERROR("send lost packets"); goto error_fatal; -- 2.34.1