Fix: Use negative value for error code of lttng_ust_ctl_duplicate_ust_object_data
authortakeshi.iwanari <takeshi.iwanari@tier4.jp>
Fri, 24 Jun 2022 13:17:39 +0000 (22:17 +0900)
committerMathieu Desnoyers <mathieu.desnoyers@efficios.com>
Mon, 27 Jun 2022 14:34:16 +0000 (10:34 -0400)
commit8449a229b6adf4ed87d34ef4d6f128e2177c3354
tree4c5ffc3b8f19e8d696778c0e0e6ce0b0d4b24a1d
parent8794c2dfa6542dbe99c8901ee553d1b43dcb7b77
Fix: Use negative value for error code of lttng_ust_ctl_duplicate_ust_object_data

[As is]
  - `lttng_ust_ctl_duplicate_ust_object_data` function is called by the following functions:
    - `event_notifier_error_accounting_register_app` (lttng-tools)
    - `duplicate_stream_object` (lttng-tools)
    - `duplicate_channel_object` (lttng-tools)
  - `lttng_ust_ctl_duplicate_ust_object_data` function returns positive value (= errno = 24 = EMFILE) when system call `dup` returns error
  - However, `duplicate_stream_object` and `duplicate_channel_object` functions expect negative value as error code
  - As a result, these functions cannot handle error and segmentation fault occurs when using `stream->handle`

[Proposal]
  - Currently, `lttng_ust_ctl_duplicate_ust_object_data` function returns either positive or negative value when error happens
  - It looks convention is using negative value for error code (e.g. `-ENOMEM` )
  - So, I propose to change `errno` to `-errno`

Signed-off-by: takeshi.iwanari <takeshi.iwanari@tier4.jp>
Signed-off-by: Mathieu Desnoyers <mathieu.desnoyers@efficios.com>
Change-Id: Iccb01930413ecd5a8c58ad267e9c4eca53694dc7
src/lib/lttng-ust-ctl/ustctl.c
This page took 0.02617 seconds and 4 git commands to generate.