src.ctf.lttng-live: use optional pattern for `ctf_stream_class_id`
authorFrancis Deslauriers <francis.deslauriers@efficios.com>
Wed, 10 Nov 2021 18:59:59 +0000 (13:59 -0500)
committerFrancis Deslauriers <francis.deslauriers@efficios.com>
Thu, 11 Nov 2021 22:47:54 +0000 (17:47 -0500)
Instead of checking for an initial boundary value to signify if the
value is initialized use a optional like anonymous struct with a
`is_set` flag.

Signed-off-by: Francis Deslauriers <francis.deslauriers@efficios.com>
Change-Id: I3045ef884345bea58824fd2170d29e982d219b7a
Reviewed-on: https://review.lttng.org/c/babeltrace/+/6699
Tested-by: jenkins <jenkins@lttng.org>
Reviewed-by: Philippe Proulx <eeppeliteloop@gmail.com>
src/plugins/ctf/lttng-live/data-stream.c
src/plugins/ctf/lttng-live/lttng-live.c
src/plugins/ctf/lttng-live/lttng-live.h
src/plugins/ctf/lttng-live/viewer-connection.c

index d7fdf34635cdc5bcbe6ce68889ca88bc131541f2..e8f00d7f561f34f25957f60a3d8b920a9340b465 100644 (file)
@@ -222,7 +222,10 @@ struct lttng_live_stream_iterator *lttng_live_stream_iterator_create(
        stream_iter->trace = trace;
        stream_iter->state = LTTNG_LIVE_STREAM_ACTIVE_NO_DATA;
        stream_iter->viewer_stream_id = stream_id;
-       stream_iter->ctf_stream_class_id = -1ULL;
+
+       stream_iter->ctf_stream_class_id.is_set = false;
+       stream_iter->ctf_stream_class_id.value = UINT64_MAX;
+
        stream_iter->last_inactivity_ts.is_set = false;
        stream_iter->last_inactivity_ts.value = 0;
 
index 65e079344a7ddb21c1edf50677c4ec58d2246f46..f091ae6e6335d282dfae1123be214f6708c84533 100644 (file)
@@ -671,7 +671,7 @@ enum lttng_live_iterator_status emit_inactivity_message(
 
        BT_COMP_LOGD("Emitting inactivity message for stream: ctf-stream-id=%" PRIu64
                ", viewer-stream-id=%" PRIu64 ", timestamp=%" PRIu64,
-               stream_iter->ctf_stream_class_id,
+               stream_iter->ctf_stream_class_id.value,
                stream_iter->viewer_stream_id, timestamp);
 
        msg = bt_message_message_iterator_inactivity_create(
index be235a7d4b04c633f086babe88833c369ee53060..d0d5b153385866683bbf9c8aad8d164858192fa5 100644 (file)
@@ -65,7 +65,10 @@ struct lttng_live_stream_iterator {
 
        uint64_t viewer_stream_id;
 
-       uint64_t ctf_stream_class_id;
+       struct {
+               bool is_set;
+               uint64_t value;
+       } ctf_stream_class_id;
 
        /* base offset in current index. */
        uint64_t base_offset;
index c4b29ed23e0cdc95d7af1e06f6c7a96e2ea23846..34bac35afa0fd7c24c3f32b2c3a8b78167d659c9 100644 (file)
@@ -1539,11 +1539,12 @@ enum lttng_live_iterator_status lttng_live_get_next_index(
                index->ts_cycles.timestamp_end = be64toh(rp.timestamp_end);
                stream->current_inactivity_ts = index->ts_cycles.timestamp_end;
                ctf_stream_class_id = be64toh(rp.stream_id);
-               if (stream->ctf_stream_class_id != -1ULL) {
-                       BT_ASSERT(stream->ctf_stream_class_id ==
+               if (stream->ctf_stream_class_id.is_set) {
+                       BT_ASSERT(stream->ctf_stream_class_id.value==
                                ctf_stream_class_id);
                } else {
-                       stream->ctf_stream_class_id = ctf_stream_class_id;
+                       stream->ctf_stream_class_id.value = ctf_stream_class_id;
+                       stream->ctf_stream_class_id.is_set = true;
                }
                lttng_live_stream_iterator_set_state(stream, LTTNG_LIVE_STREAM_QUIESCENT);
                status = LTTNG_LIVE_ITERATOR_STATUS_OK;
@@ -1555,11 +1556,12 @@ enum lttng_live_iterator_status lttng_live_get_next_index(
 
                lttng_index_to_packet_index(&rp, index);
                ctf_stream_class_id = be64toh(rp.stream_id);
-               if (stream->ctf_stream_class_id != -1ULL) {
-                       BT_ASSERT(stream->ctf_stream_class_id ==
+               if (stream->ctf_stream_class_id.is_set) {
+                       BT_ASSERT(stream->ctf_stream_class_id.value==
                                ctf_stream_class_id);
                } else {
-                       stream->ctf_stream_class_id = ctf_stream_class_id;
+                       stream->ctf_stream_class_id.value = ctf_stream_class_id;
+                       stream->ctf_stream_class_id.is_set = true;
                }
 
                lttng_live_stream_iterator_set_state(stream, LTTNG_LIVE_STREAM_ACTIVE_DATA);
This page took 0.036685 seconds and 4 git commands to generate.