[lttng-dev] [PATCH lttng-tools 3/4] Fix: undefined operation on last_relay_viewer_session_id

Mathieu Desnoyers mathieu.desnoyers at efficios.com
Tue Dec 2 17:21:11 EST 2014


Triggers compiler warning on 32-bit build.

Signed-off-by: Mathieu Desnoyers <mathieu.desnoyers at efficios.com>
---
 src/bin/lttng-relayd/live.c | 7 ++++++-
 1 file changed, 6 insertions(+), 1 deletion(-)

diff --git a/src/bin/lttng-relayd/live.c b/src/bin/lttng-relayd/live.c
index 93d458b..a437d1d 100644
--- a/src/bin/lttng-relayd/live.c
+++ b/src/bin/lttng-relayd/live.c
@@ -731,7 +731,12 @@ int viewer_connect(struct relay_connection *conn)
 	reply.major = htobe32(reply.major);
 	reply.minor = htobe32(reply.minor);
 	if (conn->type == RELAY_VIEWER_COMMAND) {
-		reply.viewer_session_id = htobe64(++last_relay_viewer_session_id);
+		/*
+		 * Increment outside of htobe64 macro, because can be used more than once
+		 * within the macro, and thus the operation may be undefined.
+		 */
+		last_relay_viewer_session_id++;
+		reply.viewer_session_id = htobe64(last_relay_viewer_session_id);
 	}
 
 	health_code_update();
-- 
2.1.1




More information about the lttng-dev mailing list