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)
committerFrancis Deslauriers <francis.deslauriers@efficios.com>
Sat, 26 Oct 2019 13:42:52 +0000 (09:42 -0400)
commitf80e9ec14e8608e514891297246112606975b5f8
tree80bd1407b3df51dc7191bc17183b1b912321dba0
parent99b4b64b7ac398ab304fe7009d0a352b4002e459
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.026272 seconds and 4 git commands to generate.