Fix: usage of `bt_value_array_get_length()`
authorFrancis Deslauriers <francis.deslauriers@efficios.com>
Thu, 24 Oct 2019 14:23:46 +0000 (10:23 -0400)
committerJérémie Galarneau <jeremie.galarneau@efficios.com>
Wed, 30 Oct 2019 19:14:53 +0000 (15:14 -0400)
commitb602018bfbd512fd2f8f41778f6560e9fb607bcb
tree2f7845aa99701c2fa17ff67702acb178e1e89c18
parent6e30bfdaa1314e2fca0a82d9bf39e6d55780e7fb
Fix: usage of `bt_value_array_get_length()`

Background
==========
Commit 601b0d3 changed the return value of the
`bt_value_array_get_size()` function now named
`bt_value_array_get_length()` from int64_t to uint64_t.

Problems
========
1. Multiple places in the code use the wrong storage type to store the
result of this function. Not only did we use `int64_t` but also, `int`,
`unsigned int` and `size_t` at some places.

2. A few places check for negative return value for handling potential
errors of this function. Because this function cannot fail and cannot
return a negative number, this is useless.

3. The babeltrace2.c file (`set_stream_intersections()` function)
contains two instances of checks against a negative value that would log
an error about the array being empty. Those log statements are
unreachable because the type is unsigned.

Solution
========
1. This commit cleanups so that we use `uint64_t` to store these value
and that we are using `uint64_t` for indexes looping on such value.

2. Remove useless error checks.

3. Those log statements are useful, so this commit corrects the
condition to compare against 0. But, this means that there is a change
in behaviour here. For example, before this commit, when doing the
stream intersection on an empty `bt_value_array` of traces the function would
return success and not log any error; now it fails and log an error.

Signed-off-by: Francis Deslauriers <francis.deslauriers@efficios.com>
Change-Id: I611bae82b4cb7092f13373283f358d8f7d13ae9d
Reviewed-on: https://review.lttng.org/c/babeltrace/+/2249
Tested-by: jenkins <jenkins@lttng.org>
src/cli/babeltrace2-cfg-cli-args-connect.c
src/cli/babeltrace2-cfg-cli-args.c
src/cli/babeltrace2-plugins.c
src/cli/babeltrace2.c
src/lib/lib-logging.c
src/lib/trace-ir/attributes.c
src/plugins/ctf/lttng-live/viewer-connection.c
This page took 0.025933 seconds and 4 git commands to generate.