ctf: assert that request_sz in medium ops request_bytes is greater than 0
authorSimon Marchi <simon.marchi@efficios.com>
Tue, 5 Nov 2019 22:21:47 +0000 (17:21 -0500)
committerJérémie Galarneau <jeremie.galarneau@efficios.com>
Fri, 15 Nov 2019 21:10:12 +0000 (16:10 -0500)
There's a check in medop_request_bytes to return OK if the passed
request_sz is 0.  I don't think that can ever happen, since that
request_sz comes from the max_request_sz parameter when the iterator is
created.  It wouldn't make sense to pass 0.

Change-Id: Ia2c8fb6e56195bcab607c39e366c6b58b3411f8b
Signed-off-by: Simon Marchi <simon.marchi@efficios.com>
src/plugins/ctf/common/msg-iter/msg-iter.c
src/plugins/ctf/fs-src/data-stream-file.c
src/plugins/ctf/lttng-live/data-stream.c

index 782a5a3435aeb32f7f623bc59aac9154d93984d3..9edc55c80b77b3c96264625c17d8a83c1c8be81e 100644 (file)
@@ -2837,6 +2837,8 @@ struct ctf_msg_iter *ctf_msg_iter_create(
        BT_ASSERT(tc);
        BT_ASSERT(medops.request_bytes);
        BT_ASSERT(medops.borrow_stream);
+       BT_ASSERT(max_request_sz > 0);
+
        BT_COMP_LOG_CUR_LVL(BT_LOG_DEBUG, log_level, self_comp,
                "Creating CTF plugin message iterator: "
                "trace-addr=%p, max-request-size=%zu, "
index 30da41a140fca4ee278dc5cfdd63f7d6f1c8b675..c4edcd32553104718c39d8c72fa05e8430450a8e 100644 (file)
@@ -143,9 +143,7 @@ enum ctf_msg_iter_medium_status medop_request_bytes(
        bt_self_component *self_comp = ds_file->self_comp;
        bt_logging_level log_level = ds_file->log_level;
 
-       if (request_sz == 0) {
-               goto end;
-       }
+       BT_ASSERT(request_sz > 0);
 
        /*
         * Check if we have at least one memory-mapped byte left. If we don't,
@@ -174,9 +172,12 @@ enum ctf_msg_iter_medium_status medop_request_bytes(
                }
        }
 
+       BT_ASSERT(remaining_mmap_bytes(ds_file) > 0);
        *buffer_sz = MIN(remaining_mmap_bytes(ds_file), request_sz);
+
        BT_ASSERT(ds_file->mmap_addr);
        *buffer_addr = ((uint8_t *) ds_file->mmap_addr) + ds_file->request_offset_in_mapping;
+
        ds_file->request_offset_in_mapping += *buffer_sz;
        goto end;
 
index 903cbf73d448da12f9d5959b14a0984e6c6a6cbf..3435628754de16d1810509181281247dd7700cb7 100644 (file)
@@ -58,6 +58,8 @@ enum ctf_msg_iter_medium_status medop_request_bytes(
        uint64_t len_left;
        uint64_t read_len;
 
+       BT_ASSERT(request_sz);
+
        if (stream->has_stream_hung_up) {
                status = CTF_MSG_ITER_MEDIUM_STATUS_EOF;
                goto end;
This page took 0.026989 seconds and 4 git commands to generate.