HeaderFilterRegex: '.*((include/.*-internal)|(src/common.*)|(src/bin.*)|(src/lib.*)|(tests.*))\.(h|hpp)$'
-Checks: '-*,modernize-use-using'
+Checks: '-*,
+ bugprone-argument-comment,
+ bugprone-assert-side-effect,
+ bugprone-dangling-handle,
+ bugprone-inaccurate-erase,
+ bugprone-string-constructor,
+ bugprone-string-integer-assignment,
+ bugprone-undefined-memory-manipulation,
+ bugprone-unused-raii,
+ bugprone-use-after-move,
+ google-build-explicit-make-pair,
+ google-explicit-constructor,
+ modernize-avoid-bind,
+ modernize-concat-nested-namespaces,
+ modernize-loop-convert,
+ modernize-make-shared,
+ modernize-make-unique,
+ modernize-redundant-void-arg,
+ modernize-replace-random-shuffle,
+ modernize-shrink-to-fit,
+ modernize-use-bool-literals,
+ modernize-use-default-member-init,
+ modernize-use-emplace,
+ modernize-use-equals-default,
+ modernize-use-equals-delete,
+ modernize-use-noexcept,
+ modernize-use-nullptr,
+ modernize-use-override,
+ modernize-use-transparent-functors,
+ modernize-use-using,
+ performance-*,
+ -performance-no-int-to-ptr,
+ readability-redundant-member-init'
FormatStyle: 'file'
+CheckOptions:
+ - key: bugprone-assert-side-effect.AssertMacros
+ value: assert,LTTNG_ASSERT
\ No newline at end of file
enum lttng_event_expr_status status;
parent_expr = lttng_event_expr_array_field_element_get_parent_expr(event_expr);
- LTTNG_ASSERT(parent_expr != NULL);
+ LTTNG_ASSERT(parent_expr != nullptr);
print_one_event_expr(parent_expr);
uint64_t u_val;
int64_t s_val;
double d_val;
- const char *string_val = NULL;
+ const char *string_val = nullptr;
switch (lttng_event_field_value_get_type(capture)) {
case LTTNG_EVENT_FIELD_VALUE_TYPE_UNSIGNED_INT:
return ret;
}
-static void print_unavailabe(void)
+static void print_unavailabe()
{
printf("Capture unavailable");
}
}
for (unsigned int i = 0; i < captured_field_count; i++) {
- const struct lttng_event_field_value *captured_field = NULL;
+ const struct lttng_event_field_value *captured_field = nullptr;
const struct lttng_event_expr *expr =
lttng_condition_event_rule_matches_get_capture_descriptor_at_index(
condition, i);
enum lttng_condition_status condition_status;
enum lttng_evaluation_event_rule_matches_status evaluation_status;
- const struct lttng_event_field_value *captured_field_array = NULL;
+ const struct lttng_event_field_value *captured_field_array = nullptr;
unsigned int expected_capture_field_count;
LTTNG_ASSERT(lttng_evaluation_get_type(evaluation) ==
char time_str[64];
struct timeval tv;
time_t the_time;
- const struct lttng_trigger *trigger = NULL;
+ const struct lttng_trigger *trigger = nullptr;
- gettimeofday(&tv, NULL);
+ gettimeofday(&tv, nullptr);
the_time = tv.tv_sec;
strftime(time_str, sizeof(time_str), "[%m-%d-%Y] %T", localtime(&the_time));
int main(int argc, char **argv)
{
int ret;
- struct lttng_triggers *triggers = NULL;
+ struct lttng_triggers *triggers = nullptr;
unsigned int count, i, j, subcription_count = 0, trigger_count;
enum lttng_trigger_status trigger_status;
- struct lttng_notification_channel *notification_channel = NULL;
+ struct lttng_notification_channel *notification_channel = nullptr;
if (argc < 2) {
fprintf(stderr, "Missing trigger name(s)\n");
const struct lttng_action *action = lttng_trigger_get_const_action(trigger);
const enum lttng_action_type action_type = lttng_action_get_type(action);
enum lttng_notification_channel_status channel_status;
- const char *trigger_name = NULL;
+ const char *trigger_name = nullptr;
bool subscribe = false;
lttng_trigger_get_name(trigger, &trigger_name);
int64_t blocking_timeout;
} LTTNG_PACKED;
-struct lttng_channel *lttng_channel_create_internal(void);
+struct lttng_channel *lttng_channel_create_internal();
struct lttng_channel *lttng_channel_copy(const struct lttng_channel *src);
void lttng_error_query_result_destroy(struct lttng_error_query_result *result);
-struct lttng_error_query_results *lttng_error_query_results_create(void);
+struct lttng_error_query_results *lttng_error_query_results_create();
/* Ownership of `result` is transferred on success. */
int lttng_error_query_results_add_result(
struct lttng_event_field_value *lttng_event_field_value_string_create_with_size(
const char *val, size_t size);
-struct lttng_event_field_value *lttng_event_field_value_array_create(void);
+struct lttng_event_field_value *lttng_event_field_value_array_create();
int lttng_event_field_value_enum_append_label(
struct lttng_event_field_value *field_val, const char *label);
* blocking state caused by a poll(). If the counter's value is not an even
* number (meaning a code execution flow), an LTTNG_ASSERT() is raised.
*/
-static inline void health_poll_entry(void)
+static inline void health_poll_entry()
{
/* Code MUST be in code execution state which is an even number. */
LTTNG_ASSERT(!(uatomic_read(&URCU_TLS(health_state).current)
* If the counter's value is not an odd number (a poll execution), an LTTNG_ASSERT()
* is raised.
*/
-static inline void health_poll_exit(void)
+static inline void health_poll_exit()
{
/* Code MUST be in poll execution state which is an odd number. */
LTTNG_ASSERT(uatomic_read(&URCU_TLS(health_state).current)
* Update current counter by 2 indicates progress in execution of a
* thread.
*/
-static inline void health_code_update(void)
+static inline void health_code_update()
{
uatomic_add(&URCU_TLS(health_state).current, HEALTH_CODE_VALUE);
}
/*
* Set health "error" flag.
*/
-static inline void health_error(void)
+static inline void health_error()
{
uatomic_or(&URCU_TLS(health_state).flags, HEALTH_ERROR);
}
* Allocate a new set of triggers.
* The returned object must be freed via lttng_triggers_destroy.
*/
-struct lttng_triggers *lttng_triggers_create(void);
+struct lttng_triggers *lttng_triggers_create();
/*
* Return the a pointer to a mutable element at index "index" of an
return lttcomm_send_unix_sock(sock, buf, len);
}
-static int setup_health_path(void)
+static int setup_health_path()
{
int is_root, ret = 0;
enum lttng_consumer_type type;
}
} else {
home_path = utils_get_home_dir();
- if (home_path == NULL) {
+ if (home_path == nullptr) {
/* TODO: Add --socket PATH option */
ERR("Can't get HOME directory for sockets creation.");
ret = -EPERM;
cmm_smp_mb__before_uatomic_dec();
uatomic_dec(<tng_consumer_ready);
- while (1) {
+ while (true) {
DBG("Health check ready");
/* Inifinite blocking call, waiting for transmission */
lttng_poll_clean(&events);
rcu_unregister_thread();
- return NULL;
+ return nullptr;
}
* Setup signal handler for :
* SIGINT, SIGTERM, SIGPIPE, SIGBUS
*/
-static int set_signal_handler(void)
+static int set_signal_handler()
{
int ret = 0;
struct sigaction sa;
sa.sa_flags = SA_SIGINFO;
sa.sa_sigaction = sighandler;
- if ((ret = sigaction(SIGTERM, &sa, NULL)) < 0) {
+ if ((ret = sigaction(SIGTERM, &sa, nullptr)) < 0) {
PERROR("sigaction");
return ret;
}
- if ((ret = sigaction(SIGINT, &sa, NULL)) < 0) {
+ if ((ret = sigaction(SIGINT, &sa, nullptr)) < 0) {
PERROR("sigaction");
return ret;
}
- if ((ret = sigaction(SIGBUS, &sa, NULL)) < 0) {
+ if ((ret = sigaction(SIGBUS, &sa, nullptr)) < 0) {
PERROR("sigaction");
return ret;
}
sa.sa_flags = 0;
sa.sa_handler = SIG_IGN;
- if ((ret = sigaction(SIGPIPE, &sa, NULL)) < 0) {
+ if ((ret = sigaction(SIGPIPE, &sa, nullptr)) < 0) {
PERROR("sigaction");
return ret;
}
{
int c, ret = 0;
- static struct option long_options[] = { { "consumerd-cmd-sock", 1, 0, 'c' },
- { "consumerd-err-sock", 1, 0, 'e' },
- { "daemonize", 0, 0, 'd' },
- { "group", 1, 0, 'g' },
- { "help", 0, 0, 'h' },
- { "quiet", 0, 0, 'q' },
- { "verbose", 0, 0, 'v' },
- { "version", 0, 0, 'V' },
- { "kernel", 0, 0, 'k' },
+ static struct option long_options[] = { { "consumerd-cmd-sock", 1, nullptr, 'c' },
+ { "consumerd-err-sock", 1, nullptr, 'e' },
+ { "daemonize", 0, nullptr, 'd' },
+ { "group", 1, nullptr, 'g' },
+ { "help", 0, nullptr, 'h' },
+ { "quiet", 0, nullptr, 'q' },
+ { "verbose", 0, nullptr, 'v' },
+ { "version", 0, nullptr, 'V' },
+ { "kernel", 0, nullptr, 'k' },
#ifdef HAVE_LIBLTTNG_UST_CTL
- { "ust", 0, 0, 'u' },
+ { "ust", 0, nullptr, 'u' },
#endif
- { NULL, 0, 0, 0 } };
+ { nullptr, 0, nullptr, 0 } };
- while (1) {
+ while (true) {
int option_index = 0;
c = getopt_long(argc,
argv,
* Set open files limit to unlimited. This daemon can open a large number of
* file descriptors in order to consumer multiple kernel traces.
*/
-static void set_ulimit(void)
+static void set_ulimit()
{
int ret;
struct rlimit lim;
rcu_register_thread();
- if (run_as_create_worker(argv[0], NULL, NULL) < 0) {
+ if (run_as_create_worker(argv[0], nullptr, nullptr) < 0) {
goto exit_set_signal_handler;
}
}
/* create the consumer instance with and assign the callbacks */
- the_consumer_context = lttng_consumer_create(
- opt_type, lttng_consumer_read_subbuffer, NULL, lttng_consumer_on_recv_stream, NULL);
+ the_consumer_context = lttng_consumer_create(opt_type,
+ lttng_consumer_read_subbuffer,
+ nullptr,
+ lttng_consumer_on_recv_stream,
+ nullptr);
if (!the_consumer_context) {
retval = -1;
goto exit_init_data;
ret = pthread_create(&health_thread,
default_pthread_attr(),
thread_manage_health_consumerd,
- (void *) NULL);
+ (void *) nullptr);
if (ret) {
errno = ret;
PERROR("pthread_create health");
* Create the thread to manage the UST metadata periodic timer and
* live timer.
*/
- ret = pthread_create(
- &metadata_timer_thread, NULL, consumer_timer_thread, (void *) the_consumer_context);
+ ret = pthread_create(&metadata_timer_thread,
+ nullptr,
+ consumer_timer_thread,
+ (void *) the_consumer_context);
if (ret) {
errno = ret;
PERROR("pthread_create");
metadata_timer_thread_online = false;
}
tmp_ctx = the_consumer_context;
- the_consumer_context = NULL;
+ the_consumer_context = nullptr;
cmm_barrier(); /* Clear ctx for signal handler. */
lttng_consumer_destroy(tmp_ctx);
#ifdef LTTNG_EMBED_HELP
#include <lttng-crash.1.h>
#else
- NULL
+ nullptr
#endif
;
/* Variables */
static const char *progname;
-static char *opt_viewer_path = NULL;
-static char *opt_output_path = NULL;
+static char *opt_viewer_path = nullptr;
+static char *opt_output_path = nullptr;
static char *the_input_path;
/* Getopt options. No first level command. */
static struct option long_options[] = {
- { "version", 0, NULL, 'V' }, { "help", 0, NULL, 'h' },
- { "verbose", 0, NULL, 'v' }, { "viewer", 1, NULL, 'e' },
- { "extract", 1, NULL, 'x' }, { "list-options", 0, NULL, OPT_DUMP_OPTIONS },
- { NULL, 0, NULL, 0 },
+ { "version", 0, nullptr, 'V' }, { "help", 0, nullptr, 'h' },
+ { "verbose", 0, nullptr, 'v' }, { "viewer", 1, nullptr, 'e' },
+ { "extract", 1, nullptr, 'x' }, { "list-options", 0, nullptr, OPT_DUMP_OPTIONS },
+ { nullptr, 0, nullptr, 0 },
};
-static void usage(void)
+static void usage()
{
int ret = utils_show_help(1, "lttng-crash", help_msg);
static void list_options(FILE *ofp)
{
int i = 0;
- struct option *option = NULL;
+ struct option *option = nullptr;
option = &long_options[i];
- while (option->name != NULL) {
+ while (option->name != nullptr) {
fprintf(ofp, "--%s\n", option->name);
if (isprint(option->val)) {
exit(EXIT_FAILURE);
}
- while ((opt = getopt_long(argc, argv, "+Vhve:x:", long_options, NULL)) != -1) {
+ while ((opt = getopt_long(argc, argv, "+Vhve:x:", long_options, nullptr)) != -1) {
switch (opt) {
case 'V':
version(stdout);
RB_CRASH_DUMP_ABI_LEN);
return -1;
}
- map = (char *) mmap(NULL, RB_CRASH_DUMP_ABI_LEN, PROT_READ, MAP_PRIVATE, fd, 0);
+ map = (char *) mmap(nullptr, RB_CRASH_DUMP_ABI_LEN, PROT_READ, MAP_PRIVATE, fd, 0);
if (map == MAP_FAILED) {
PERROR("Mapping file");
return -1;
{
int ret;
bool has_warning = false;
- const char *output_path = NULL;
+ const char *output_path = nullptr;
char tmppath[] = "/tmp/lttng-crash-XXXXXX";
progname = argv[0] ? argv[0] : "lttng-crash";
int ret;
size_t len;
char *leftover_ptr;
- char *local_copy = NULL;
- char *datetime = NULL;
- char *partial_base_path = NULL;
- char *filepath_per_session = NULL;
+ char *local_copy = nullptr;
+ char *datetime = nullptr;
+ char *partial_base_path = nullptr;
+ char *filepath_per_session = nullptr;
const char *second_token_ptr;
const char *leftover_second_token_ptr;
const char *hostname_ptr;
goto error;
}
- second_token_ptr = strtok_r(NULL, "/", &leftover_ptr);
+ second_token_ptr = strtok_r(nullptr, "/", &leftover_ptr);
if (!second_token_ptr) {
ERR("Failed to parse session path \"%s\": couldn't identify session name", path);
goto error;
* session_name. If this is a auto session name, we need to
* fetch the creation datetime.
*/
- ret = regexec(®ex, local_session_name, 0, NULL, 0);
+ ret = regexec(®ex, local_session_name, 0, nullptr, 0);
if (ret == 0) {
const ssize_t local_session_name_offset =
strlen(local_session_name) - DATETIME_STR_LEN + 1;
}
}
} else if (len == DATETIME_STR_LEN &&
- !regexec(®ex, leftover_second_token_ptr, 0, NULL, 0)) {
+ !regexec(®ex, leftover_second_token_ptr, 0, nullptr, 0)) {
/*
* The leftover from the second token is of format
* "-<datetime>", use it as the creation time.
* "name-<datetime>" format. Using the datetime from such a
* session would be invalid.
* */
- LTTNG_ASSERT(partial_base_path == NULL);
- LTTNG_ASSERT(datetime == NULL);
+ LTTNG_ASSERT(partial_base_path == nullptr);
+ LTTNG_ASSERT(datetime == nullptr);
partial_base_path = strdup(second_token_ptr);
if (!partial_base_path) {
partial_base_path ? "/" : "",
leftover_ptr);
if (ret < 0) {
- filepath_per_session = NULL;
+ filepath_per_session = nullptr;
goto error;
}
error_regex:
{
int ret;
struct lttcomm_relayd_add_stream stream_info;
- char *path_name = NULL;
- char *channel_name = NULL;
+ char *path_name = nullptr;
+ char *channel_name = nullptr;
size_t len;
if (payload->size < sizeof(stream_info)) {
size_t header_len, received_names_size;
struct lttng_buffer_view channel_name_view;
struct lttng_buffer_view pathname_view;
- char *path_name = NULL;
- char *channel_name = NULL;
+ char *path_name = nullptr;
+ char *channel_name = nullptr;
header_len = sizeof(header);
*ret_path_name = path_name;
*ret_channel_name = channel_name;
/* Move ownership to caller */
- path_name = NULL;
- channel_name = NULL;
+ path_name = nullptr;
+ channel_name = nullptr;
ret = 0;
error:
free(channel_name);
{
int ret;
struct lttcomm_relayd_add_stream_2_2 stream_info;
- char *path_name = NULL;
- char *channel_name = NULL;
+ char *path_name = nullptr;
+ char *channel_name = nullptr;
size_t len;
if (payload->size < sizeof(stream_info)) {
{
struct lttng_ht_node_ulong *node;
struct lttng_ht_iter iter;
- struct relay_connection *conn = NULL;
+ struct relay_connection *conn = nullptr;
LTTNG_ASSERT(sock >= 0);
}
conn = lttng::utils::container_of(node, &relay_connection::sock_n);
if (!connection_get(conn)) {
- conn = NULL;
+ conn = nullptr;
}
end:
rcu_read_unlock();
lttcomm_destroy_sock(conn->sock);
if (conn->viewer_session) {
viewer_session_destroy(conn->viewer_session);
- conn->viewer_session = NULL;
+ conn->viewer_session = nullptr;
}
if (conn->type == RELAY_CONTROL) {
lttng_dynamic_buffer_reset(&conn->protocol.ctrl.reception_buffer);
if (session_close(conn->session)) {
ERR("session_close");
}
- conn->session = NULL;
+ conn->session = nullptr;
}
if (conn->viewer_session) {
viewer_session_close(conn->viewer_session);
{
LTTNG_ASSERT(!conn->in_socket_ht);
lttng_ht_add_unique_ulong(relay_connections_ht, &conn->sock_n);
- conn->in_socket_ht = 1;
+ conn->in_socket_ht = true;
conn->socket_ht = relay_connections_ht;
}
ASSERT_RCU_READ_LOCKED();
session_put(trace->session);
- trace->session = NULL;
+ trace->session = nullptr;
free(trace->path);
- trace->path = NULL;
+ trace->path = nullptr;
call_rcu(&trace->rcu_node, rcu_destroy_ctf_trace);
}
lttng_ht_node_init_str(&trace->node, trace->path);
trace->session = session;
- pthread_mutex_init(&trace->lock, NULL);
- pthread_mutex_init(&trace->stream_list_lock, NULL);
+ pthread_mutex_init(&trace->lock, nullptr);
+ pthread_mutex_init(&trace->stream_list_lock, nullptr);
lttng_ht_add_str(session->ctf_traces_ht, &trace->node);
DBG("Created ctf_trace %" PRIu64 " of session \"%s\" from host \"%s\" with path: %s",
return trace;
error:
ctf_trace_put(trace);
- return NULL;
+ return nullptr;
}
/*
{
struct lttng_ht_node_str *node;
struct lttng_ht_iter iter;
- struct ctf_trace *trace = NULL;
+ struct ctf_trace *trace = nullptr;
rcu_read_lock();
lttng_ht_lookup(session->ctf_traces_ht, subpath, &iter);
}
trace = lttng::utils::container_of(node, &ctf_trace::node);
if (!ctf_trace_get(trace)) {
- trace = NULL;
+ trace = nullptr;
}
end:
rcu_read_unlock();
goto end;
}
if (!viewer_stream_get(vstream)) {
- vstream = NULL;
+ vstream = nullptr;
}
end:
rcu_read_unlock();
return ret;
}
-static int parse_health_env(void)
+static int parse_health_env()
{
const char *health_path;
return 0;
}
-static int setup_health_path(void)
+static int setup_health_path()
{
int is_root, ret = 0;
- const char *home_path = NULL;
- char *rundir = NULL, *relayd_path = NULL;
+ const char *home_path = nullptr;
+ char *rundir = nullptr, *relayd_path = nullptr;
ret = parse_health_env();
if (ret) {
*/
home_path = utils_get_home_dir();
- if (home_path == NULL) {
+ if (home_path == nullptr) {
/* TODO: Add --socket PATH option */
ERR("Can't get HOME directory for sockets creation.");
ret = -EPERM;
lttng_relay_notify_ready();
- while (1) {
+ while (true) {
char *accepted_socket_name;
DBG("Health check ready");
if (ret <= 0) {
DBG("Nothing recv() from client... continuing");
ret = fd_tracker_close_unsuspendable_fd(
- the_fd_tracker, &new_sock, 1, fd_tracker_util_close_fd, NULL);
+ the_fd_tracker, &new_sock, 1, fd_tracker_util_close_fd, nullptr);
if (ret) {
PERROR("close");
}
/* End of transmission */
ret = fd_tracker_close_unsuspendable_fd(
- the_fd_tracker, &new_sock, 1, fd_tracker_util_close_fd, NULL);
+ the_fd_tracker, &new_sock, 1, fd_tracker_util_close_fd, nullptr);
if (ret) {
PERROR("close");
}
unlink(health_unix_sock_path);
if (sock >= 0) {
ret = fd_tracker_close_unsuspendable_fd(
- the_fd_tracker, &sock, 1, fd_tracker_util_close_fd, NULL);
+ the_fd_tracker, &sock, 1, fd_tracker_util_close_fd, nullptr);
if (ret) {
PERROR("close");
}
(void) fd_tracker_util_poll_clean(the_fd_tracker, &events);
rcu_unregister_thread();
- return NULL;
+ return nullptr;
}
if (!stream_get(stream)) {
ERR("Cannot get stream");
free(index);
- index = NULL;
+ index = nullptr;
goto end;
}
index->stream = stream;
lttng_ht_node_init_u64(&index->index_n, net_seq_num);
- pthread_mutex_init(&index->lock, NULL);
+ pthread_mutex_init(&index->lock, nullptr);
urcu_ref_init(&index->ref);
end:
if (node_ptr != &index->index_n.node) {
_index = caa_container_of(node_ptr, struct relay_index, index_n.node);
} else {
- _index = NULL;
+ _index = nullptr;
}
return _index;
}
{
struct lttng_ht_node_u64 *node;
struct lttng_ht_iter iter;
- struct relay_index *index = NULL;
+ struct relay_index *index = nullptr;
DBG3("Finding index for stream id %" PRIu64 " and seq_num %" PRIu64,
stream->stream_handle,
relay_index_put(index);
index = oldindex;
if (!relay_index_get(index)) {
- index = NULL;
+ index = nullptr;
}
} else {
stream->indexes_in_flight++;
if (index->index_file) {
lttng_index_file_put(index->index_file);
- index->index_file = NULL;
+ index->index_file = nullptr;
}
if (index->in_hash_table) {
/* Delete index from hash table. */
}
stream_put(index->stream);
- index->stream = NULL;
+ index->stream = nullptr;
call_rcu(&index->rcu_node, index_destroy_rcu);
}
/*
* Cleanup the daemon
*/
-static void cleanup_relayd_live(void)
+static void cleanup_relayd_live()
{
DBG("Cleaning up");
}
DBG("Sending stream %" PRIu64 " to viewer", vstream->stream->stream_handle);
- vstream->sent_flag = 1;
+ vstream->sent_flag = true;
pthread_mutex_unlock(&vstream->stream->lock);
ret = send_response(sock, &send_stream, sizeof(send_stream));
int ret;
struct lttng_ht_iter iter;
struct ctf_trace *ctf_trace;
- struct relay_stream *relay_stream = NULL;
+ struct relay_stream *relay_stream = nullptr;
LTTNG_ASSERT(relay_session);
ASSERT_LOCKED(relay_session->lock);
}
}
- relay_stream = NULL;
+ relay_stream = nullptr;
/*
* If there is no metadata stream in this trace at the moment
}
viewer_stream = viewer_stream_get_by_id(relay_stream->stream_handle);
if (!viewer_stream) {
- struct lttng_trace_chunk *viewer_stream_trace_chunk = NULL;
+ struct lttng_trace_chunk *viewer_stream_trace_chunk = nullptr;
/*
* Save that we sent the metadata stream to the
viewer_stream = viewer_stream_create(
relay_stream, viewer_stream_trace_chunk, seek_t);
lttng_trace_chunk_put(viewer_stream_trace_chunk);
- viewer_stream_trace_chunk = NULL;
+ viewer_stream_trace_chunk = nullptr;
if (!viewer_stream) {
ret = -1;
ctf_trace_put(ctf_trace);
pthread_mutex_unlock(&relay_stream->lock);
stream_put(relay_stream);
}
- relay_stream = NULL;
+ relay_stream = nullptr;
ctf_trace_put(ctf_trace);
}
return ret;
}
-int relayd_live_stop(void)
+int relayd_live_stop()
{
/* Stop dispatch thread */
CMM_STORE_SHARED(live_dispatch_thread_exit, 1);
static struct lttcomm_sock *accept_live_sock(struct lttcomm_sock *listening_sock, const char *name)
{
int out_fd, ret;
- struct lttcomm_sock *socks[2] = { listening_sock, NULL };
- struct lttcomm_sock *new_sock = NULL;
+ struct lttcomm_sock *socks[2] = { listening_sock, nullptr };
+ struct lttcomm_sock *new_sock = nullptr;
ret = fd_tracker_open_unsuspendable_fd(
the_fd_tracker, &out_fd, (const char **) &name, 1, accept_sock, &socks);
static struct lttcomm_sock *init_socket(struct lttng_uri *uri, const char *name)
{
int ret, sock_fd;
- struct lttcomm_sock *sock = NULL;
+ struct lttcomm_sock *sock = nullptr;
char uri_str[LTTNG_PATH_MAX];
- char *formated_name = NULL;
+ char *formated_name = nullptr;
sock = lttcomm_alloc_sock_from_uri(uri);
- if (sock == NULL) {
+ if (sock == nullptr) {
ERR("Allocating socket");
goto error;
}
if (ret >= 0) {
ret = asprintf(&formated_name, "%s socket @ %s", name, uri_str);
if (ret < 0) {
- formated_name = NULL;
+ formated_name = nullptr;
}
}
ret = fd_tracker_open_unsuspendable_fd(the_fd_tracker,
&sock_fd,
(const char **) (formated_name ? &formated_name :
- NULL),
+ nullptr),
1,
create_sock,
sock);
lttcomm_destroy_sock(sock);
}
free(formated_name);
- return NULL;
+ return nullptr;
}
/*
goto error_testpoint;
}
- while (1) {
+ while (true) {
health_code_update();
DBG("Listener accepting live viewers connections");
goto error;
}
/* Ownership assumed by the connection. */
- newsock = NULL;
+ newsock = nullptr;
/* Enqueue request for the dispatcher thread. */
cds_wfcq_head_ptr_t head;
if (lttng_relay_stop_threads()) {
ERR("Error stopping threads");
}
- return NULL;
+ return nullptr;
}
/*
int err = -1;
ssize_t ret;
struct cds_wfcq_node *node;
- struct relay_connection *conn = NULL;
+ struct relay_connection *conn = nullptr;
DBG("[thread] Live viewer relay dispatcher started");
/* Dequeue commands */
node = cds_wfcq_dequeue_blocking(&viewer_conn_queue.head,
&viewer_conn_queue.tail);
- if (node == NULL) {
+ if (node == nullptr) {
DBG("Woken up but nothing in the live-viewer "
"relay command queue");
/* Continue thread execution */
connection_put(conn);
goto error;
}
- } while (node != NULL);
+ } while (node != nullptr);
/* Futex wait on queue. Blocking call on futex() */
health_poll_entry();
if (lttng_relay_stop_threads()) {
ERR("Error stopping threads");
}
- return NULL;
+ return nullptr;
}
/*
int ret;
struct lttng_viewer_connect reply, msg;
- conn->version_check_done = 1;
+ conn->version_check_done = true;
health_code_update();
struct lttng_viewer_list_sessions session_list;
struct lttng_ht_iter iter;
struct relay_session *session;
- struct lttng_viewer_session *send_session_buf = NULL;
+ struct lttng_viewer_session *send_session_buf = nullptr;
uint32_t buf_count = SESSION_BUF_DEFAULT_COUNT;
uint32_t count = 0;
uint32_t nb_created = 0, nb_unsent = 0, nb_streams = 0, nb_total = 0;
struct lttng_viewer_new_streams_request request;
struct lttng_viewer_new_streams_response response;
- struct relay_session *session = NULL;
+ struct relay_session *session = nullptr;
uint64_t session_id;
bool closed = false;
enum lttng_viewer_seek seek_type;
struct lttng_viewer_attach_session_request request;
struct lttng_viewer_attach_session_response response;
- struct relay_session *session = NULL;
+ struct relay_session *session = nullptr;
enum lttng_viewer_attach_return_code viewer_attach_status;
bool closed = false;
uint64_t session_id;
}
ret = make_viewer_streams(
- session, conn->viewer_session, seek_type, &nb_streams, NULL, NULL, &closed);
+ session, conn->viewer_session, seek_type, &nb_streams, nullptr, nullptr, &closed);
if (ret < 0) {
goto end_put_session;
}
pthread_mutex_unlock(&session->lock);
session_put(session);
- session = NULL;
+ session = nullptr;
response.streams_count = htobe32(nb_streams);
/*
struct lttng_viewer_get_next_index request_index;
struct lttng_viewer_index viewer_index;
struct ctf_packet_index packet_index;
- struct relay_viewer_stream *vstream = NULL;
- struct relay_stream *rstream = NULL;
- struct ctf_trace *ctf_trace = NULL;
- struct relay_viewer_stream *metadata_viewer_stream = NULL;
+ struct relay_viewer_stream *vstream = nullptr;
+ struct relay_stream *rstream = nullptr;
+ struct ctf_trace *ctf_trace = nullptr;
+ struct relay_viewer_stream *metadata_viewer_stream = nullptr;
bool viewer_stream_and_session_in_same_chunk, viewer_stream_one_rotation_behind;
uint64_t stream_file_chunk_id = -1ULL, viewer_session_chunk_id = -1ULL;
enum lttng_trace_chunk_status status;
rstream->channel_name,
rstream->tracefile_size,
vstream->current_tracefile_id,
- NULL,
+ nullptr,
file_path,
sizeof(file_path));
if (ret < 0) {
{
int ret;
off_t lseek_ret;
- char *reply = NULL;
+ char *reply = nullptr;
struct lttng_viewer_get_packet get_packet_info;
struct lttng_viewer_trace_packet reply_header;
- struct relay_viewer_stream *vstream = NULL;
+ struct relay_viewer_stream *vstream = nullptr;
uint32_t reply_size = sizeof(reply_header);
uint32_t packet_data_len = 0;
ssize_t read_len;
int fd = -1;
ssize_t read_len;
uint64_t len = 0;
- char *data = NULL;
+ char *data = nullptr;
struct lttng_viewer_get_metadata request;
struct lttng_viewer_metadata_packet reply;
- struct relay_viewer_stream *vstream = NULL;
+ struct relay_viewer_stream *vstream = nullptr;
LTTNG_ASSERT(conn);
rstream->channel_name,
rstream->tracefile_size,
vstream->current_tracefile_id,
- NULL,
+ nullptr,
file_path,
sizeof(file_path));
if (ret < 0) {
int ret;
struct lttng_viewer_detach_session_response response;
struct lttng_viewer_detach_session_request request;
- struct relay_session *session = NULL;
+ struct relay_session *session = nullptr;
uint64_t viewer_session_to_close;
LTTNG_ASSERT(conn);
(void) lttng_poll_del(events, pollfd);
ret = fd_tracker_close_unsuspendable_fd(
- the_fd_tracker, &pollfd, 1, fd_tracker_util_close_fd, NULL);
+ the_fd_tracker, &pollfd, 1, fd_tracker_util_close_fd, nullptr);
if (ret < 0) {
ERR("Closing pollfd %d", pollfd);
}
}
restart:
- while (1) {
+ while (true) {
int i;
health_code_update();
ERR("Error stopping threads");
}
rcu_unregister_thread();
- return NULL;
+ return nullptr;
}
/*
* Create the relay command pipe to wake thread_manage_apps.
* Closed in cleanup().
*/
-static int create_conn_pipe(void)
+static int create_conn_pipe()
{
return fd_tracker_util_pipe_open_cloexec(
the_fd_tracker, "Live connection pipe", live_conn_pipe);
}
-int relayd_live_join(void)
+int relayd_live_join()
{
int ret, retval = 0;
void *status;
}
/* Setup the dispatcher thread */
- ret = pthread_create(
- &live_dispatcher_thread, default_pthread_attr(), thread_dispatcher, (void *) NULL);
+ ret = pthread_create(&live_dispatcher_thread,
+ default_pthread_attr(),
+ thread_dispatcher,
+ (void *) nullptr);
if (ret) {
errno = ret;
PERROR("pthread_create viewer dispatcher");
}
/* Setup the worker thread */
- ret = pthread_create(&live_worker_thread, default_pthread_attr(), thread_worker, NULL);
+ ret = pthread_create(&live_worker_thread, default_pthread_attr(), thread_worker, nullptr);
if (ret) {
errno = ret;
PERROR("pthread_create viewer worker");
/* Setup the listener thread */
ret = pthread_create(
- &live_listener_thread, default_pthread_attr(), thread_listener, (void *) NULL);
+ &live_listener_thread, default_pthread_attr(), thread_listener, (void *) nullptr);
if (ret) {
errno = ret;
PERROR("pthread_create viewer listener");
#ifdef LTTNG_EMBED_HELP
#include <lttng-relayd.8.h>
#else
- NULL
+ nullptr
#endif
;
{
"control-port",
1,
- 0,
+ nullptr,
'C',
},
{
"data-port",
1,
- 0,
+ nullptr,
'D',
},
{
"live-port",
1,
- 0,
+ nullptr,
'L',
},
{
"daemonize",
0,
- 0,
+ nullptr,
'd',
},
{
"background",
0,
- 0,
+ nullptr,
'b',
},
{
"group",
1,
- 0,
+ nullptr,
'g',
},
{
"fd-pool-size",
1,
- 0,
+ nullptr,
'\0',
},
{
"help",
0,
- 0,
+ nullptr,
'h',
},
{
"output",
1,
- 0,
+ nullptr,
'o',
},
{
"verbose",
0,
- 0,
+ nullptr,
'v',
},
- { "config", 1, 0, 'f' },
- { "version", 0, 0, 'V' },
+ { "config", 1, nullptr, 'f' },
+ { "version", 0, nullptr, 'V' },
{
"working-directory",
1,
- 0,
+ nullptr,
'w',
},
{
"group-output-by-session",
0,
- 0,
+ nullptr,
's',
},
{
"group-output-by-host",
0,
- 0,
+ nullptr,
'p',
},
- { "disallow-clear", 0, 0, 'x' },
+ { "disallow-clear", 0, nullptr, 'x' },
{
- NULL,
- 0,
+ nullptr,
0,
+ nullptr,
0,
},
};
static const char *config_ignore_options[] = { "help", "config", "version" };
-static void print_version(void)
+static void print_version()
{
fprintf(stdout, "%s\n", VERSION);
}
-static void relayd_config_log(void)
+static void relayd_config_log()
{
DBG("LTTng-relayd " VERSION " - " VERSION_NAME "%s%s",
GIT_VERSION[0] == '\0' ? "" : " - " GIT_VERSION,
unsigned long v;
errno = 0;
- v = strtoul(arg, NULL, 0);
+ v = strtoul(arg, nullptr, 0);
if (errno != 0 || !isdigit((unsigned char) arg[0])) {
ERR("Wrong value in --fd-pool-size parameter: %s", arg);
ret = -1;
"-g, --group");
} else {
tracing_group_name = strdup(arg);
- if (tracing_group_name == NULL) {
+ if (tracing_group_name == nullptr) {
ret = -errno;
PERROR("strdup");
goto end;
return ret;
}
-static int parse_env_options(void)
+static int parse_env_options()
{
int ret = 0;
- char *value = NULL;
+ char *value = nullptr;
value = lttng_secure_getenv(DEFAULT_LTTNG_RELAYD_WORKING_DIRECTORY_ENV);
if (value) {
return ret;
}
-static int set_fd_pool_size(void)
+static int set_fd_pool_size()
{
int ret = 0;
struct rlimit rlimit;
int c, ret = 0, option_index = 0, retval = 0;
int orig_optopt = optopt, orig_optind = optind;
char *default_address, *optstring;
- char *config_path = NULL;
+ char *config_path = nullptr;
optstring = utils_generate_optstring(long_options,
sizeof(long_options) / sizeof(struct option));
}
ret = config_get_section_entries(
- config_path, config_section_name, config_entry_handler, NULL);
+ config_path, config_section_name, config_entry_handler, nullptr);
if (ret) {
if (ret > 0) {
ERR("Invalid configuration option at line %i", ret);
/* Reset getopt's global state */
optopt = orig_optopt;
optind = orig_optind;
- while (1) {
+ while (true) {
c = getopt_long(argc, argv, optstring, long_options, &option_index);
if (c == -1) {
break;
}
/* assign default values */
- if (control_uri == NULL) {
+ if (control_uri == nullptr) {
ret = asprintf(&default_address,
"tcp://" DEFAULT_NETWORK_CONTROL_BIND_ADDRESS ":%d",
DEFAULT_NETWORK_CONTROL_PORT);
goto exit;
}
}
- if (data_uri == NULL) {
+ if (data_uri == nullptr) {
ret = asprintf(&default_address,
"tcp://" DEFAULT_NETWORK_DATA_BIND_ADDRESS ":%d",
DEFAULT_NETWORK_DATA_PORT);
goto exit;
}
}
- if (live_uri == NULL) {
+ if (live_uri == nullptr) {
ret = asprintf(&default_address,
"tcp://" DEFAULT_NETWORK_VIEWER_BIND_ADDRESS ":%d",
DEFAULT_NETWORK_VIEWER_PORT);
return retval;
}
-static void print_global_objects(void)
+static void print_global_objects()
{
print_viewer_streams();
print_relay_streams();
return 0;
}
-static void untrack_stdio(void)
+static void untrack_stdio()
{
int fds[] = { fileno(stdout), fileno(stderr) };
* noop_close is used since we don't really want to close
* the stdio output fds; we merely want to stop tracking them.
*/
- (void) fd_tracker_close_unsuspendable_fd(the_fd_tracker, fds, 2, noop_close, NULL);
+ (void) fd_tracker_close_unsuspendable_fd(the_fd_tracker, fds, 2, noop_close, nullptr);
}
/*
* Cleanup the daemon
*/
-static void relayd_cleanup(void)
+static void relayd_cleanup()
{
print_global_objects();
/*
* Stop all relayd and relayd-live threads.
*/
-int lttng_relay_stop_threads(void)
+int lttng_relay_stop_threads()
{
int retval = 0;
* Setup signal handler for :
* SIGINT, SIGTERM, SIGPIPE
*/
-static int set_signal_handler(void)
+static int set_signal_handler()
{
int ret = 0;
struct sigaction sa;
sa.sa_flags = 0;
sa.sa_handler = sighandler;
- if ((ret = sigaction(SIGTERM, &sa, NULL)) < 0) {
+ if ((ret = sigaction(SIGTERM, &sa, nullptr)) < 0) {
PERROR("sigaction");
return ret;
}
- if ((ret = sigaction(SIGINT, &sa, NULL)) < 0) {
+ if ((ret = sigaction(SIGINT, &sa, nullptr)) < 0) {
PERROR("sigaction");
return ret;
}
- if ((ret = sigaction(SIGUSR1, &sa, NULL)) < 0) {
+ if ((ret = sigaction(SIGUSR1, &sa, nullptr)) < 0) {
PERROR("sigaction");
return ret;
}
sa.sa_handler = SIG_IGN;
- if ((ret = sigaction(SIGPIPE, &sa, NULL)) < 0) {
+ if ((ret = sigaction(SIGPIPE, &sa, nullptr)) < 0) {
PERROR("sigaction");
return ret;
}
return ret;
}
-void lttng_relay_notify_ready(void)
+void lttng_relay_notify_ready()
{
/* Notify the parent of the fork() process that we are ready. */
if (opt_daemon || opt_background) {
*
* Return -1 on error or 0 if all pipes are created.
*/
-static int init_health_quit_pipe(void)
+static int init_health_quit_pipe()
{
return fd_tracker_util_pipe_open_cloexec(
the_fd_tracker, "Health quit pipe", health_quit_pipe);
static struct lttcomm_sock *relay_socket_create(struct lttng_uri *uri, const char *name)
{
int ret, sock_fd;
- struct lttcomm_sock *sock = NULL;
+ struct lttcomm_sock *sock = nullptr;
char uri_str[PATH_MAX];
- char *formated_name = NULL;
+ char *formated_name = nullptr;
sock = lttcomm_alloc_sock_from_uri(uri);
- if (sock == NULL) {
+ if (sock == nullptr) {
ERR("Allocating socket");
goto error;
}
if (ret >= 0) {
ret = asprintf(&formated_name, "%s socket @ %s", name, uri_str);
if (ret < 0) {
- formated_name = NULL;
+ formated_name = nullptr;
}
}
ret = fd_tracker_open_unsuspendable_fd(the_fd_tracker,
&sock_fd,
(const char **) (formated_name ? &formated_name :
- NULL),
+ nullptr),
1,
create_sock,
sock);
lttcomm_destroy_sock(sock);
}
free(formated_name);
- return NULL;
+ return nullptr;
}
static struct lttcomm_sock *accept_relayd_sock(struct lttcomm_sock *listening_sock,
const char *name)
{
int out_fd, ret;
- struct lttcomm_sock *socks[2] = { listening_sock, NULL };
- struct lttcomm_sock *new_sock = NULL;
+ struct lttcomm_sock *socks[2] = { listening_sock, nullptr };
+ struct lttcomm_sock *new_sock = nullptr;
ret = fd_tracker_open_unsuspendable_fd(
the_fd_tracker, &out_fd, (const char **) &name, 1, accept_sock, &socks);
goto error_testpoint;
}
- while (1) {
+ while (true) {
health_code_update();
DBG("Listener accepting connections");
*/
int val = 1;
struct relay_connection *new_conn;
- struct lttcomm_sock *newsock = NULL;
+ struct lttcomm_sock *newsock = nullptr;
enum connection_type type;
if (pollfd == data_sock->fd) {
rcu_unregister_thread();
DBG("Relay listener thread cleanup complete");
lttng_relay_stop_threads();
- return NULL;
+ return nullptr;
}
/*
int err = -1;
ssize_t ret;
struct cds_wfcq_node *node;
- struct relay_connection *new_conn = NULL;
+ struct relay_connection *new_conn = nullptr;
DBG("[thread] Relay dispatcher started");
/* Dequeue commands */
node = cds_wfcq_dequeue_blocking(&relay_conn_queue.head,
&relay_conn_queue.tail);
- if (node == NULL) {
+ if (node == nullptr) {
DBG("Woken up but nothing in the relay command queue");
/* Continue thread execution */
break;
connection_put(new_conn);
goto error;
}
- } while (node != NULL);
+ } while (node != nullptr);
/* Futex wait on queue. Blocking call on futex() */
health_poll_entry();
health_unregister(health_relayd);
DBG("Dispatch thread dying");
lttng_relay_stop_threads();
- return NULL;
+ return nullptr;
}
static bool session_streams_have_index(const struct relay_session *session)
{
int ret = 0;
ssize_t send_ret;
- struct relay_session *session = NULL;
+ struct relay_session *session = nullptr;
struct lttcomm_relayd_create_session_reply_2_11 reply = {};
char session_name[LTTNG_NAME_MAX] = {};
char hostname[LTTNG_HOST_NAME_MAX] = {};
live_timer,
snapshot,
sessiond_uuid,
- id_sessiond.is_set ? &id_sessiond.value : NULL,
- current_chunk_id.is_set ? ¤t_chunk_id.value : NULL,
- creation_time.is_set ? &creation_time.value : NULL,
+ id_sessiond.is_set ? &id_sessiond.value : nullptr,
+ current_chunk_id.is_set ? ¤t_chunk_id.value : nullptr,
+ creation_time.is_set ? &creation_time.value : nullptr,
conn->major,
conn->minor,
session_name_contains_creation_timestamp);
int ret;
ssize_t send_ret;
struct relay_session *session = conn->session;
- struct relay_stream *stream = NULL;
+ struct relay_stream *stream = nullptr;
struct lttcomm_relayd_status_stream reply;
- struct ctf_trace *trace = NULL;
+ struct ctf_trace *trace = nullptr;
uint64_t stream_handle = -1ULL;
- char *path_name = NULL, *channel_name = NULL;
+ char *path_name = nullptr, *channel_name = nullptr;
uint64_t tracefile_size = 0, tracefile_count = 0;
LTTNG_OPTIONAL(uint64_t) stream_chunk_id = {};
/* We pass ownership of path_name and channel_name. */
stream = stream_create(
trace, stream_handle, path_name, channel_name, tracefile_size, tracefile_count);
- path_name = NULL;
- channel_name = NULL;
+ path_name = nullptr;
+ channel_name = nullptr;
/*
* Streams are the owners of their trace. Reference to trace is
msg.last_net_seq_num = be64toh(msg.last_net_seq_num);
stream = stream_get_by_id(msg.stream_id);
- if (stream == NULL) {
+ if (stream == nullptr) {
ret = -1;
goto end;
}
struct relay_session *session = conn->session;
struct lttcomm_relayd_rotate_streams rotate_streams;
struct lttcomm_relayd_generic_reply reply = {};
- struct relay_stream *stream = NULL;
- struct lttng_trace_chunk *next_trace_chunk = NULL;
+ struct relay_stream *stream = nullptr;
+ struct lttng_trace_chunk *next_trace_chunk = nullptr;
struct lttng_buffer_view stream_positions;
char chunk_id_buf[MAX_INT_DEC_LEN(uint64_t)];
const char *chunk_id_str = "none";
}
stream_put(stream);
- stream = NULL;
+ stream = nullptr;
}
reply_code = LTTNG_OK;
struct lttcomm_relayd_create_trace_chunk *msg;
struct lttcomm_relayd_generic_reply reply = {};
struct lttng_buffer_view header_view;
- struct lttng_trace_chunk *chunk = NULL, *published_chunk = NULL;
+ struct lttng_trace_chunk *chunk = nullptr, *published_chunk = nullptr;
enum lttng_error_code reply_code = LTTNG_OK;
enum lttng_trace_chunk_status chunk_status;
const char *new_path;
if (!session->has_rotated) {
new_path = "";
} else {
- new_path = NULL;
+ new_path = nullptr;
}
} else {
new_path = DEFAULT_CHUNK_TMP_NEW_DIRECTORY;
}
conn->session->pending_closure_trace_chunk = conn->session->current_trace_chunk;
conn->session->current_trace_chunk = published_chunk;
- published_chunk = NULL;
+ published_chunk = nullptr;
if (!conn->session->pending_closure_trace_chunk) {
session->ongoing_rotation = false;
}
struct lttcomm_relayd_close_trace_chunk *msg;
struct lttcomm_relayd_close_trace_chunk_reply reply = {};
struct lttng_buffer_view header_view;
- struct lttng_trace_chunk *chunk = NULL;
+ struct lttng_trace_chunk *chunk = nullptr;
enum lttng_error_code reply_code = LTTNG_OK;
enum lttng_trace_chunk_status chunk_status;
uint64_t chunk_id;
time_t close_timestamp;
char closed_trace_chunk_path[LTTNG_PATH_MAX];
size_t path_length = 0;
- const char *chunk_name = NULL;
+ const char *chunk_name = nullptr;
struct lttng_dynamic_buffer reply_payload;
const char *new_path;
new_path = "";
} else {
/* Use chunk name for new chunk. */
- new_path = NULL;
+ new_path = nullptr;
}
/* Rename new chunk path. */
chunk_status =
if (!session->has_rotated) {
old_path = "";
} else {
- old_path = NULL;
+ old_path = nullptr;
}
/* We need to move back the .tmp_old_chunk to its rightful place. */
chunk_status = lttng_trace_chunk_rename_path(chunk, old_path);
goto end_unlock_session;
}
}
- chunk_status = lttng_trace_chunk_get_name(chunk, &chunk_name, NULL);
+ chunk_status = lttng_trace_chunk_get_name(chunk, &chunk_name, nullptr);
if (chunk_status != LTTNG_TRACE_CHUNK_STATUS_OK) {
ERR("Failed to get chunk name");
ret = -1;
* the last stream releases its reference to it.
*/
lttng_trace_chunk_put(session->current_trace_chunk);
- session->current_trace_chunk = NULL;
+ session->current_trace_chunk = nullptr;
}
lttng_trace_chunk_put(session->pending_closure_trace_chunk);
- session->pending_closure_trace_chunk = NULL;
+ session->pending_closure_trace_chunk = nullptr;
end_unlock_session:
pthread_mutex_unlock(&session->lock);
goto end_stream_unlock;
}
- ret = stream_write(stream, NULL, state->header.padding_size);
+ ret = stream_write(stream, nullptr, state->header.padding_size);
if (ret) {
status = RELAY_CONNECTION_STATUS_ERROR;
goto end_stream_unlock;
* the new state. Don't use it beyond this point.
*/
connection_reset_protocol_state(conn);
- state = NULL;
+ state = nullptr;
end_stream_unlock:
close_requested = stream->close_requested;
(void) lttng_poll_del(events, pollfd);
ret = fd_tracker_close_unsuspendable_fd(
- the_fd_tracker, &pollfd, 1, fd_tracker_util_close_fd, NULL);
+ the_fd_tracker, &pollfd, 1, fd_tracker_util_close_fd, nullptr);
if (ret < 0) {
ERR("Closing pollfd %d", pollfd);
}
struct lttng_poll_event events;
struct lttng_ht *relay_connections_ht;
struct lttng_ht_iter iter;
- struct relay_connection *destroy_conn = NULL;
+ struct relay_connection *destroy_conn = nullptr;
DBG("[thread] Relay worker started");
}
restart:
- while (1) {
+ while (true) {
int idx = -1, i, seen_control = 0, last_notdel_data_fd = -1;
health_code_update();
health_unregister(health_relayd);
rcu_unregister_thread();
lttng_relay_stop_threads();
- return NULL;
+ return nullptr;
}
/*
* Create the relay command pipe to wake thread_manage_apps.
* Closed in cleanup().
*/
-static int create_relay_conn_pipe(void)
+static int create_relay_conn_pipe()
{
return fd_tracker_util_pipe_open_cloexec(
the_fd_tracker, "Relayd connection pipe", relay_conn_pipe);
return 0;
}
-static int track_stdio(void)
+static int track_stdio()
{
int fds[2];
const char *names[] = { "stdout", "stderr" };
- return fd_tracker_open_unsuspendable_fd(the_fd_tracker, fds, names, 2, stdio_open, NULL);
+ return fd_tracker_open_unsuspendable_fd(the_fd_tracker, fds, names, 2, stdio_open, nullptr);
}
/*
bool thread_is_rcu_registered = false;
int ret = 0, retval = 0;
void *status;
- char *unlinked_file_directory_path = NULL, *output_path = NULL;
+ char *unlinked_file_directory_path = nullptr, *output_path = nullptr;
/* Parse environment variables */
ret = parse_env_options();
}
/* Create thread to manage the client socket */
- ret = pthread_create(
- &health_thread, default_pthread_attr(), thread_manage_health_relayd, (void *) NULL);
+ ret = pthread_create(&health_thread,
+ default_pthread_attr(),
+ thread_manage_health_relayd,
+ (void *) nullptr);
if (ret) {
errno = ret;
PERROR("pthread_create health");
}
/* Setup the dispatcher thread */
- ret = pthread_create(
- &dispatcher_thread, default_pthread_attr(), relay_thread_dispatcher, (void *) NULL);
+ ret = pthread_create(&dispatcher_thread,
+ default_pthread_attr(),
+ relay_thread_dispatcher,
+ (void *) nullptr);
if (ret) {
errno = ret;
PERROR("pthread_create dispatcher");
}
/* Setup the worker thread */
- ret = pthread_create(&worker_thread, default_pthread_attr(), relay_thread_worker, NULL);
+ ret = pthread_create(&worker_thread, default_pthread_attr(), relay_thread_worker, nullptr);
if (ret) {
errno = ret;
PERROR("pthread_create worker");
/* Setup the listener thread */
ret = pthread_create(
- &listener_thread, default_pthread_attr(), relay_thread_listener, (void *) NULL);
+ &listener_thread, default_pthread_attr(), relay_thread_listener, (void *) nullptr);
if (ret) {
errno = ret;
PERROR("pthread_create listener");
* else
* hostname/base_path
*/
- char *session_directory = NULL;
+ char *session_directory = nullptr;
int ret = 0;
if (session->output_path[0] != '\0') {
* integral part of the name and how a user identify a session.
*/
int ret = 0;
- char *session_directory = NULL;
+ char *session_directory = nullptr;
char creation_datetime[DATETIME_STR_LEN];
if (session->output_path[0] != '\0') {
* relayd_output_path/session_directory
* e.g. /home/user/lttng-traces/hostname/session_name
*/
- char *full_session_path = NULL;
- struct lttng_directory_handle *handle = NULL;
+ char *full_session_path = nullptr;
+ struct lttng_directory_handle *handle = nullptr;
pthread_mutex_lock(&session->lock);
full_session_path = create_output_path(session->output_path);
static int session_set_anonymous_chunk(struct relay_session *session)
{
int ret = 0;
- struct lttng_trace_chunk *chunk = NULL;
+ struct lttng_trace_chunk *chunk = nullptr;
enum lttng_trace_chunk_status status;
struct lttng_directory_handle *output_directory;
}
session->current_trace_chunk = chunk;
- chunk = NULL;
+ chunk = nullptr;
end:
lttng_trace_chunk_put(chunk);
lttng_directory_handle_put(output_directory);
bool session_name_contains_creation_time)
{
int ret;
- struct relay_session *session = NULL;
+ struct relay_session *session = nullptr;
LTTNG_ASSERT(session_name);
LTTNG_ASSERT(hostname);
lttng_ht_node_init_u64(&session->session_n, session->id);
urcu_ref_init(&session->ref);
CDS_INIT_LIST_HEAD(&session->recv_list);
- pthread_mutex_init(&session->lock, NULL);
- pthread_mutex_init(&session->recv_list_lock, NULL);
+ pthread_mutex_init(&session->lock, nullptr);
+ pthread_mutex_init(&session->recv_list_lock, nullptr);
if (lttng_strncpy(session->session_name, session_name, sizeof(session->session_name))) {
WARN("Session name exceeds maximal allowed length");
if (creation_time) {
LTTNG_OPTIONAL_SET(&session->creation_time, *creation_time);
} else {
- LTTNG_OPTIONAL_SET(&session->creation_time, time(NULL));
+ LTTNG_OPTIONAL_SET(&session->creation_time, time(nullptr));
if (session->creation_time.value == (time_t) -1) {
PERROR("Failed to sample session creation time");
goto error;
error:
session_put(session);
- return NULL;
+ return nullptr;
}
/* Should be called with RCU read-side lock held. */
*/
struct relay_session *session_get_by_id(uint64_t id)
{
- struct relay_session *session = NULL;
+ struct relay_session *session = nullptr;
struct lttng_ht_node_u64 *node;
struct lttng_ht_iter iter;
session = lttng::utils::container_of(node, &relay_session::session_n);
DBG("Session find by ID %" PRIu64 " id found", id);
if (!session_get(session)) {
- session = NULL;
+ session = nullptr;
}
end:
rcu_read_unlock();
ret = session_delete(session);
LTTNG_ASSERT(!ret);
lttng_trace_chunk_put(session->current_trace_chunk);
- session->current_trace_chunk = NULL;
+ session->current_trace_chunk = nullptr;
lttng_trace_chunk_put(session->pending_closure_trace_chunk);
- session->pending_closure_trace_chunk = NULL;
+ session->pending_closure_trace_chunk = nullptr;
ret = sessiond_trace_chunk_registry_session_destroyed(sessiond_trace_chunk_registry,
session->sessiond_uuid);
LTTNG_ASSERT(!ret);
lttng_directory_handle_put(session->output_directory);
- session->output_directory = NULL;
+ session->output_directory = nullptr;
call_rcu(&session->rcu_node, rcu_destroy_session);
}
return ret;
}
-void print_sessions(void)
+void print_sessions()
{
struct lttng_ht_iter iter;
struct relay_session *session;
rcu_read_lock();
cds_lfht_del(element->sessiond_trace_chunk_registry->ht, &element->ht_node);
rcu_read_unlock();
- element->sessiond_trace_chunk_registry = NULL;
+ element->sessiond_trace_chunk_registry = nullptr;
}
lttng_trace_chunk_registry_destroy(element->trace_chunk_registry);
trace_chunk_registry_ht_element_find(struct sessiond_trace_chunk_registry *sessiond_registry,
const struct trace_chunk_registry_ht_key *key)
{
- struct trace_chunk_registry_ht_element *element = NULL;
+ struct trace_chunk_registry_ht_element *element = nullptr;
struct cds_lfht_node *node;
struct cds_lfht_iter iter;
* could be acquired.
*/
if (!trace_chunk_registry_ht_element_get(element)) {
- element = NULL;
+ element = nullptr;
}
}
rcu_read_unlock();
urcu_ref_init(&new_element->ref);
cds_lfht_node_init(&new_element->ht_node);
new_element->trace_chunk_registry = trace_chunk_registry;
- trace_chunk_registry = NULL;
+ trace_chunk_registry = nullptr;
/* Attempt to publish the new element. */
rcu_read_lock();
- while (1) {
+ while (true) {
struct cds_lfht_node *published_node;
struct trace_chunk_registry_ht_element *published_element;
DBG("Acquired reference to trace chunk registry of sessiond {%s}",
uuid_str);
trace_chunk_registry_ht_element_put(new_element);
- new_element = NULL;
+ new_element = nullptr;
break;
}
/*
return ret;
}
-struct sessiond_trace_chunk_registry *sessiond_trace_chunk_registry_create(void)
+struct sessiond_trace_chunk_registry *sessiond_trace_chunk_registry_create()
{
struct sessiond_trace_chunk_registry *sessiond_registry =
zmalloc<sessiond_trace_chunk_registry>();
}
sessiond_registry->ht = cds_lfht_new(
- DEFAULT_HT_SIZE, 1, 0, CDS_LFHT_AUTO_RESIZE | CDS_LFHT_ACCOUNTING, NULL);
+ DEFAULT_HT_SIZE, 1, 0, CDS_LFHT_AUTO_RESIZE | CDS_LFHT_ACCOUNTING, nullptr);
if (!sessiond_registry->ht) {
goto error;
}
return sessiond_registry;
error:
sessiond_trace_chunk_registry_destroy(sessiond_registry);
- return NULL;
+ return nullptr;
}
void sessiond_trace_chunk_registry_destroy(struct sessiond_trace_chunk_registry *sessiond_registry)
{
- int ret = cds_lfht_destroy(sessiond_registry->ht, NULL);
+ int ret = cds_lfht_destroy(sessiond_registry->ht, nullptr);
LTTNG_ASSERT(!ret);
free(sessiond_registry);
uint64_t chunk_id;
bool is_anonymous_chunk;
struct trace_chunk_registry_ht_key key;
- struct trace_chunk_registry_ht_element *element = NULL;
+ struct trace_chunk_registry_ht_element *element = nullptr;
char uuid_str[LTTNG_UUID_STR_LEN];
char chunk_id_str[MAX_INT_DEC_LEN(typeof(chunk_id))] = "-1";
- struct lttng_trace_chunk *published_chunk = NULL;
+ struct lttng_trace_chunk *published_chunk = nullptr;
bool trace_chunk_already_published;
lttng_uuid_to_str(sessiond_uuid, uuid_str);
const lttng_uuid& sessiond_uuid,
uint64_t session_id)
{
- struct lttng_trace_chunk *chunk = NULL;
+ struct lttng_trace_chunk *chunk = nullptr;
struct trace_chunk_registry_ht_element *element;
struct trace_chunk_registry_ht_key key;
char uuid_str[LTTNG_UUID_STR_LEN];
uint64_t session_id,
uint64_t chunk_id)
{
- struct lttng_trace_chunk *chunk = NULL;
+ struct lttng_trace_chunk *chunk = nullptr;
struct trace_chunk_registry_ht_element *element;
struct trace_chunk_registry_ht_key key;
char uuid_str[LTTNG_UUID_STR_LEN];
{
struct lttng_ht_node_u64 *node;
struct lttng_ht_iter iter;
- struct relay_stream *stream = NULL;
+ struct relay_stream *stream = nullptr;
rcu_read_lock();
lttng_ht_lookup(relay_streams_ht, &stream_id, &iter);
}
stream = lttng::utils::container_of(node, &relay_stream::node);
if (!stream_get(stream)) {
- stream = NULL;
+ stream = nullptr;
}
end:
rcu_read_unlock();
stream->channel_name,
stream->tracefile_size,
stream->tracefile_current_index,
- NULL,
+ nullptr,
stream_path,
sizeof(stream_path));
if (ret < 0) {
if (stream->file) {
fs_handle_close(stream->file);
- stream->file = NULL;
+ stream->file = nullptr;
}
stream->tracefile_wrapped_around = false;
off_t lseek_ret, previous_stream_copy_origin;
uint64_t copy_bytes_left, misplaced_data_size;
bool acquired_reference;
- struct fs_handle *previous_stream_file = NULL;
- struct lttng_trace_chunk *previous_chunk = NULL;
+ struct fs_handle *previous_stream_file = nullptr;
+ struct lttng_trace_chunk *previous_chunk = nullptr;
if (!LTTNG_OPTIONAL_GET(stream->ongoing_rotation).next_trace_chunk) {
ERR("Protocol error encoutered in %s(): stream rotation "
*/
LTTNG_ASSERT(stream->file);
previous_stream_file = stream->file;
- stream->file = NULL;
+ stream->file = nullptr;
LTTNG_ASSERT(!stream->is_metadata);
LTTNG_ASSERT(stream->tracefile_size_current > stream->pos_after_last_complete_data_index);
{
int ret;
uint32_t major, minor;
- char *index_subpath = NULL;
+ char *index_subpath = nullptr;
enum lttng_trace_chunk_status status;
ASSERT_LOCKED(stream->lock);
/* Put ref on previous index_file. */
if (stream->index_file) {
lttng_index_file_put(stream->index_file);
- stream->index_file = NULL;
+ stream->index_file = nullptr;
}
major = stream->trace->session->major;
minor = stream->trace->session->minor;
DBG("Rotating stream %" PRIu64 " index file", stream->stream_handle);
if (stream->index_file) {
lttng_index_file_put(stream->index_file);
- stream->index_file = NULL;
+ stream->index_file = nullptr;
}
stream->ongoing_rotation.value.index_rotated = true;
if (stream->file) {
fs_handle_close(stream->file);
- stream->file = NULL;
+ stream->file = nullptr;
}
ret = stream_create_data_output_file_from_trace_chunk(stream, chunk, false, &stream->file);
end:
uint64_t tracefile_count)
{
int ret;
- struct relay_stream *stream = NULL;
+ struct relay_stream *stream = nullptr;
struct relay_session *session = trace->session;
bool acquired_reference = false;
struct lttng_trace_chunk *current_trace_chunk;
stream = zmalloc<relay_stream>();
- if (stream == NULL) {
+ if (stream == nullptr) {
PERROR("relay stream zmalloc");
goto error_no_alloc;
}
stream->channel_name = channel_name;
stream->beacon_ts_end = -1ULL;
lttng_ht_node_init_u64(&stream->node, stream->stream_handle);
- pthread_mutex_init(&stream->lock, NULL);
+ pthread_mutex_init(&stream->lock, nullptr);
urcu_ref_init(&stream->ref);
ctf_trace_get(trace);
stream->trace = trace;
if (ret) {
if (stream->file) {
fs_handle_close(stream->file);
- stream->file = NULL;
+ stream->file = nullptr;
}
stream_put(stream);
- stream = NULL;
+ stream = nullptr;
}
if (acquired_reference) {
lttng_trace_chunk_put(current_trace_chunk);
*/
free(path_name);
free(channel_name);
- return NULL;
+ return nullptr;
}
/*
if (stream->file) {
fs_handle_close(stream->file);
- stream->file = NULL;
+ stream->file = nullptr;
}
if (stream->index_file) {
lttng_index_file_put(stream->index_file);
- stream->index_file = NULL;
+ stream->index_file = nullptr;
}
if (stream->trace) {
ctf_trace_put(stream->trace);
- stream->trace = NULL;
+ stream->trace = nullptr;
}
stream_complete_rotation(stream);
lttng_trace_chunk_put(stream->trace_chunk);
- stream->trace_chunk = NULL;
+ stream->trace_chunk = nullptr;
call_rcu(&stream->rcu_node, stream_destroy_rcu);
}
/* Put stream fd before put chunk. */
if (stream->file) {
fs_handle_close(stream->file);
- stream->file = NULL;
+ stream->file = nullptr;
}
if (stream->index_file) {
lttng_index_file_put(stream->index_file);
- stream->index_file = NULL;
+ stream->index_file = nullptr;
}
lttng_trace_chunk_put(stream->trace_chunk);
- stream->trace_chunk = NULL;
+ stream->trace_chunk = nullptr;
pthread_mutex_unlock(&stream->lock);
DBG("Succeeded in closing stream %" PRIu64, stream->stream_handle);
stream_put(stream);
if (stream->file) {
fs_handle_close(stream->file);
- stream->file = NULL;
+ stream->file = nullptr;
}
ret = stream_create_data_output_file_from_trace_chunk(
stream, stream->trace_chunk, false, &stream->file);
stream->stream_handle);
/* Put self-ref for this index due to error. */
relay_index_put(index);
- index = NULL;
+ index = nullptr;
goto end;
}
}
ret = -1;
/* Put self-ref for this index due to error. */
relay_index_put(index);
- index = NULL;
+ index = nullptr;
goto end;
}
stream->channel_name,
stream->stream_handle);
}
- stream->file = NULL;
+ stream->file = nullptr;
}
DBG("%s: reset tracefile_size_current for stream %" PRIu64 " was %" PRIu64,
stream, stream->trace_chunk, true, &stream->file);
}
-void print_relay_streams(void)
+void print_relay_streams()
{
struct lttng_ht_iter iter;
struct relay_stream *stream;
{
int ret;
long tmp;
- char *endptr = NULL;
+ char *endptr = nullptr;
errno = 0;
tmp = strtol(value, &endptr, 0);
}
/* Initialize the TCP keep-alive configuration. */
-__attribute__((constructor)) static void tcp_keep_alive_init(void)
+__attribute__((constructor)) static void tcp_keep_alive_init()
{
tcp_keep_alive_init_support(&the_support);
(void) tcp_keep_alive_init_config(&the_support, &the_config);
*
* Return -1 on error or 0 if all pipes are created.
*/
-int relayd_init_thread_quit_pipe(void)
+int relayd_init_thread_quit_pipe()
{
return fd_tracker_util_pipe_open_cloexec(
the_fd_tracker, "Thread quit pipe", thread_quit_pipe);
*
* Return 0 on success or -1 on error.
*/
-int relayd_notify_thread_quit_pipe(void)
+int relayd_notify_thread_quit_pipe()
{
return notify_thread_pipe(thread_quit_pipe[1]);
}
/*
* Close the thread quit pipe.
*/
-void relayd_close_thread_quit_pipe(void)
+void relayd_close_thread_quit_pipe()
{
if (thread_quit_pipe[0] != -1) {
(void) fd_tracker_util_pipe_close(the_fd_tracker, thread_quit_pipe);
*/
int create_named_thread_poll_set(struct lttng_poll_event *events, int size, const char *name)
{
- if (events == NULL || size == 0) {
+ if (events == nullptr || size == 0) {
return -1;
}
struct tracefile_array *tracefile_array_create(size_t count)
{
- struct tracefile_array *tfa = NULL;
+ struct tracefile_array *tfa = nullptr;
int i;
tfa = zmalloc<tracefile_array>();
free(tfa->tf);
}
free(tfa);
- return NULL;
+ return nullptr;
}
void tracefile_array_destroy(struct tracefile_array *tfa)
static char *create_output_path_auto(const char *path_name)
{
int ret;
- char *traces_path = NULL;
+ char *traces_path = nullptr;
const char *default_path;
default_path = utils_get_home_dir();
- if (default_path == NULL) {
+ if (default_path == nullptr) {
ERR("Home path not found.\n \
Please specify an output path using -o, --output PATH");
goto exit;
static char *create_output_path_noauto(const char *path_name)
{
int ret;
- char *traces_path = NULL;
+ char *traces_path = nullptr;
char *full_path;
full_path = utils_expand_path(opt_output_path);
{
LTTNG_ASSERT(path_name);
- if (opt_output_path == NULL) {
+ if (opt_output_path == nullptr) {
return create_output_path_auto(path_name);
} else {
return create_output_path_noauto(path_name);
#include <urcu/rculist.h>
-struct relay_viewer_session *viewer_session_create(void)
+struct relay_viewer_session *viewer_session_create()
{
struct relay_viewer_session *vsession;
struct lttng_trace_chunk *viewer_chunk;
lttng_trace_chunk_put(vsession->current_trace_chunk);
- vsession->current_trace_chunk = NULL;
+ vsession->current_trace_chunk = nullptr;
DBG("Copying relay session's current trace chunk to the viewer session");
if (!relay_session_trace_chunk) {
viewer_stream_put(vstream);
}
lttng_trace_chunk_put(vsession->current_trace_chunk);
- vsession->current_trace_chunk = NULL;
+ vsession->current_trace_chunk = nullptr;
viewer_session_detach(vsession, session);
}
{
if (vstream->stream_file.handle) {
fs_handle_close(vstream->stream_file.handle);
- vstream->stream_file.handle = NULL;
+ vstream->stream_file.handle = nullptr;
}
if (vstream->index_file) {
lttng_index_file_put(vstream->index_file);
- vstream->index_file = NULL;
+ vstream->index_file = nullptr;
}
if (vstream->stream) {
stream_put(vstream->stream);
- vstream->stream = NULL;
+ vstream->stream = nullptr;
}
lttng_trace_chunk_put(vstream->stream_file.trace_chunk);
- vstream->stream_file.trace_chunk = NULL;
+ vstream->stream_file.trace_chunk = nullptr;
}
static void viewer_stream_destroy(struct relay_viewer_stream *vstream)
struct lttng_trace_chunk *trace_chunk,
enum lttng_viewer_seek seek_t)
{
- struct relay_viewer_stream *vstream = NULL;
+ struct relay_viewer_stream *vstream = nullptr;
ASSERT_LOCKED(stream->lock);
vstream->stream_file.trace_chunk = trace_chunk;
vstream->path_name = lttng_strndup(stream->path_name, LTTNG_VIEWER_PATH_MAX);
- if (vstream->path_name == NULL) {
+ if (vstream->path_name == nullptr) {
PERROR("relay viewer path_name alloc");
goto error;
}
vstream->channel_name = lttng_strndup(stream->channel_name, LTTNG_VIEWER_NAME_MAX);
- if (vstream->channel_name == NULL) {
+ if (vstream->channel_name == nullptr) {
PERROR("relay viewer channel_name alloc");
goto error;
}
* If we never received an index for the current stream, delay
* the opening of the index, otherwise open it right now.
*/
- if (stream->index_file == NULL) {
- vstream->index_file = NULL;
+ if (stream->index_file == nullptr) {
+ vstream->index_file = nullptr;
} else if (vstream->stream_file.trace_chunk) {
const uint32_t connection_major = stream->trace->session->major;
const uint32_t connection_minor = stream->trace->session->minor;
&vstream->index_file);
if (chunk_status != LTTNG_TRACE_CHUNK_STATUS_OK) {
if (chunk_status == LTTNG_TRACE_CHUNK_STATUS_NO_FILE) {
- vstream->index_file = NULL;
+ vstream->index_file = nullptr;
} else {
goto error;
}
stream->channel_name,
stream->tracefile_size,
vstream->current_tracefile_id,
- NULL,
+ nullptr,
file_path,
sizeof(file_path));
if (ret < 0) {
viewer_stream_release_composite_objects(vstream);
viewer_stream_destroy(vstream);
}
- return NULL;
+ return nullptr;
}
static void viewer_stream_unpublish(struct relay_viewer_stream *vstream)
{
struct lttng_ht_node_u64 *node;
struct lttng_ht_iter iter;
- struct relay_viewer_stream *vstream = NULL;
+ struct relay_viewer_stream *vstream = nullptr;
rcu_read_lock();
lttng_ht_lookup(viewer_streams_ht, &id, &iter);
}
vstream = lttng::utils::container_of(node, &relay_viewer_stream::stream_n);
if (!viewer_stream_get(vstream)) {
- vstream = NULL;
+ vstream = nullptr;
}
end:
rcu_read_unlock();
{
if (vstream->index_file) {
lttng_index_file_put(vstream->index_file);
- vstream->index_file = NULL;
+ vstream->index_file = nullptr;
}
if (vstream->stream_file.handle) {
fs_handle_close(vstream->stream_file.handle);
- vstream->stream_file.handle = NULL;
+ vstream->stream_file.handle = nullptr;
}
}
return ret;
}
-void print_viewer_streams(void)
+void print_viewer_streams()
{
struct lttng_ht_iter iter;
struct relay_viewer_stream *vstream;
work_item->client_list,
work_item->trigger,
work_item->evaluation,
- work_item->object_creds.is_set ? &(work_item->object_creds.value) : NULL,
+ work_item->object_creds.is_set ? &(work_item->object_creds.value) : nullptr,
client_handle_transmission_status,
executor);
}
}
cmd_ret = (lttng_error_code) cmd_rotate_session(
- session, NULL, false, LTTNG_TRACE_CHUNK_COMMAND_TYPE_MOVE_TO_COMPLETED);
+ session, nullptr, false, LTTNG_TRACE_CHUNK_COMMAND_TYPE_MOVE_TO_COMPLETED);
switch (cmd_ret) {
case LTTNG_OK:
DBG("Successfully started rotation of session `%s` on behalf of trigger `%s`",
/* Execute item only if a trigger is registered. */
lttng_trigger_lock(work_item->trigger);
if (!lttng_trigger_is_registered(work_item->trigger)) {
- const char *trigger_name = NULL;
+ const char *trigger_name = nullptr;
uid_t trigger_owner_uid;
enum lttng_trigger_status trigger_status;
rcu_unregister_thread();
health_unregister(the_health_sessiond);
- return NULL;
+ return nullptr;
}
static bool shutdown_action_executor_thread(void *_data)
}
CDS_INIT_LIST_HEAD(&executor->work.list);
- pthread_cond_init(&executor->work.cond, NULL);
- pthread_mutex_init(&executor->work.lock, NULL);
+ pthread_cond_init(&executor->work.cond, nullptr);
+ pthread_mutex_init(&executor->work.lock, nullptr);
executor->notification_thread_handle = handle;
executor->thread = lttng_thread_create(THREAD_NAME,
/* Ownership transferred to the work item. */
work_item->evaluation = evaluation;
- evaluation = NULL;
+ evaluation = nullptr;
work_item->client_list = client_list;
work_item->object_creds.is_set = !!object_creds;
{
int ret = 0;
enum lttng_action_type type = lttng_action_get_type(action);
- const char *session_name = NULL;
+ const char *session_name = nullptr;
enum lttng_action_status status;
struct action_work_subitem subitem = {
- .action = NULL,
+ .action = nullptr,
.context = {
.session_id = LTTNG_OPTIONAL_INIT_UNSET,
},
LTTNG_ASSERT(status == LTTNG_ACTION_STATUS_OK);
for (i = 0; i < count; i++) {
- struct lttng_action *inner_action = NULL;
+ struct lttng_action *inner_action = nullptr;
inner_action = lttng_action_list_borrow_mutable_at_index(action, i);
LTTNG_ASSERT(inner_action);
* now we leave the decision to skip to the action executor for sake of
* simplicity and consistency.
*/
- if (session_name != NULL) {
+ if (session_name != nullptr) {
uint64_t session_id;
/*
/*
* Create and init socket from uri.
*/
-static struct lttcomm_sock *init_tcp_socket(void)
+static struct lttcomm_sock *init_tcp_socket()
{
int ret;
- struct lttng_uri *uri = NULL;
- struct lttcomm_sock *sock = NULL;
+ struct lttng_uri *uri = nullptr;
+ struct lttcomm_sock *sock = nullptr;
unsigned int port;
bool bind_succeeded = false;
sock = lttcomm_alloc_sock_from_uri(uri);
uri_free(uri);
- if (sock == NULL) {
+ if (sock == nullptr) {
ERR("agent allocating TCP socket");
goto error;
}
if (sock) {
lttcomm_destroy_sock(sock);
}
- return NULL;
+ return nullptr;
}
/*
new_sock->fd);
*agent_app_socket = new_sock;
- new_sock = NULL;
+ new_sock = nullptr;
ret = 0;
goto end;
return ret;
}
-bool agent_tracing_is_enabled(void)
+bool agent_tracing_is_enabled()
{
int enabled;
goto error;
}
- while (1) {
+ while (true) {
DBG3("Manage agent polling");
/* Inifinite blocking call, waiting for transmission */
/* Activity on the registration socket. */
if (revents & LPOLLIN) {
struct agent_app_id new_app_id;
- struct agent_app *new_app = NULL;
+ struct agent_app *new_app = nullptr;
struct lttcomm_sock *new_app_socket;
int new_app_socket_fd;
continue;
}
new_app_socket_fd = new_app_socket->fd;
- new_app_socket = NULL;
+ new_app_socket = nullptr;
/*
* Since this is a command socket (write then
DBG("Cleaning up and stopping.");
rcu_thread_offline();
rcu_unregister_thread();
- return NULL;
+ return nullptr;
}
static bool shutdown_agent_management_thread(void *data)
free(notifiers);
}
-bool launch_agent_management_thread(void)
+bool launch_agent_management_thread()
{
struct thread_notifiers *notifiers;
struct lttng_thread *thread;
uint32_t nb_event;
size_t data_size;
uint32_t reply_ret_code;
- struct lttng_event *tmp_events = NULL;
- struct lttcomm_agent_list_reply *reply = NULL;
+ struct lttng_event *tmp_events = nullptr;
+ struct lttcomm_agent_list_reply *reply = nullptr;
struct lttcomm_agent_list_reply_hdr reply_hdr;
LTTNG_ASSERT(app);
static struct agent_app_ctx *create_app_ctx(const struct lttng_event_context *ctx)
{
- struct agent_app_ctx *agent_ctx = NULL;
+ struct agent_app_ctx *agent_ctx = nullptr;
if (!ctx) {
goto end;
agent_ctx->ctx_name = strdup(ctx->u.app_ctx.ctx_name);
if (!agent_ctx->provider_name || !agent_ctx->ctx_name) {
destroy_app_ctx(agent_ctx);
- agent_ctx = NULL;
+ agent_ctx = nullptr;
}
end:
return agent_ctx;
int ret;
size_t nbmem, count = 0;
struct agent_app *app;
- struct lttng_event *tmp_events = NULL;
+ struct lttng_event *tmp_events = nullptr;
struct lttng_ht_iter iter;
LTTNG_ASSERT(events);
lttng_ht_lookup(the_agent_apps_ht_by_sock, (void *) ((unsigned long) sock), &iter);
node = lttng_ht_iter_get_node_ulong(&iter);
- if (node == NULL) {
+ if (node == nullptr) {
goto error;
}
app = lttng::utils::container_of(node, &agent_app::node);
error:
DBG3("Agent app NOT found by sock %d.", sock);
- return NULL;
+ return nullptr;
}
/*
ret = agent_init(agt);
if (ret < 0) {
free(agt);
- agt = NULL;
+ agt = nullptr;
goto error;
}
struct lttng_bytecode *filter,
char *filter_expression)
{
- struct agent_event *event = NULL;
+ struct agent_event *event = nullptr;
DBG3("Agent create new event with name %s, loglevel type %d, \
loglevel value %d and filter %s",
int agent_add_context(const struct lttng_event_context *ctx, struct agent *agt)
{
int ret = LTTNG_OK;
- struct agent_app_ctx *agent_ctx = NULL;
+ struct agent_app_ctx *agent_ctx = nullptr;
LTTNG_ASSERT(ctx);
LTTNG_ASSERT(agt);
&key,
&iter.iter);
node = lttng_ht_iter_get_node_str(&iter);
- if (node == NULL) {
+ if (node == nullptr) {
goto error;
}
error:
DBG3("Agent event NOT found %s.", name);
- return NULL;
+ return nullptr;
}
/*
/*
* Allocate agent_apps_ht_by_sock.
*/
-int agent_app_ht_alloc(void)
+int agent_app_ht_alloc()
{
the_agent_apps_ht_by_sock = lttng_ht_new(0, LTTNG_HT_TYPE_ULONG);
return the_agent_apps_ht_by_sock ? 0 : -1;
/*
* Clean-up the agent app hash table and destroy it.
*/
-void agent_app_ht_clean(void)
+void agent_app_ht_clean()
{
struct lttng_ht_node_ulong *node;
struct lttng_ht_iter iter;
* Allocate the per-event notifier domain agent hash table. It is lazily
* populated as domains are used.
*/
-int agent_by_event_notifier_domain_ht_create(void)
+int agent_by_event_notifier_domain_ht_create()
{
the_trigger_agents_ht_by_domain = lttng_ht_new(0, LTTNG_HT_TYPE_U64);
return the_trigger_agents_ht_by_domain ? 0 : -1;
/*
* Clean-up the per-event notifier domain agent hash table and destroy it.
*/
-void agent_by_event_notifier_domain_ht_destroy(void)
+void agent_by_event_notifier_domain_ht_destroy()
{
struct lttng_ht_node_u64 *node;
struct lttng_ht_iter iter;
struct agent *agent_find_by_event_notifier_domain(enum lttng_domain_type domain_type)
{
- struct agent *agt = NULL;
+ struct agent *agt = nullptr;
struct lttng_ht_node_u64 *node;
struct lttng_ht_iter iter;
const uint64_t key = (uint64_t) domain_type;
/*
* Initialize global buffer per UID registry. Should only be called ONCE!.
*/
-void buffer_reg_init_uid_registry(void)
+void buffer_reg_init_uid_registry()
{
/* Should be called once. */
LTTNG_ASSERT(!buffer_registry_uid);
const char *shm_path)
{
int ret = 0;
- struct buffer_reg_uid *reg = NULL;
+ struct buffer_reg_uid *reg = nullptr;
LTTNG_ASSERT(regp);
{
struct lttng_ht_node_u64 *node;
struct lttng_ht_iter iter;
- struct buffer_reg_uid *reg = NULL, key;
+ struct buffer_reg_uid *reg = nullptr, key;
struct lttng_ht *ht = buffer_registry_uid;
ASSERT_RCU_READ_LOCKED();
/*
* Initialize global buffer per PID registry. Should only be called ONCE!.
*/
-void buffer_reg_init_pid_registry(void)
+void buffer_reg_init_pid_registry()
{
/* Should be called once. */
LTTNG_ASSERT(!buffer_registry_pid);
const char *shm_path)
{
int ret = 0;
- struct buffer_reg_pid *reg = NULL;
+ struct buffer_reg_pid *reg = nullptr;
LTTNG_ASSERT(regp);
{
struct lttng_ht_node_u64 *node;
struct lttng_ht_iter iter;
- struct buffer_reg_pid *reg = NULL;
+ struct buffer_reg_pid *reg = nullptr;
struct lttng_ht *ht = buffer_registry_pid;
DBG3("Buffer registry per PID find id: %" PRIu64, session_id);
uint64_t *consumer_chan_key)
{
struct lttng_ht_iter iter;
- struct buffer_reg_uid *uid_reg = NULL;
- struct buffer_reg_session *session_reg = NULL;
+ struct buffer_reg_uid *uid_reg = nullptr;
+ struct buffer_reg_session *session_reg = nullptr;
struct buffer_reg_channel *reg_chan;
int ret = -1;
reg->key = key;
CDS_INIT_LIST_HEAD(®->streams);
- pthread_mutex_init(®->stream_list_lock, NULL);
+ pthread_mutex_init(®->stream_list_lock, nullptr);
lttng_ht_node_init_u64(®->node, key);
*regp = reg;
{
struct lttng_ht_node_u64 *node;
struct lttng_ht_iter iter;
- struct buffer_reg_channel *chan = NULL;
+ struct buffer_reg_channel *chan = nullptr;
struct lttng_ht *ht;
LTTNG_ASSERT(reg);
{
int ret;
- ret = ust_app_release_object(NULL, regp->obj.ust);
+ ret = ust_app_release_object(nullptr, regp->obj.ust);
if (ret < 0 && ret != -EPIPE && ret != -LTTNG_UST_ERR_EXITING) {
ERR("Buffer reg stream release obj handle %d failed with ret %d",
regp->obj.ust->handle,
}
if (regp->obj.ust) {
- ret = ust_app_release_object(NULL, regp->obj.ust);
+ ret = ust_app_release_object(nullptr, regp->obj.ust);
if (ret < 0 && ret != -EPIPE && ret != -LTTNG_UST_ERR_EXITING) {
ERR("Buffer reg channel release obj handle %d failed with ret %d",
regp->obj.ust->handle,
/*
* Destroy per PID and UID registry hash table.
*/
-void buffer_reg_destroy_registries(void)
+void buffer_reg_destroy_registries()
{
DBG3("Buffer registry destroy all registry");
lttng_ht_destroy(buffer_registry_uid);
{
struct lttng_channel *chan;
const char *channel_name = DEFAULT_CHANNEL_NAME;
- struct lttng_channel_extended *extended_attr = NULL;
+ struct lttng_channel_extended *extended_attr = nullptr;
chan = zmalloc<lttng_channel>();
- if (chan == NULL) {
+ if (chan == nullptr) {
PERROR("zmalloc channel init");
goto error_alloc;
}
free(extended_attr);
free(chan);
error_alloc:
- return NULL;
+ return nullptr;
}
void channel_attr_destroy(struct lttng_channel *channel)
LTTNG_ASSERT(channel_name);
kchan = trace_kernel_get_channel_by_name(channel_name, ksession);
- if (kchan == NULL) {
+ if (kchan == nullptr) {
ret = LTTNG_ERR_KERN_CHAN_NOT_FOUND;
goto error;
}
int kernel_pipe)
{
enum lttng_error_code ret_code;
- struct lttng_channel *defattr = NULL;
+ struct lttng_channel *defattr = nullptr;
LTTNG_ASSERT(ksession);
/* Creating channel attributes if needed */
- if (attr == NULL) {
+ if (attr == nullptr) {
defattr = channel_new_default_attr(LTTNG_DOMAIN_KERNEL, LTTNG_BUFFER_GLOBAL);
- if (defattr == NULL) {
+ if (defattr == nullptr) {
ret_code = LTTNG_ERR_FATAL;
goto error;
}
enum lttng_buffer_type type)
{
enum lttng_error_code ret_code = LTTNG_OK;
- struct ltt_ust_channel *uchan = NULL;
- struct lttng_channel *defattr = NULL;
+ struct ltt_ust_channel *uchan = nullptr;
+ struct lttng_channel *defattr = nullptr;
enum lttng_domain_type domain = LTTNG_DOMAIN_UST;
bool chan_published = false;
LTTNG_ASSERT(usess);
/* Creating channel attributes if needed */
- if (attr == NULL) {
+ if (attr == nullptr) {
defattr = channel_new_default_attr(LTTNG_DOMAIN_UST, type);
- if (defattr == NULL) {
+ if (defattr == nullptr) {
ret_code = LTTNG_ERR_FATAL;
goto error;
}
/* Create UST channel */
uchan = trace_ust_create_channel(attr, domain);
- if (uchan == NULL) {
+ if (uchan == nullptr) {
ret_code = LTTNG_ERR_FATAL;
goto error;
}
struct lttng_channel *trace_ust_channel_to_lttng_channel(const struct ltt_ust_channel *uchan)
{
- struct lttng_channel *channel = NULL, *ret = NULL;
+ struct lttng_channel *channel = nullptr, *ret = nullptr;
channel = lttng_channel_create_internal();
if (!channel) {
lttng_channel_set_monitor_timer_interval(channel, uchan->monitor_timer_interval);
ret = channel;
- channel = NULL;
+ channel = nullptr;
end:
lttng_channel_destroy(channel);
int cmd_clear_session(struct ltt_session *session, int *sock_fd)
{
int ret = LTTNG_OK;
- struct cmd_clear_session_reply_context *reply_context = NULL;
+ struct cmd_clear_session_reply_context *reply_context = nullptr;
bool session_was_active = false;
struct ltt_kernel_session *ksession;
struct ltt_ust_session *usess;
* On success, ownership of reply_context has been
* passed to session_add_clear_notifier().
*/
- reply_context = NULL;
+ reply_context = nullptr;
*sock_fd = -1;
}
ret = cmd_rotate_session(
- session, NULL, true, LTTNG_TRACE_CHUNK_COMMAND_TYPE_DELETE);
+ session, nullptr, true, LTTNG_TRACE_CHUNK_COMMAND_TYPE_DELETE);
if (ret != LTTNG_OK) {
goto end;
}
}
if (session_was_active) {
/* Kernel tracing */
- if (ksession != NULL) {
+ if (ksession != nullptr) {
DBG("Start kernel tracing session \"%s\"", session->name);
ret = start_kernel_session(ksession);
if (ret != LTTNG_OK) {
sem_post(&thread_state.ready);
}
-static bool wait_thread_status(void)
+static bool wait_thread_status()
{
DBG("Waiting for client thread to be ready");
sem_wait(&thread_state.ready);
static int create_ust_session(struct ltt_session *session, const struct lttng_domain *domain)
{
int ret;
- struct ltt_ust_session *lus = NULL;
+ struct ltt_ust_session *lus = nullptr;
LTTNG_ASSERT(session);
LTTNG_ASSERT(domain);
DBG("Creating UST session");
lus = trace_ust_create_session(session->id);
- if (lus == NULL) {
+ if (lus == nullptr) {
ret = LTTNG_ERR_UST_SESS_FAIL;
goto error;
}
error:
free(lus);
- session->ust_session = NULL;
+ session->ust_session = nullptr;
return ret;
}
error:
trace_kernel_destroy_session(session->kernel_session);
- session->kernel_session = NULL;
+ session->kernel_session = nullptr;
error_create:
return ret;
}
ssize_t sock_recv_len;
enum lttng_error_code ret_code;
struct lttng_payload trigger_payload;
- struct lttng_trigger *trigger = NULL;
+ struct lttng_trigger *trigger = nullptr;
lttng_payload_init(&trigger_payload);
trigger_len = (size_t) cmd_ctx->lsm.u.trigger.length;
ssize_t sock_recv_len;
enum lttng_error_code ret_code;
struct lttng_payload query_payload;
- struct lttng_error_query *query = NULL;
+ struct lttng_error_query *query = nullptr;
lttng_payload_init(&query_payload);
query_len = (size_t) cmd_ctx->lsm.u.error_query.length;
ssize_t sock_recv_len;
enum lttng_error_code ret_code;
struct lttng_payload event_payload;
- struct lttng_event *local_event = NULL;
- char *local_filter_expression = NULL;
- struct lttng_bytecode *local_bytecode = NULL;
- struct lttng_event_exclusion *local_exclusion = NULL;
+ struct lttng_event *local_event = nullptr;
+ char *local_filter_expression = nullptr;
+ struct lttng_bytecode *local_bytecode = nullptr;
+ struct lttng_event_exclusion *local_exclusion = nullptr;
lttng_payload_init(&event_payload);
if (cmd_ctx->lsm.cmd_type == LTTCOMM_SESSIOND_COMMAND_ENABLE_EVENT) {
*out_exclusion = local_exclusion;
*out_filter_expression = local_filter_expression;
*out_bytecode = local_bytecode;
- local_event = NULL;
- local_exclusion = NULL;
- local_filter_expression = NULL;
- local_bytecode = NULL;
+ local_event = nullptr;
+ local_exclusion = nullptr;
+ local_filter_expression = nullptr;
+ local_bytecode = nullptr;
ret_code = LTTNG_OK;
ssize_t sock_recv_len;
enum lttng_error_code ret_code;
struct lttng_payload event_context_payload;
- struct lttng_event_context *context = NULL;
+ struct lttng_event_context *context = nullptr;
lttng_payload_init(&event_context_payload);
}
*out_event_context = context;
- context = NULL;
+ context = nullptr;
ret_code = LTTNG_OK;
end:
static int
setup_lttng_msg_no_cmd_header(struct command_ctx *cmd_ctx, void *payload_buf, size_t payload_len)
{
- return setup_lttng_msg(cmd_ctx, payload_buf, payload_len, NULL, 0);
+ return setup_lttng_msg(cmd_ctx, payload_buf, payload_len, nullptr, 0);
}
/*
* Check if the current kernel tracer supports the session rotation feature.
* Return 1 if it does, 0 otherwise.
*/
-static int check_rotate_compatible(void)
+static int check_rotate_compatible()
{
int ret = 1;
break;
default:
/* Setup lttng message with no payload */
- ret = setup_lttng_msg_no_cmd_header(cmd_ctx, NULL, 0);
+ ret = setup_lttng_msg_no_cmd_header(cmd_ctx, nullptr, 0);
if (ret < 0) {
/* This label does not try to unlock the session */
goto init_setup_error;
*/
session_lock_list();
cmd_ctx->session = session_find_by_name(cmd_ctx->lsm.session.name);
- if (cmd_ctx->session == NULL) {
+ if (cmd_ctx->session == nullptr) {
ret = LTTNG_ERR_SESS_NOT_FOUND;
goto error;
} else {
/* Need a session for kernel command */
if (need_tracing_session) {
- if (cmd_ctx->session->kernel_session == NULL) {
+ if (cmd_ctx->session->kernel_session == nullptr) {
ret = create_kernel_session(cmd_ctx->session);
if (ret != LTTNG_OK) {
ret = LTTNG_ERR_KERN_SESS_FAIL;
if (need_tracing_session) {
/* Create UST session if none exist. */
- if (cmd_ctx->session->ust_session == NULL) {
+ if (cmd_ctx->session->ust_session == nullptr) {
lttng_domain domain = cmd_ctx->lsm.domain;
ret = create_ust_session(cmd_ctx->session, &domain);
if (ret != LTTNG_OK) {
switch (cmd_ctx->lsm.cmd_type) {
case LTTCOMM_SESSIOND_COMMAND_ADD_CONTEXT:
{
- struct lttng_event_context *event_context = NULL;
+ struct lttng_event_context *event_context = nullptr;
const enum lttng_error_code ret_code =
receive_lttng_event_context(cmd_ctx, *sock, sock_error, &event_context);
}
uris = calloc<lttng_uri>(nb_uri);
- if (uris == NULL) {
+ if (uris == nullptr) {
ret = LTTNG_ERR_FATAL;
goto error;
}
case LTTCOMM_SESSIOND_COMMAND_LIST_DOMAINS:
{
ssize_t nb_dom;
- struct lttng_domain *domains = NULL;
+ struct lttng_domain *domains = nullptr;
nb_dom = cmd_list_domains(cmd_ctx->session, &domains);
if (nb_dom < 0) {
case LTTCOMM_SESSIOND_COMMAND_SNAPSHOT_LIST_OUTPUT:
{
ssize_t nb_output;
- struct lttng_snapshot_output *outputs = NULL;
+ struct lttng_snapshot_output *outputs = nullptr;
nb_output = cmd_snapshot_list_outputs(cmd_ctx->session, &outputs);
if (nb_output < 0) {
case LTTCOMM_SESSIOND_COMMAND_CREATE_SESSION_EXT:
{
struct lttng_dynamic_buffer payload;
- struct lttng_session_descriptor *return_descriptor = NULL;
+ struct lttng_session_descriptor *return_descriptor = nullptr;
lttng_dynamic_buffer_init(&payload);
ret = cmd_create_session(cmd_ctx, *sock, &return_descriptor);
}
case LTTCOMM_SESSIOND_COMMAND_LIST_TRIGGERS:
{
- struct lttng_triggers *return_triggers = NULL;
+ struct lttng_triggers *return_triggers = nullptr;
size_t original_payload_size;
size_t payload_size;
.uid = LTTNG_OPTIONAL_INIT_VALUE(cmd_ctx->creds.uid),
.gid = LTTNG_OPTIONAL_INIT_VALUE(cmd_ctx->creds.gid),
};
- struct lttng_error_query_results *results = NULL;
+ struct lttng_error_query_results *results = nullptr;
size_t original_payload_size;
size_t payload_size;
error:
if (cmd_ctx->reply_payload.buffer.size == 0) {
DBG("Missing llm header, creating one.");
- if (setup_lttng_msg_no_cmd_header(cmd_ctx, NULL, 0) < 0) {
+ if (setup_lttng_msg_no_cmd_header(cmd_ctx, nullptr, 0) < 0) {
goto setup_error;
}
}
if (cmd_ctx->session) {
session_unlock(cmd_ctx->session);
session_put(cmd_ctx->session);
- cmd_ctx->session = NULL;
+ cmd_ctx->session = nullptr;
}
if (need_tracing_session) {
session_unlock_list();
return ret;
}
-static int create_client_sock(void)
+static int create_client_sock()
{
int ret, client_sock;
is_root = (getuid() == 0);
- pthread_cleanup_push(thread_init_cleanup, NULL);
+ pthread_cleanup_push(thread_init_cleanup, nullptr);
rcu_register_thread();
health_code_update();
- while (1) {
+ while (true) {
const struct cmd_completion_handler *cmd_completion_handler;
cmd_ctx.creds.uid = UINT32_MAX;
cmd_ctx.creds.gid = UINT32_MAX;
cmd_ctx.creds.pid = 0;
- cmd_ctx.session = NULL;
+ cmd_ctx.session = nullptr;
lttng_payload_clear(&cmd_ctx.reply_payload);
cmd_ctx.lttng_msg_size = 0;
DBG("Client thread dying");
lttng_payload_reset(&cmd_ctx.reply_payload);
rcu_unregister_thread();
- return NULL;
+ return nullptr;
}
static bool shutdown_client_thread(void *thread_data)
return notify_thread_pipe(write_fd) == 1;
}
-struct lttng_thread *launch_client_thread(void)
+struct lttng_thread *launch_client_thread()
{
bool thread_running;
struct lttng_pipe *client_quit_pipe;
- struct lttng_thread *thread = NULL;
+ struct lttng_thread *thread = nullptr;
int client_sock_fd = -1;
sem_init(&thread_state.ready, 0, 0);
}
/* The client thread now owns the client sock fd and the quit pipe. */
client_sock_fd = -1;
- client_quit_pipe = NULL;
+ client_quit_pipe = nullptr;
/*
* This thread is part of the threads that need to be fully
}
lttng_thread_put(thread);
cleanup_client_thread(client_quit_pipe);
- return NULL;
+ return nullptr;
}
static int build_network_session_path(char *dst, size_t size, struct ltt_session *session)
{
int ret, kdata_port, udata_port;
- struct lttng_uri *kuri = NULL, *uuri = NULL, *uri = NULL;
+ struct lttng_uri *kuri = nullptr, *uuri = nullptr, *uri = nullptr;
char tmp_uurl[PATH_MAX], tmp_urls[PATH_MAX];
LTTNG_ASSERT(session);
udata_port = session->ust_session->consumer->dst.net.data.port;
}
- if (uuri == NULL && kuri == NULL) {
+ if (uuri == nullptr && kuri == nullptr) {
uri = &session->consumer->dst.net.control;
kdata_port = session->consumer->dst.net.data.port;
} else if (kuri && uuri) {
} else {
uri = kuri;
}
- } else if (kuri && uuri == NULL) {
+ } else if (kuri && uuri == nullptr) {
uri = kuri;
- } else if (uuri && kuri == NULL) {
+ } else if (uuri && kuri == nullptr) {
uri = uuri;
}
tmp_event->loglevel_type = event->loglevel_type;
ret = lttng_event_serialize(
- tmp_event, 0, NULL, event->filter_expression, 0, NULL, reply_payload);
+ tmp_event, 0, nullptr, event->filter_expression, 0, nullptr, reply_payload);
lttng_event_destroy(tmp_event);
if (ret) {
ret_code = LTTNG_ERR_FATAL;
lttng_ht_lookup(ust_global->channels, (void *) channel_name, &iter);
node = lttng_ht_iter_get_node_str(&iter);
- if (node == NULL) {
+ if (node == nullptr) {
ret_code = LTTNG_ERR_UST_CHAN_NOT_FOUND;
goto error;
}
DBG3("Listing UST global %d events", *nb_events);
cds_lfht_for_each_entry (uchan->events->ht, &iter.iter, uevent, node.node) {
- struct lttng_event *tmp_event = NULL;
+ struct lttng_event *tmp_event = nullptr;
if (uevent->internal) {
/* This event should remain hidden from clients */
ret = lttng_event_serialize(tmp_event,
uevent->exclusion ? uevent->exclusion->count : 0,
uevent->exclusion ? (char **) uevent->exclusion->names :
- NULL,
+ nullptr,
uevent->filter_expression,
0,
- NULL,
+ nullptr,
reply_payload);
lttng_event_destroy(tmp_event);
if (ret) {
assert(reply_payload);
kchan = trace_kernel_get_channel_by_name(channel_name, kernel_session);
- if (kchan == NULL) {
+ if (kchan == nullptr) {
ret_code = LTTNG_ERR_KERN_CHAN_NOT_FOUND;
goto end;
}
}
ret = lttng_event_serialize(
- tmp_event, 0, NULL, event->filter_expression, 0, NULL, reply_payload);
+ tmp_event, 0, nullptr, event->filter_expression, 0, nullptr, reply_payload);
lttng_event_destroy(tmp_event);
if (ret) {
ret_code = LTTNG_ERR_FATAL;
LTTNG_ASSERT(uri);
- if (consumer == NULL) {
+ if (consumer == nullptr) {
DBG("No consumer detected. Don't add URI. Stopping.");
ret_code = LTTNG_ERR_NO_CONSUMER;
goto error;
rcu_read_lock();
- if (session->consumer_fds_sent == 0 && session->consumer != NULL) {
+ if (session->consumer_fds_sent == 0 && session->consumer != nullptr) {
cds_lfht_for_each_entry (
session->consumer->socks->ht, &iter.iter, socket, node.node) {
pthread_mutex_lock(socket->lock);
bool session_name_contains_creation_time)
{
int ret;
- struct lttcomm_relayd_sock *rsock = NULL;
+ struct lttcomm_relayd_sock *rsock = nullptr;
enum lttng_error_code status;
/* Connect to relayd and make version check if uri is the control. */
session->hostname,
session->base_path,
session->live_timer,
- current_chunk_id.is_set ? ¤t_chunk_id.value : NULL,
+ current_chunk_id.is_set ? ¤t_chunk_id.value : nullptr,
session->creation_time,
session->name_contains_creation_time);
pthread_mutex_unlock(socket->lock);
session->hostname,
session->base_path,
session->live_timer,
- current_chunk_id.is_set ? ¤t_chunk_id.value : NULL,
+ current_chunk_id.is_set ? ¤t_chunk_id.value : nullptr,
session->creation_time,
session->name_contains_creation_time);
pthread_mutex_unlock(socket->lock);
struct ltt_kernel_channel *kchan;
/* Open kernel metadata */
- if (ksess->metadata == NULL && ksess->output_traces) {
+ if (ksess->metadata == nullptr && ksess->output_traces) {
ret = kernel_open_metadata(ksess);
if (ret < 0) {
ret = LTTNG_ERR_KERN_META_FAIL;
chan_ht = usess->domain_global.channels;
uchan = trace_ust_find_channel_by_name(chan_ht, channel_name);
- if (uchan == NULL) {
+ if (uchan == nullptr) {
ret = LTTNG_ERR_UST_CHAN_NOT_FOUND;
goto error;
}
int ret;
size_t channel_len;
ssize_t sock_recv_len;
- struct lttng_channel *channel = NULL;
+ struct lttng_channel *channel = nullptr;
struct lttng_buffer_view view;
struct lttng_dynamic_buffer channel_buffer;
const struct lttng_domain command_domain = cmd_ctx->lsm.domain;
struct ltt_ust_session *usess = session->ust_session;
struct lttng_ht *chan_ht;
size_t len;
- struct lttng_channel *attr = NULL;
+ struct lttng_channel *attr = nullptr;
LTTNG_ASSERT(session);
LTTNG_ASSERT(_attr);
len = lttng_strnlen(attr->name, sizeof(attr->name));
/* Validate channel name */
- if (attr->name[0] == '.' || memchr(attr->name, '/', len) != NULL) {
+ if (attr->name[0] == '.' || memchr(attr->name, '/', len) != nullptr) {
ret_code = LTTNG_ERR_INVALID_CHANNEL_NAME;
goto end;
}
struct ltt_kernel_channel *kchan;
kchan = trace_kernel_get_channel_by_name(attr->name, session->kernel_session);
- if (kchan == NULL) {
+ if (kchan == nullptr) {
/*
* Don't try to create a channel if the session has been started at
* some point in time before. The tracer does not allow it.
chan_ht = usess->domain_global.channels;
uchan = trace_ust_find_channel_by_name(chan_ht, attr->name);
- if (uchan == NULL) {
+ if (uchan == nullptr) {
/*
* Don't try to create a channel if the session has been started at
* some point in time before. The tracer does not allow it.
}
kchan = trace_kernel_get_channel_by_name(channel_name, ksess);
- if (kchan == NULL) {
+ if (kchan == nullptr) {
ret = LTTNG_ERR_KERN_CHAN_NOT_FOUND;
goto error_unlock;
}
case LTTNG_EVENT_FUNCTION:
case LTTNG_EVENT_FUNCTION_ENTRY: /* fall-through */
if (event_name[0] == '\0') {
- ret = event_kernel_disable_event(kchan, NULL, event->type);
+ ret = event_kernel_disable_event(kchan, nullptr, event->type);
} else {
ret = event_kernel_disable_event(kchan, event_name, event->type);
}
}
uchan = trace_ust_find_channel_by_name(usess->domain_global.channels, channel_name);
- if (uchan == NULL) {
+ if (uchan == nullptr) {
ret = LTTNG_ERR_UST_CHAN_NOT_FOUND;
goto error_unlock;
}
if (session->kernel_session->channel_count == 0) {
/* Create default channel */
- ret = channel_kernel_create(session->kernel_session, NULL, kwpipe);
+ ret = channel_kernel_create(session->kernel_session, nullptr, kwpipe);
if (ret != LTTNG_OK) {
goto error;
}
struct lttng_channel *attr;
/* Create default channel */
attr = channel_new_default_attr(domain, usess->buffer_type);
- if (attr == NULL) {
+ if (attr == nullptr) {
ret = LTTNG_ERR_FATAL;
goto error;
}
bool internal_event)
{
int ret = 0, channel_created = 0;
- struct lttng_channel *attr = NULL;
+ struct lttng_channel *attr = nullptr;
LTTNG_ASSERT(session);
LTTNG_ASSERT(event);
}
kchan = trace_kernel_get_channel_by_name(channel_name, session->kernel_session);
- if (kchan == NULL) {
+ if (kchan == nullptr) {
attr = channel_new_default_attr(LTTNG_DOMAIN_KERNEL, LTTNG_BUFFER_GLOBAL);
- if (attr == NULL) {
+ if (attr == nullptr) {
ret = LTTNG_ERR_FATAL;
goto error;
}
/* Get the newly created kernel channel pointer */
kchan = trace_kernel_get_channel_by_name(channel_name, session->kernel_session);
- if (kchan == NULL) {
+ if (kchan == nullptr) {
/* This sould not happen... */
ret = LTTNG_ERR_FATAL;
goto error;
switch (event->type) {
case LTTNG_EVENT_ALL:
{
- char *filter_expression_a = NULL;
- struct lttng_bytecode *filter_a = NULL;
+ char *filter_expression_a = nullptr;
+ struct lttng_bytecode *filter_a = nullptr;
/*
* We need to duplicate filter_expression and filter,
event->type = LTTNG_EVENT_TRACEPOINT; /* Hack */
ret = event_kernel_enable_event(kchan, event, filter_expression, filter);
/* We have passed ownership */
- filter_expression = NULL;
- filter = NULL;
+ filter_expression = nullptr;
+ filter = nullptr;
if (ret != LTTNG_OK) {
if (channel_created) {
/* Let's not leak a useless channel. */
ret = event_kernel_enable_event(
kchan, event, filter_expression_a, filter_a);
/* We have passed ownership */
- filter_expression_a = NULL;
- filter_a = NULL;
+ filter_expression_a = nullptr;
+ filter_a = nullptr;
if (ret != LTTNG_OK) {
goto error;
}
case LTTNG_EVENT_TRACEPOINT:
ret = event_kernel_enable_event(kchan, event, filter_expression, filter);
/* We have passed ownership */
- filter_expression = NULL;
- filter = NULL;
+ filter_expression = nullptr;
+ filter = nullptr;
if (ret != LTTNG_OK) {
if (channel_created) {
/* Let's not leak a useless channel. */
case LTTNG_EVENT_SYSCALL:
ret = event_kernel_enable_event(kchan, event, filter_expression, filter);
/* We have passed ownership */
- filter_expression = NULL;
- filter = NULL;
+ filter_expression = nullptr;
+ filter = nullptr;
if (ret != LTTNG_OK) {
goto error;
}
/* Get channel from global UST domain */
uchan = trace_ust_find_channel_by_name(usess->domain_global.channels, channel_name);
- if (uchan == NULL) {
+ if (uchan == nullptr) {
/* Create default channel */
attr = channel_new_default_attr(LTTNG_DOMAIN_UST, usess->buffer_type);
- if (attr == NULL) {
+ if (attr == nullptr) {
ret = LTTNG_ERR_FATAL;
goto error;
}
ret = event_ust_enable_tracepoint(
usess, uchan, event, filter_expression, filter, exclusion, internal_event);
/* We have passed ownership */
- filter_expression = NULL;
- filter = NULL;
- exclusion = NULL;
+ filter_expression = nullptr;
+ filter = nullptr;
+ exclusion = nullptr;
if (ret == LTTNG_ERR_UST_EVENT_ENABLED) {
goto already_enabled;
} else if (ret != LTTNG_OK) {
}
{
- char *filter_expression_copy = NULL;
- struct lttng_bytecode *filter_copy = NULL;
+ char *filter_expression_copy = nullptr;
+ struct lttng_bytecode *filter_copy = nullptr;
if (filter) {
const size_t filter_size =
&uevent,
filter_expression_copy,
filter_copy,
- NULL,
+ nullptr,
wpipe);
}
} else {
ret = event_agent_enable(usess, agt, event, filter, filter_expression);
}
- filter = NULL;
- filter_expression = NULL;
+ filter = nullptr;
+ filter_expression = nullptr;
if (ret != LTTNG_OK) {
goto error;
}
exclusion,
wpipe,
false);
- filter_expression = NULL;
- bytecode = NULL;
- exclusion = NULL;
+ filter_expression = nullptr;
+ bytecode = nullptr;
+ exclusion = nullptr;
return ret;
}
enum lttng_error_code ret_code;
int ret;
ssize_t i, nb_events = 0;
- struct lttng_event *events = NULL;
+ struct lttng_event *events = nullptr;
struct lttcomm_list_command_header reply_command_header = {};
size_t reply_command_header_offset;
}
for (i = 0; i < nb_events; i++) {
- ret = lttng_event_serialize(&events[i], 0, NULL, NULL, 0, NULL, reply_payload);
+ ret = lttng_event_serialize(
+ &events[i], 0, nullptr, nullptr, 0, nullptr, reply_payload);
if (ret) {
ret_code = LTTNG_ERR_NOMEM;
goto error;
enum lttng_error_code ret_code;
int ret;
unsigned int i, nb_fields;
- struct lttng_event_field *fields = NULL;
+ struct lttng_event_field *fields = nullptr;
struct lttcomm_list_command_header reply_command_header = {};
size_t reply_command_header_offset;
enum lttng_error_code ret_code;
ssize_t nb_events, i;
int ret;
- struct lttng_event *events = NULL;
+ struct lttng_event *events = nullptr;
struct lttcomm_list_command_header reply_command_header = {};
size_t reply_command_header_offset;
}
for (i = 0; i < nb_events; i++) {
- ret = lttng_event_serialize(&events[i], 0, NULL, NULL, 0, NULL, reply_payload);
+ ret = lttng_event_serialize(
+ &events[i], 0, nullptr, nullptr, 0, nullptr, reply_payload);
if (ret) {
ret_code = LTTNG_ERR_NOMEM;
goto end;
struct lttng_trace_chunk *trace_chunk;
DBG("Creating initial trace chunk of session \"%s\"", session->name);
- trace_chunk = session_create_new_trace_chunk(session, NULL, NULL, NULL);
+ trace_chunk =
+ session_create_new_trace_chunk(session, nullptr, nullptr, nullptr);
if (!trace_chunk) {
ret = LTTNG_ERR_CREATE_DIR_FAIL;
goto error;
}
LTTNG_ASSERT(!session->current_trace_chunk);
ret = (lttng_error_code) session_set_trace_chunk(
- session, trace_chunk, NULL);
+ session, trace_chunk, nullptr);
lttng_trace_chunk_put(trace_chunk);
if (ret) {
ret = LTTNG_ERR_CREATE_TRACE_CHUNK_FAIL_CONSUMER;
* rotation should happen on reception of the command.
*/
ret = (lttng_error_code) cmd_rotate_session(
- session, NULL, true, LTTNG_TRACE_CHUNK_COMMAND_TYPE_NO_OPERATION);
+ session, nullptr, true, LTTNG_TRACE_CHUNK_COMMAND_TYPE_NO_OPERATION);
if (ret != LTTNG_OK) {
goto error;
}
}
/* Kernel tracing */
- if (ksession != NULL) {
+ if (ksession != nullptr) {
DBG("Start kernel tracing session %s", session->name);
ret = (lttng_error_code) start_kernel_session(ksession);
if (ret != LTTNG_OK) {
continue;
}
- if (session->base_path != NULL) {
+ if (session->base_path != nullptr) {
free(session->base_path);
- session->base_path = NULL;
+ session->base_path = nullptr;
}
/* Set session base_path */
switch (session_type) {
case LTTNG_SESSION_DESCRIPTOR_TYPE_SNAPSHOT:
{
- struct snapshot_output *new_output = NULL;
+ struct snapshot_output *new_output = nullptr;
new_output = snapshot_output_alloc();
if (!new_output) {
ret = snapshot_output_init_with_uri(session,
DEFAULT_SNAPSHOT_MAX_SIZE,
- NULL,
+ nullptr,
uris,
uri_count,
session->consumer,
int ret;
enum lttng_error_code ret_code;
const char *session_name;
- struct ltt_session *new_session = NULL;
+ struct ltt_session *new_session = nullptr;
enum lttng_session_descriptor_status descriptor_status;
session_lock_list();
case LTTNG_SESSION_DESCRIPTOR_STATUS_OK:
break;
case LTTNG_SESSION_DESCRIPTOR_STATUS_UNSET:
- session_name = NULL;
+ session_name = nullptr;
break;
default:
ret_code = LTTNG_ERR_INVALID;
(void) notification_thread_command_remove_session(
the_notification_thread_handle, session->id);
},
- NULL);
+ nullptr);
if (ret) {
PERROR("Failed to add notification thread command to session's destroy notifiers: session name = %s",
new_session->name);
* not auto-generated.
*/
ret_code = lttng_session_descriptor_set_default_output(
- descriptor, session_name ? &new_session->creation_time : NULL, home_path);
+ descriptor,
+ session_name ? &new_session->creation_time : nullptr,
+ home_path);
if (ret_code != LTTNG_OK) {
goto end;
}
struct lttng_dynamic_buffer payload;
struct lttng_buffer_view home_dir_view;
struct lttng_buffer_view session_descriptor_view;
- struct lttng_session_descriptor *session_descriptor = NULL;
+ struct lttng_session_descriptor *session_descriptor = nullptr;
enum lttng_error_code ret_code;
lttng_dynamic_buffer_init(&payload);
* Sets the descriptor's auto-generated properties (name, output) if
* needed.
*/
- ret_code =
- cmd_create_session_from_descriptor(session_descriptor,
- &cmd_ctx->creds,
- home_dir_view.size ? home_dir_view.data : NULL);
+ ret_code = cmd_create_session_from_descriptor(session_descriptor,
+ &cmd_ctx->creds,
+ home_dir_view.size ? home_dir_view.data :
+ nullptr);
if (ret_code != LTTNG_OK) {
goto error;
}
ret_code = LTTNG_OK;
*return_descriptor = session_descriptor;
- session_descriptor = NULL;
+ session_descriptor = nullptr;
error:
lttng_dynamic_buffer_reset(&payload);
lttng_session_descriptor_destroy(session_descriptor);
(cmd_destroy_session_reply_context *) _reply_context;
struct lttng_dynamic_buffer payload;
struct lttcomm_session_destroy_command_header cmd_header;
- struct lttng_trace_archive_location *location = NULL;
+ struct lttng_trace_archive_location *location = nullptr;
struct lttcomm_lttng_msg llm = {
.cmd_type = LTTCOMM_SESSIOND_COMMAND_DESTROY_SESSION,
.ret_code = reply_context->destruction_status,
{
int ret;
enum lttng_error_code destruction_last_error = LTTNG_OK;
- struct cmd_destroy_session_reply_context *reply_context = NULL;
+ struct cmd_destroy_session_reply_context *reply_context = nullptr;
if (sock_fd) {
reply_context = zmalloc<cmd_destroy_session_reply_context>();
* occurred during the session's lifetime.
*/
ret = cmd_rotate_session(
- session, NULL, false, LTTNG_TRACE_CHUNK_COMMAND_TYPE_MOVE_TO_COMPLETED);
+ session, nullptr, false, LTTNG_TRACE_CHUNK_COMMAND_TYPE_MOVE_TO_COMPLETED);
if (ret != LTTNG_OK) {
ERR("Failed to perform an implicit rotation as part of the destruction of session \"%s\": %s",
session->name,
* place.
*/
ret = cmd_rotate_session(
- session, NULL, true, LTTNG_TRACE_CHUNK_COMMAND_TYPE_NO_OPERATION);
+ session, nullptr, true, LTTNG_TRACE_CHUNK_COMMAND_TYPE_NO_OPERATION);
/*
* Rotation operations may not be supported by the kernel
* tracer. Hence, do not consider this implicit rotation as
struct consumer_data *cdata)
{
int ret, sock;
- struct consumer_socket *socket = NULL;
+ struct consumer_socket *socket = nullptr;
LTTNG_ASSERT(session);
LTTNG_ASSERT(cdata);
cdata->cmd_sock = sock;
socket = consumer_allocate_socket(&cdata->cmd_sock);
- if (socket == NULL) {
+ if (socket == nullptr) {
ret = close(sock);
if (ret < 0) {
PERROR("close register consumer");
}
socket->lock = zmalloc<pthread_mutex_t>();
- if (socket->lock == NULL) {
+ if (socket->lock == nullptr) {
PERROR("zmalloc pthread mutex");
ret = LTTNG_ERR_FATAL;
goto error;
}
- pthread_mutex_init(socket->lock, NULL);
+ pthread_mutex_init(socket->lock, nullptr);
socket->registered = 1;
rcu_read_lock();
struct agent *agt;
struct lttng_ht_iter iter;
- if (session->kernel_session != NULL) {
+ if (session->kernel_session != nullptr) {
DBG3("Listing domains found kernel domain");
nb_dom++;
}
- if (session->ust_session != NULL) {
+ if (session->ust_session != nullptr) {
DBG3("Listing domains found UST global domain");
nb_dom++;
}
*domains = calloc<lttng_domain>(nb_dom);
- if (*domains == NULL) {
+ if (*domains == nullptr) {
ret = LTTNG_ERR_FATAL;
goto error;
}
- if (session->kernel_session != NULL) {
+ if (session->kernel_session != nullptr) {
(*domains)[index].type = LTTNG_DOMAIN_KERNEL;
/* Kernel session buffer type is always GLOBAL */
index++;
}
- if (session->ust_session != NULL) {
+ if (session->ust_session != nullptr) {
(*domains)[index].type = LTTNG_DOMAIN_UST;
(*domains)[index].buf_type = session->ust_session->buffer_type;
index++;
{
/* Kernel channels */
struct ltt_kernel_channel *kchan;
- if (session->kernel_session != NULL) {
+ if (session->kernel_session != nullptr) {
cds_list_for_each_entry (
kchan, &session->kernel_session->channel_list.head, list) {
uint64_t discarded_events, lost_packets;
uchan,
node.node) {
uint64_t discarded_events = 0, lost_packets = 0;
- struct lttng_channel *channel = NULL;
+ struct lttng_channel *channel = nullptr;
struct lttng_channel_extended *extended;
channel = trace_ust_channel_to_lttng_channel(uchan);
switch (domain) {
case LTTNG_DOMAIN_KERNEL:
- if (session->kernel_session != NULL) {
+ if (session->kernel_session != nullptr) {
ret_code = list_lttng_kernel_events(
channel_name, session->kernel_session, reply_payload, &nb_events);
}
break;
case LTTNG_DOMAIN_UST:
{
- if (session->ust_session != NULL) {
+ if (session->ust_session != nullptr) {
ret_code =
list_lttng_ust_global_events(channel_name,
&session->ust_session->domain_global,
int cmd_snapshot_del_output(struct ltt_session *session, const struct lttng_snapshot_output *output)
{
int ret;
- struct snapshot_output *sout = NULL;
+ struct snapshot_output *sout = nullptr;
LTTNG_ASSERT(session);
LTTNG_ASSERT(output);
struct lttng_snapshot_output **outputs)
{
int ret, idx = 0;
- struct lttng_snapshot_output *list = NULL;
+ struct lttng_snapshot_output *list = nullptr;
struct lttng_ht_iter iter;
struct snapshot_output *output;
}
*outputs = list;
- list = NULL;
+ list = nullptr;
ret = session->snapshot.nb_output;
error:
rcu_read_unlock();
lttng_trigger_get(trigger);
*return_trigger = trigger;
/* Ownership of trigger was transferred to caller. */
- trigger = NULL;
+ trigger = nullptr;
}
end:
return ret_code;
const char *trigger_name;
uid_t trigger_owner;
enum lttng_trigger_status trigger_status;
- struct lttng_trigger *sessiond_trigger = NULL;
+ struct lttng_trigger *sessiond_trigger = nullptr;
trigger_status = lttng_trigger_get_name(trigger, &trigger_name);
trigger_name = trigger_status == LTTNG_TRIGGER_STATUS_OK ? trigger_name : "(anonymous)";
{
int ret;
enum lttng_error_code ret_code;
- struct lttng_triggers *triggers = NULL;
+ struct lttng_triggers *triggers = nullptr;
/* Get the set of triggers from the notification thread. */
ret_code = notification_thread_command_list_triggers(
}
*return_triggers = triggers;
- triggers = NULL;
+ triggers = nullptr;
ret_code = LTTNG_OK;
end:
lttng_triggers_destroy(triggers);
{
enum lttng_error_code ret_code;
const struct lttng_trigger *query_target_trigger;
- const struct lttng_action *query_target_action = NULL;
- struct lttng_trigger *matching_trigger = NULL;
+ const struct lttng_action *query_target_action = nullptr;
+ struct lttng_trigger *matching_trigger = nullptr;
const char *trigger_name;
uid_t trigger_owner;
enum lttng_trigger_status trigger_status;
- struct lttng_error_query_results *results = NULL;
+ struct lttng_error_query_results *results = nullptr;
switch (lttng_error_query_get_target_type(query)) {
case LTTNG_ERROR_QUERY_TARGET_TYPE_TRIGGER:
}
/* No longer needed. */
- query_target_trigger = NULL;
+ query_target_trigger = nullptr;
if (lttng_error_query_get_target_type(query) == LTTNG_ERROR_QUERY_TARGET_TYPE_ACTION) {
/* Get the sessiond-side version of the target action. */
}
*_results = results;
- results = NULL;
+ results = nullptr;
ret_code = LTTNG_OK;
end:
lttng_trigger_put(matching_trigger);
session->hostname,
base_path,
session->live_timer,
- current_chunk_id.is_set ? ¤t_chunk_id.value : NULL,
+ current_chunk_id.is_set ? ¤t_chunk_id.value : nullptr,
session->creation_time,
session->name_contains_creation_time);
pthread_mutex_unlock(socket->lock);
int ret;
enum lttng_error_code ret_code = LTTNG_OK;
struct lttng_trace_chunk *snapshot_trace_chunk;
- struct consumer_output *original_ust_consumer_output = NULL;
- struct consumer_output *original_kernel_consumer_output = NULL;
- struct consumer_output *snapshot_ust_consumer_output = NULL;
- struct consumer_output *snapshot_kernel_consumer_output = NULL;
+ struct consumer_output *original_ust_consumer_output = nullptr;
+ struct consumer_output *original_kernel_consumer_output = nullptr;
+ struct consumer_output *snapshot_ust_consumer_output = nullptr;
+ struct consumer_output *snapshot_kernel_consumer_output = nullptr;
ret = snprintf(snapshot_chunk_name,
sizeof(snapshot_chunk_name),
goto error;
}
LTTNG_ASSERT(!session->current_trace_chunk);
- ret = session_set_trace_chunk(session, snapshot_trace_chunk, NULL);
+ ret = session_set_trace_chunk(session, snapshot_trace_chunk, nullptr);
lttng_trace_chunk_put(snapshot_trace_chunk);
- snapshot_trace_chunk = NULL;
+ snapshot_trace_chunk = nullptr;
if (ret) {
ERR("Failed to set temporary trace chunk to record a snapshot of session \"%s\"",
session->name);
}
error_close_trace_chunk:
- if (session_set_trace_chunk(session, NULL, &snapshot_trace_chunk)) {
+ if (session_set_trace_chunk(session, nullptr, &snapshot_trace_chunk)) {
ERR("Failed to release the current trace chunk of session \"%s\"", session->name);
ret_code = LTTNG_ERR_UNK;
}
if (session_close_trace_chunk(session,
snapshot_trace_chunk,
LTTNG_TRACE_CHUNK_COMMAND_TYPE_NO_OPERATION,
- NULL)) {
+ nullptr)) {
/*
* Don't goto end; make sure the chunk is closed for the session
* to allow future snapshots.
}
lttng_trace_chunk_put(snapshot_trace_chunk);
- snapshot_trace_chunk = NULL;
+ snapshot_trace_chunk = nullptr;
error:
if (original_ust_consumer_output) {
session->ust_session->consumer = original_ust_consumer_output;
int ret;
unsigned int snapshot_success = 0;
char datetime[16];
- struct snapshot_output *tmp_output = NULL;
+ struct snapshot_output *tmp_output = nullptr;
LTTNG_ASSERT(session);
LTTNG_ASSERT(output);
output->data_url,
session->consumer,
tmp_output,
- NULL);
+ nullptr);
if (ret < 0) {
if (ret == -ENOMEM) {
cmd_ret = LTTNG_ERR_NOMEM;
int ret;
uint64_t ongoing_rotation_chunk_id;
enum lttng_error_code cmd_ret = LTTNG_OK;
- struct lttng_trace_chunk *chunk_being_archived = NULL;
- struct lttng_trace_chunk *new_trace_chunk = NULL;
+ struct lttng_trace_chunk *chunk_being_archived = nullptr;
+ struct lttng_trace_chunk *new_trace_chunk = nullptr;
enum lttng_trace_chunk_status chunk_status;
bool failed_to_rotate = false;
enum lttng_error_code rotation_fail_code = LTTNG_OK;
}
if (session->active) {
- new_trace_chunk = session_create_new_trace_chunk(session, NULL, NULL, NULL);
+ new_trace_chunk =
+ session_create_new_trace_chunk(session, nullptr, nullptr, nullptr);
if (!new_trace_chunk) {
cmd_ret = LTTNG_ERR_CREATE_DIR_FAIL;
goto error;
}
session->chunk_being_archived = chunk_being_archived;
- chunk_being_archived = NULL;
+ chunk_being_archived = nullptr;
if (!quiet_rotation) {
ret = notification_thread_command_session_rotation_ongoing(
the_notification_thread_handle, session->id, ongoing_rotation_chunk_id);
* Returns a pointer to a handler to run on completion of a command.
* Returns NULL if no handler has to be run for the last command executed.
*/
-const struct cmd_completion_handler *cmd_pop_completion_handler(void)
+const struct cmd_completion_handler *cmd_pop_completion_handler()
{
struct cmd_completion_handler *handler = current_completion_handler;
- current_completion_handler = NULL;
+ current_completion_handler = nullptr;
return handler;
}
/*
* Init command subsystem.
*/
-void cmd_init(void)
+void cmd_init()
{
/*
* Set network sequence index to 1 for streams to match a relayd
{
int ret;
struct lttng_payload copy_buffer;
- struct lttng_condition *copy = NULL;
+ struct lttng_condition *copy = nullptr;
lttng_payload_init(©_buffer);
ret = lttng_condition_create_from_payload(&view, ©);
if (ret < 0) {
- copy = NULL;
+ copy = nullptr;
goto end;
}
}
return pathname;
error:
free(pathname);
- return NULL;
+ return nullptr;
}
/*
LTTNG_ASSERT(data);
- if (output == NULL || data->cmd_sock < 0) {
+ if (output == nullptr || data->cmd_sock < 0) {
/*
* Not an error. Possible there is simply not spawned consumer or it's
* disabled for the tracing session asking the socket.
rcu_read_lock();
socket = consumer_find_socket(data->cmd_sock, output);
rcu_read_unlock();
- if (socket == NULL) {
+ if (socket == nullptr) {
socket = consumer_allocate_socket(&data->cmd_sock);
- if (socket == NULL) {
+ if (socket == nullptr) {
ret = -1;
goto error;
}
const struct consumer_output *consumer)
{
int consumer_fd;
- struct consumer_socket *socket = NULL;
+ struct consumer_socket *socket = nullptr;
ASSERT_RCU_READ_LOCKED();
{
struct lttng_ht_iter iter;
struct lttng_ht_node_ulong *node;
- struct consumer_socket *socket = NULL;
+ struct consumer_socket *socket = nullptr;
ASSERT_RCU_READ_LOCKED();
/* Negative keys are lookup failures */
- if (key < 0 || consumer == NULL) {
- return NULL;
+ if (key < 0 || consumer == nullptr) {
+ return nullptr;
}
lttng_ht_lookup(consumer->socks, (void *) ((unsigned long) key), &iter);
node = lttng_ht_iter_get_node_ulong(&iter);
- if (node != NULL) {
+ if (node != nullptr) {
socket = lttng::utils::container_of(node, &consumer_socket::node);
}
*/
struct consumer_socket *consumer_allocate_socket(int *fd)
{
- struct consumer_socket *socket = NULL;
+ struct consumer_socket *socket = nullptr;
LTTNG_ASSERT(fd);
socket = zmalloc<consumer_socket>();
- if (socket == NULL) {
+ if (socket == nullptr) {
PERROR("zmalloc consumer socket");
goto error;
}
*/
struct consumer_output *consumer_create_output(enum consumer_dst_type type)
{
- struct consumer_output *output = NULL;
+ struct consumer_output *output = nullptr;
output = zmalloc<consumer_output>();
- if (output == NULL) {
+ if (output == nullptr) {
PERROR("zmalloc consumer_output");
goto error;
}
LTTNG_ASSERT(src);
output = consumer_create_output(src->type);
- if (output == NULL) {
+ if (output == nullptr) {
goto end;
}
output->enabled = src->enabled;
error_put:
consumer_output_put(output);
- return NULL;
+ return nullptr;
}
/*
/* Create new socket object. */
copy_sock = consumer_allocate_socket(socket->fd_ptr);
- if (copy_sock == NULL) {
+ if (copy_sock == nullptr) {
rcu_read_unlock();
ret = -ENOMEM;
goto error;
struct lttng_uri *uri)
{
int ret;
- struct lttng_uri *dst_uri = NULL;
+ struct lttng_uri *dst_uri = nullptr;
/* Code flow error safety net. */
LTTNG_ASSERT(output);
int ret;
enum lttng_trace_chunk_status chunk_status;
struct lttng_credentials chunk_credentials;
- const struct lttng_directory_handle *chunk_directory_handle = NULL;
- struct lttng_directory_handle *domain_handle = NULL;
+ const struct lttng_directory_handle *chunk_directory_handle = nullptr;
+ struct lttng_directory_handle *domain_handle = nullptr;
int domain_dirfd;
const char *chunk_name;
bool chunk_name_overridden;
};
struct consumer_data {
- consumer_data (lttng_consumer_type type_)
+ explicit consumer_data (lttng_consumer_type type_)
: type(type_)
{}
#include <common/sessiond-comm/sessiond-comm.hpp>
#include <stdio.h>
-#include <stdlib.h>
-#include <string.h>
#include <unistd.h>
#include <urcu/list.h>
/* Ownership of kctx_copy is transferred to the callee. */
ret = kernel_add_channel_context(kchan, kctx_copy);
- kctx_copy = NULL;
+ kctx_copy = nullptr;
if (ret != 0) {
goto error;
}
/* Ownership of kctx is transferred to the callee. */
ret = kernel_add_channel_context(kchan, kctx);
- kctx = NULL;
+ kctx = nullptr;
if (ret != 0) {
goto error;
}
const struct lttng_event_context *ctx)
{
int ret;
- struct ltt_ust_context *uctx = NULL;
+ struct ltt_ust_context *uctx = nullptr;
LTTNG_ASSERT(usess);
LTTNG_ASSERT(uchan);
goto duplicate;
}
}
- uctx = NULL;
+ uctx = nullptr;
switch (domain) {
case LTTNG_DOMAIN_JUL:
/* Create ltt UST context */
uctx = trace_ust_create_context(ctx);
- if (uctx == NULL) {
+ if (uctx == nullptr) {
ret = LTTNG_ERR_UST_CONTEXT_INVAL;
goto error;
}
LTTNG_ASSERT(ctx);
LTTNG_ASSERT(channel_name);
- kctx = trace_kernel_create_context(NULL);
+ kctx = trace_kernel_create_context(nullptr);
if (!kctx) {
ret = -LTTNG_ERR_NOMEM;
goto error;
if (*channel_name == '\0') {
ret = add_kctx_all_channels(ksession, kctx);
/* Ownership of kctx is transferred to the callee. */
- kctx = NULL;
+ kctx = nullptr;
if (ret != LTTNG_OK) {
goto error;
}
} else {
/* Get kernel channel */
kchan = trace_kernel_get_channel_by_name(channel_name, ksession);
- if (kchan == NULL) {
+ if (kchan == nullptr) {
ret = LTTNG_ERR_KERN_CHAN_NOT_FOUND;
goto error;
}
ret = add_kctx_to_channel(kctx, kchan);
/* Ownership of kctx is transferred to the callee. */
- kctx = NULL;
+ kctx = nullptr;
if (ret != LTTNG_OK) {
goto error;
}
int ret = LTTNG_OK;
struct lttng_ht_iter iter;
struct lttng_ht *chan_ht;
- struct ltt_ust_channel *uchan = NULL;
+ struct ltt_ust_channel *uchan = nullptr;
LTTNG_ASSERT(usess);
LTTNG_ASSERT(ctx);
/* Get UST channel if defined */
if (channel_name[0] != '\0') {
uchan = trace_ust_find_channel_by_name(chan_ht, channel_name);
- if (uchan == NULL) {
+ if (uchan == nullptr) {
ret = LTTNG_ERR_UST_CHAN_NOT_FOUND;
goto error;
}
#include <vendor/nlohmann/json.hpp>
#include <algorithm>
+#include <utility>
namespace lsc = lttng::sessiond::ctf2;
namespace lst = lttng::sessiond::trace;
namespace ctf2 {
class trace_environment_visitor : public lst::trace_class_environment_visitor {
public:
- trace_environment_visitor()
- {
- }
+ trace_environment_visitor() = default;
- virtual void visit(const lst::environment_field<int64_t>& field) override
+ void visit(const lst::environment_field<int64_t>& field) override
{
_visit(field);
}
- virtual void visit(const lst::environment_field<const char *>& field) override
+ void visit(const lst::environment_field<const char *>& field) override
{
_visit(field);
}
class field_visitor : public lttng::sessiond::trace::field_visitor,
public lttng::sessiond::trace::type_visitor {
public:
- field_visitor()
- {
- }
+ field_visitor() = default;
/* Only call once. */
json::json move_fragment()
}
private:
- virtual void visit(const lst::field& field) override final
+ void visit(const lst::field& field) final
{
field_visitor field_type_visitor;
field.get_type().accept(field_type_visitor);
_fragment["field-class"] = field_type_visitor.move_fragment();
}
- virtual void visit(const lst::integer_type& type) override final
+ void visit(const lst::integer_type& type) final
{
_fragment["type"] = type.signedness_ == lst::integer_type::signedness::SIGNED ?
"fixed-length-signed-integer" :
}
}
- virtual void visit(const lst::floating_point_type& type) override final
+ void visit(const lst::floating_point_type& type) final
{
_fragment["type"] = "fixed-length-floating-point-number";
_fragment["length"] = type.exponent_digits + type.mantissa_digits;
_fragment["mappings"] = std::move(mappings_value);
}
- virtual void visit(const lst::signed_enumeration_type& type) override final
+ void visit(const lst::signed_enumeration_type& type) final
{
visit_enumeration(type);
}
- virtual void visit(const lst::unsigned_enumeration_type& type) override final
+ void visit(const lst::unsigned_enumeration_type& type) final
{
visit_enumeration(type);
}
- virtual void visit(const lst::static_length_array_type& type) override final
+ void visit(const lst::static_length_array_type& type) final
{
_fragment["type"] = "static-length-array";
_fragment["length"] = type.length;
}
- virtual void visit(const lst::dynamic_length_array_type& type) override final
+ void visit(const lst::dynamic_length_array_type& type) final
{
_fragment["type"] = "dynamic-length-array";
_fragment["length-field-location"] = to_json(type.length_field_location);
}
- virtual void visit(const lst::static_length_blob_type& type) override final
+ void visit(const lst::static_length_blob_type& type) final
{
_fragment["type"] = "static-length-blob";
_fragment["length"] = type.length_bytes;
}
}
- virtual void visit(const lst::dynamic_length_blob_type& type) override final
+ void visit(const lst::dynamic_length_blob_type& type) final
{
_fragment["type"] = "dynamic-length-blob";
_fragment["length-field-location"] = to_json(type.length_field_location);
}
- virtual void visit(const lst::null_terminated_string_type& type
- __attribute__((unused))) override final
+ void visit(const lst::null_terminated_string_type& type __attribute__((unused))) final
{
_fragment["type"] = "null-terminated-string";
}
- virtual void visit(const lst::structure_type& type) override final
+ void visit(const lst::structure_type& type) final
{
_fragment["type"] = "structure";
_fragment["options"] = std::move(options_value);
}
- virtual void visit(const lst::variant_type<int64_t>& type) override final
+ void visit(const lst::variant_type<int64_t>& type) final
{
visit_variant(type);
}
- virtual void visit(const lst::variant_type<uint64_t>& type) override final
+ void visit(const lst::variant_type<uint64_t>& type) final
{
visit_variant(type);
}
- virtual void visit(const lst::static_length_string_type& type) override final
+ void visit(const lst::static_length_string_type& type) final
{
_fragment["type"] = "static-length-string";
_fragment["length"] = type.length;
}
- virtual void visit(const lst::dynamic_length_string_type& type) override final
+ void visit(const lst::dynamic_length_string_type& type) final
{
_fragment["type"] = "dynamic-length-string";
_fragment["length-field-location"] = to_json(type.length_field_location);
lsc::trace_class_visitor::trace_class_visitor(
lsc::append_metadata_fragment_function append_metadata_fragment) :
- _append_metadata_fragment(append_metadata_fragment)
+ _append_metadata_fragment(std::move(append_metadata_fragment))
{
}
rcu_read_lock();
LTTNG_ASSERT(app_sock >= 0);
app = ust_app_find_by_sock(app_sock);
- if (app == NULL) {
+ if (app == nullptr) {
/*
* Application can be unregistered before so
* this is possible hence simply stopping the
int ret, nb_fd = 0, i;
unsigned int fd_added = 0;
struct lttng_poll_event events;
- struct ust_reg_wait_node *wait_node = NULL, *tmp_wait_node;
+ struct ust_reg_wait_node *wait_node = nullptr, *tmp_wait_node;
LTTNG_ASSERT(wait_queue);
* cds_list_for_each_entry_safe which uses
* __typeof__(*wait_node).
*/
- wait_node = NULL;
+ wait_node = nullptr;
break;
} else {
ERR("Unexpected poll events %u for sock %d", revents, pollfd);
{
int ret, err = -1;
struct cds_wfcq_node *node;
- struct ust_command *ust_cmd = NULL;
- struct ust_reg_wait_node *wait_node = NULL, *tmp_wait_node;
+ struct ust_command *ust_cmd = nullptr;
+ struct ust_reg_wait_node *wait_node = nullptr, *tmp_wait_node;
struct ust_reg_wait_queue wait_queue = {
.count = 0,
.head = {},
}
do {
- struct ust_app *app = NULL;
- ust_cmd = NULL;
+ struct ust_app *app = nullptr;
+ ust_cmd = nullptr;
/*
* Make sure we don't have node(s) that have hung up before receiving
/* Dequeue command for registration */
node = cds_wfcq_dequeue_blocking(¬ifiers->ust_cmd_queue->head,
¬ifiers->ust_cmd_queue->tail);
- if (node == NULL) {
+ if (node == nullptr) {
DBG("Woken up but nothing in the UST command queue");
/* Continue thread execution */
break;
}
lttng_fd_put(LTTNG_FD_APPS, 1);
free(ust_cmd);
- ust_cmd = NULL;
+ ust_cmd = nullptr;
goto error;
}
CDS_INIT_LIST_HEAD(&wait_node->head);
}
lttng_fd_put(LTTNG_FD_APPS, 1);
free(wait_node);
- wait_node = NULL;
+ wait_node = nullptr;
free(ust_cmd);
- ust_cmd = NULL;
+ ust_cmd = nullptr;
continue;
}
/*
wait_queue.count++;
free(ust_cmd);
- ust_cmd = NULL;
+ ust_cmd = nullptr;
/*
* We have to continue here since we don't have the notify
* socket and the application MUST be added to the hash table
wait_queue.count--;
app = wait_node->app;
free(wait_node);
- wait_node = NULL;
+ wait_node = nullptr;
DBG3("UST app notify socket %d is set",
ust_cmd->sock);
break;
lttng_fd_put(LTTNG_FD_APPS, 1);
}
free(ust_cmd);
- ust_cmd = NULL;
+ ust_cmd = nullptr;
}
if (app) {
rcu_read_unlock();
session_unlock_list();
}
- } while (node != NULL);
+ } while (node != nullptr);
health_poll_entry();
/* Futex wait on queue. Blocking call on futex() */
/* Dequeue command for registration */
node = cds_wfcq_dequeue_blocking(¬ifiers->ust_cmd_queue->head,
¬ifiers->ust_cmd_queue->tail);
- if (node == NULL) {
+ if (node == nullptr) {
break;
}
ust_cmd = lttng::utils::container_of(node, &ust_command::node);
}
health_unregister(the_health_sessiond);
rcu_unregister_thread();
- return NULL;
+ return nullptr;
}
static bool shutdown_ust_dispatch_thread(void *data)
/*
* Put one reference to every UID entries.
*/
-static void put_ref_all_ust_error_accounting_entry(void)
+static void put_ref_all_ust_error_accounting_entry()
{
struct lttng_ht_iter iter;
struct ust_error_accounting_entry *uid_entry;
/*
* Get one reference to every UID entries.
*/
-static void get_ref_all_ust_error_accounting_entry(void)
+static void get_ref_all_ust_error_accounting_entry()
{
struct lttng_ht_iter iter;
struct ust_error_accounting_entry *uid_entry;
error_indices_ht:
lttng_index_allocator_destroy(state->index_allocator);
- state->index_allocator = NULL;
+ state->index_allocator = nullptr;
end:
return status;
}
lttng_ht_lookup(uid_ht, &key, &iter);
node = lttng_ht_iter_get_node_u64(&iter);
- if (node == NULL) {
- entry = NULL;
+ if (node == nullptr) {
+ entry = nullptr;
} else {
bool got_ref;
got_ref = ust_error_accounting_entry_get(entry);
if (!got_ref) {
- entry = NULL;
+ entry = nullptr;
}
}
static struct ust_error_accounting_entry *
ust_error_accounting_entry_create(const struct ust_app *app)
{
- int i, ret, *cpu_counter_fds = NULL;
+ int i, ret, *cpu_counter_fds = nullptr;
struct lttng_ust_ctl_daemon_counter *daemon_counter;
struct lttng_ust_abi_object_data *counter, **cpu_counters;
- struct ust_error_accounting_entry *entry = NULL;
+ struct ust_error_accounting_entry *entry = nullptr;
lttng_ust_ctl_counter_dimension dimension = {};
dimension.size = ust_state.number_indices;
error_counter_cpu_fds_alloc:
free(entry);
error:
- entry = NULL;
+ entry = nullptr;
end:
free(cpu_counter_fds);
return entry;
*/
rcu_read_lock();
entry = ust_error_accounting_entry_find(error_counter_uid_ht, app);
- if (entry == NULL) {
+ if (entry == nullptr) {
/*
* Take the event notifier counter lock before creating the new
* entry to ensure that no event notifier is registered between
}
for (i = 0; i < entry->nr_counter_cpu_fds; i++) {
- struct lttng_ust_abi_object_data *new_counter_cpu = NULL;
+ struct lttng_ust_abi_object_data *new_counter_cpu = nullptr;
ret = lttng_ust_ctl_duplicate_ust_object_data(&new_counter_cpu,
entry->cpu_counters[i]);
}
app->event_notifier_group.counter = new_counter;
- new_counter = NULL;
+ new_counter = nullptr;
app->event_notifier_group.nr_counter_cpu = entry->nr_counter_cpu_fds;
app->event_notifier_group.counter_cpu = cpu_counters;
- cpu_counters = NULL;
+ cpu_counters = nullptr;
goto end_unlock;
error_send_cpu_counter_data:
error_duplicate_counter:
ust_error_accounting_entry_put(entry);
error_creating_entry:
- app->event_notifier_group.counter = NULL;
+ app->event_notifier_group.counter = nullptr;
end_unlock:
rcu_read_unlock();
end:
}
entry = ust_error_accounting_entry_find(error_counter_uid_ht, app);
- if (entry == NULL) {
+ if (entry == nullptr) {
ERR("Failed to find event notitifier error accounting entry on application teardown: pid = %d, application name = '%s'",
app->pid,
app->name);
}
index_entry = zmalloc<index_ht_entry>();
- if (index_entry == NULL) {
+ if (index_entry == nullptr) {
PERROR("Failed to allocate event notifier error counter hash table entry");
status = EVENT_NOTIFIER_ERROR_ACCOUNTING_STATUS_NOMEM;
goto end;
rcu_read_unlock();
}
-void event_notifier_error_accounting_fini(void)
+void event_notifier_error_accounting_fini()
{
if (kernel_error_accounting_entry.error_counter_fd) {
const int ret = close(kernel_error_accounting_entry.error_counter_fd);
cds_list_for_each_entry (kevent, &kchan->events_list.head, list) {
if (type != LTTNG_EVENT_ALL && kevent->type != type)
continue;
- if (event_name != NULL && strcmp(event_name, kevent->event->name)) {
+ if (event_name != nullptr && strcmp(event_name, kevent->event->name)) {
continue;
}
found++;
event_name ? event_name : "NULL",
type);
- if (event_name != NULL && !found) {
+ if (event_name != nullptr && !found) {
ret = LTTNG_ERR_NO_EVENT;
} else {
ret = error ? LTTNG_ERR_KERN_DISABLE_FAIL : LTTNG_OK;
LTTNG_ASSERT(event);
kevent = trace_kernel_find_event(event->name, kchan, event->type, filter);
- if (kevent == NULL) {
+ if (kevent == nullptr) {
ret = kernel_create_event(event, kchan, filter_expression, filter);
/* We have passed ownership */
- filter_expression = NULL;
- filter = NULL;
+ filter_expression = nullptr;
+ filter = nullptr;
if (ret) {
goto end;
}
ret = trace_ust_create_event(
event, filter_expression, filter, exclusion, internal_event, &uevent);
/* We have passed ownership */
- filter_expression = NULL;
- filter = NULL;
- exclusion = NULL;
+ filter_expression = nullptr;
+ filter = nullptr;
+ exclusion = nullptr;
if (ret != LTTNG_OK) {
goto end;
}
event_name,
&iter.iter);
node = lttng_ht_iter_get_node_str(&iter);
- if (node == NULL) {
+ if (node == nullptr) {
DBG2("Trace UST event NOT found by name %s", event_name);
ret = LTTNG_ERR_UST_EVENT_NOT_FOUND;
goto error;
{
int ret, i, size, error = 0;
struct lttng_ht_iter iter;
- struct ltt_ust_event *uevent = NULL;
- struct lttng_event *events = NULL;
+ struct ltt_ust_event *uevent = nullptr;
+ struct lttng_event *events = nullptr;
LTTNG_ASSERT(usess);
LTTNG_ASSERT(uchan);
struct agent *agt)
{
int ret = LTTNG_OK;
- char *provider_name = NULL, *ctx_name = NULL;
+ char *provider_name = nullptr, *ctx_name = nullptr;
struct bytecode_symbol_iterator *it = bytecode_symbol_iterator_create(bytecode);
if (!it) {
free(provider_name);
free(ctx_name);
- provider_name = ctx_name = NULL;
+ provider_name = ctx_name = nullptr;
} while (bytecode_symbol_iterator_next(it) == 0);
end:
free(provider_name);
ret = LTTNG_ERR_NOMEM;
goto error;
}
- filter = NULL;
- filter_expression = NULL;
+ filter = nullptr;
+ filter_expression = nullptr;
created = 1;
LTTNG_ASSERT(!AGENT_EVENT_IS_ENABLED(aevent));
}
const struct lttng_condition *condition;
const struct lttng_event_rule *rule;
const char *filter_expression;
- char *filter_expression_copy = NULL;
+ char *filter_expression_copy = nullptr;
const struct lttng_bytecode *filter_bytecode;
- struct lttng_bytecode *filter_bytecode_copy = NULL;
- struct lttng_event *event = NULL;
+ struct lttng_bytecode *filter_bytecode_copy = nullptr;
+ struct lttng_event *event = nullptr;
uid_t trigger_owner_uid = 0;
const char *trigger_name;
ret = agent_enable(agt, event, filter_bytecode_copy, filter_expression_copy);
/* Ownership was passed even in case of error. */
- filter_expression_copy = NULL;
- filter_bytecode_copy = NULL;
+ filter_expression_copy = nullptr;
+ filter_bytecode_copy = nullptr;
end:
free(filter_expression_copy);
*/
const char *event_get_default_agent_ust_name(enum lttng_domain_type domain)
{
- const char *default_event_name = NULL;
+ const char *default_event_name = nullptr;
switch (domain) {
case LTTNG_DOMAIN_LOG4J:
struct agent_event *aevent)
{
int ret;
- struct ltt_ust_event *uevent = NULL;
- struct ltt_ust_channel *uchan = NULL;
+ struct ltt_ust_event *uevent = nullptr;
+ struct ltt_ust_channel *uchan = nullptr;
const char *ust_event_name, *ust_channel_name;
LTTNG_ASSERT(agt);
aevent->filter,
LTTNG_UST_ABI_LOGLEVEL_ALL,
-1,
- NULL);
+ nullptr);
/* If the agent event exists, it must be available on the UST side. */
LTTNG_ASSERT(uevent);
rcu_read_lock();
aevent = agent_find_event_by_trigger(trigger, agt);
- if (aevent == NULL) {
+ if (aevent == nullptr) {
DBG2("Event agent NOT found by trigger %" PRIu64,
lttng_trigger_get_tracer_token(trigger));
ret = LTTNG_ERR_UST_EVENT_NOT_FOUND;
agent_find_events_by_name(event_name, agt, &iter);
node = lttng_ht_iter_get_node_str(&iter);
- if (node == NULL) {
+ if (node == nullptr) {
DBG2("Event agent NOT found by name %s", event_name);
ret = LTTNG_ERR_UST_EVENT_NOT_FOUND;
goto end;
uatomic_sub(&fd_count, (long) nr);
}
-void lttng_fd_init(void)
+void lttng_fd_init()
{
struct rlimit rlim;
int ret;
{
}
-lst::type::~type()
-{
-}
+lst::type::~type() = default;
bool lst::type::operator==(const lst::type& other) const noexcept
{
const unsigned int alignment;
protected:
- type(unsigned int alignment);
+ explicit type(unsigned int alignment);
private:
virtual bool _is_equal(const type& rhs) const noexcept = 0;
base base,
roles roles = {});
- virtual type::cuptr copy() const override;
+ type::cuptr copy() const override;
- virtual void accept(type_visitor& visitor) const override;
+ void accept(type_visitor& visitor) const override;
const enum byte_order byte_order;
const unsigned int size;
const roles roles_;
protected:
- virtual bool _is_equal(const type& other) const noexcept override;
+ bool _is_equal(const type& other) const noexcept override;
};
class floating_point_type : public type {
unsigned int exponent_digits,
unsigned int mantissa_digits);
- virtual type::cuptr copy() const override final;
+ type::cuptr copy() const final;
- virtual void accept(type_visitor& visitor) const override final;
+ void accept(type_visitor& visitor) const final;
const enum byte_order byte_order;
const unsigned int exponent_digits;
const unsigned int mantissa_digits;
private:
- virtual bool _is_equal(const type& other) const noexcept override final;
+ bool _is_equal(const type& other) const noexcept final;
};
class enumeration_type : public integer_type {
enum base base,
integer_type::roles roles = {});
- virtual void accept(type_visitor& visitor) const = 0;
+ void accept(type_visitor& visitor) const override = 0;
};
namespace details {
using range_t = enumeration_mapping_range<MappingIntegerType>;
enumeration_mapping(const enumeration_mapping<MappingIntegerType>& other) = default;
- enumeration_mapping(const enumeration_mapping<MappingIntegerType>&& other) :
- name{std::move(other.name)}, range{other.range}
+ enumeration_mapping(const enumeration_mapping<MappingIntegerType>&& other) noexcept :
+ name{ std::move(other.name) }, range{ other.range }
{
}
{
}
- virtual type::cuptr copy() const override
+ type::cuptr copy() const override
{
return lttng::make_unique<typed_enumeration_type<MappingIntegerType>>(
alignment, byte_order, size, base_, mappings_, roles_);
}
- virtual void accept(type_visitor& visitor) const override final;
+ void accept(type_visitor& visitor) const final;
const std::shared_ptr<const mappings> mappings_;
private:
- virtual bool _is_equal(const type& base_other) const noexcept override final
+ bool _is_equal(const type& base_other) const noexcept final
{
const auto& other = static_cast<const typed_enumeration_type<MappingIntegerType>&>(
base_other);
const type::cuptr element_type;
protected:
- virtual bool _is_equal(const type& base_other) const noexcept override;
+ bool _is_equal(const type& base_other) const noexcept override;
};
class static_length_array_type : public array_type {
type::cuptr element_type,
uint64_t in_length);
- virtual type::cuptr copy() const override final;
+ type::cuptr copy() const final;
- virtual void accept(type_visitor& visitor) const override final;
+ void accept(type_visitor& visitor) const final;
const uint64_t length;
private:
- virtual bool _is_equal(const type& base_other) const noexcept override final;
+ bool _is_equal(const type& base_other) const noexcept final;
};
class dynamic_length_array_type : public array_type {
type::cuptr element_type,
field_location length_field_location);
- virtual type::cuptr copy() const override final;
+ type::cuptr copy() const final;
- virtual void accept(type_visitor& visitor) const override final;
+ void accept(type_visitor& visitor) const final;
const field_location length_field_location;
private:
- virtual bool _is_equal(const type& base_other) const noexcept override final;
+ bool _is_equal(const type& base_other) const noexcept final;
};
class static_length_blob_type : public type {
static_length_blob_type(unsigned int alignment, uint64_t in_length_bytes, roles roles = {});
- virtual type::cuptr copy() const override final;
+ type::cuptr copy() const final;
- virtual void accept(type_visitor& visitor) const override final;
+ void accept(type_visitor& visitor) const final;
const uint64_t length_bytes;
const roles roles_;
private:
- virtual bool _is_equal(const type& base_other) const noexcept override final;
+ bool _is_equal(const type& base_other) const noexcept final;
};
class dynamic_length_blob_type : public type {
public:
dynamic_length_blob_type(unsigned int alignment, field_location length_field_location);
- virtual type::cuptr copy() const override final;
+ type::cuptr copy() const final;
- virtual void accept(type_visitor& visitor) const override final;
+ void accept(type_visitor& visitor) const final;
const field_location length_field_location;
private:
- virtual bool _is_equal(const type& base_other) const noexcept override final;
+ bool _is_equal(const type& base_other) const noexcept final;
};
class string_type : public type {
const encoding encoding_;
protected:
- virtual bool _is_equal(const type& base_other) const noexcept override;
+ bool _is_equal(const type& base_other) const noexcept override;
};
class static_length_string_type : public string_type {
static_length_string_type(
unsigned int alignment, enum encoding in_encoding, uint64_t length);
- virtual type::cuptr copy() const override final;
+ type::cuptr copy() const final;
- virtual void accept(type_visitor& visitor) const override final;
+ void accept(type_visitor& visitor) const final;
const uint64_t length;
private:
- virtual bool _is_equal(const type& base_other) const noexcept override final;
+ bool _is_equal(const type& base_other) const noexcept final;
};
class dynamic_length_string_type : public string_type {
enum encoding in_encoding,
field_location length_field_location);
- virtual type::cuptr copy() const override final;
+ type::cuptr copy() const final;
- virtual void accept(type_visitor& visitor) const override final;
+ void accept(type_visitor& visitor) const final;
const field_location length_field_location;
private:
- virtual bool _is_equal(const type& base_other) const noexcept override final;
+ bool _is_equal(const type& base_other) const noexcept final;
};
class null_terminated_string_type : public string_type {
public:
null_terminated_string_type(unsigned int alignment, enum encoding in_encoding);
- virtual type::cuptr copy() const override final;
+ type::cuptr copy() const final;
- virtual void accept(type_visitor& visitor) const override final;
+ void accept(type_visitor& visitor) const final;
};
class structure_type : public type {
structure_type(unsigned int alignment, fields in_fields);
- virtual type::cuptr copy() const override final;
+ type::cuptr copy() const final;
- virtual void accept(type_visitor& visitor) const override final;
+ void accept(type_visitor& visitor) const final;
const fields fields_;
private:
- virtual bool _is_equal(const type& base_other) const noexcept override final;
+ bool _is_equal(const type& base_other) const noexcept final;
};
template <typename MappingIntegerType>
{
}
- virtual type::cuptr copy() const override final
+ type::cuptr copy() const final
{
choices copy_of_choices;
alignment, selector_field_location, std::move(copy_of_choices));
}
- virtual void accept(type_visitor& visitor) const override final;
+ void accept(type_visitor& visitor) const final;
const field_location selector_field_location;
const choices choices_;
});
}
- virtual bool _is_equal(const type& base_other) const noexcept override final
+ bool _is_equal(const type& base_other) const noexcept final
{
const auto& other = static_cast<decltype(*this)&>(base_other);
struct notification_thread_handle *the_notification_thread_handle;
-struct lttng_ht *the_agent_apps_ht_by_sock = NULL;
-struct lttng_ht *the_trigger_agents_ht_by_domain = NULL;
+struct lttng_ht *the_agent_apps_ht_by_sock = nullptr;
+struct lttng_ht *the_trigger_agents_ht_by_domain = nullptr;
struct lttng_kernel_abi_tracer_version the_kernel_tracer_version;
struct lttng_kernel_abi_tracer_abi_version the_kernel_tracer_abi_version;
enum consumerd_state the_ust_consumerd_state;
enum consumerd_state the_kernel_consumerd_state;
-static void __attribute__((constructor)) init_sessiond_uuid(void)
+static void __attribute__((constructor)) init_sessiond_uuid()
{
if (lttng_uuid_generate(the_sessiond_uuid)) {
ERR("Failed to generate a session daemon UUID");
/* Application health monitoring */
extern struct health_app *the_health_sessiond;
-bool launch_health_management_thread(void);
+bool launch_health_management_thread();
#endif /* HEALTH_SESSIOND_H */
}
mark_thread_as_ready(notifiers);
- while (1) {
+ while (true) {
DBG("Health check ready");
/* Infinite blocking call, waiting for transmission */
lttng_poll_clean(&events);
rcu_unregister_thread();
- return NULL;
+ return nullptr;
}
static bool shutdown_health_management_thread(void *data)
return notify_thread_pipe(write_fd) == 1;
}
-bool launch_health_management_thread(void)
+bool launch_health_management_thread()
{
struct thread_notifiers *notifiers;
struct lttng_thread *thread;
{
int ret;
char tmp_path[PATH_MAX];
- char *pathname = NULL;
+ char *pathname = nullptr;
LTTNG_ASSERT(consumer);
error:
free(pathname);
- return NULL;
+ return nullptr;
}
/*
unsigned int monitor)
{
int ret;
- char *pathname = NULL;
+ char *pathname = nullptr;
struct lttcomm_consumer_msg lkm;
struct consumer_output *consumer;
enum lttng_error_code status;
- struct ltt_session *session = NULL;
+ struct ltt_session *session = nullptr;
struct lttng_channel_extended *channel_attr_extended;
bool is_local_trace;
size_t consumer_path_offset = 0;
end:
cds_list_add_tail(&ctx->list, &chan->ctx_list);
ctx->in_list = true;
- ctx = NULL;
+ ctx = nullptr;
error:
if (ctx) {
trace_kernel_destroy_context(ctx);
/* Allocate data structure */
lks = trace_kernel_create_session();
- if (lks == NULL) {
+ if (lks == nullptr) {
ret = -1;
goto error;
}
/* Allocate kernel channel */
lkc = trace_kernel_create_channel(chan);
- if (lkc == NULL) {
+ if (lkc == nullptr) {
goto error;
}
{
int fd;
int ret = 0;
- const char *symbol = NULL;
- const struct lttng_userspace_probe_location_lookup_method *lookup = NULL;
+ const char *symbol = nullptr;
+ const struct lttng_userspace_probe_location_lookup_method *lookup = nullptr;
enum lttng_userspace_probe_location_lookup_method_type lookup_method_type;
LTTNG_ASSERT(lttng_userspace_probe_location_get_type(probe_location) ==
uint32_t *offsets_count)
{
enum lttng_userspace_probe_location_lookup_method_type lookup_method_type;
- const struct lttng_userspace_probe_location_lookup_method *lookup = NULL;
- const char *probe_name = NULL, *provider_name = NULL;
+ const struct lttng_userspace_probe_location_lookup_method *lookup = nullptr;
+ const char *probe_name = nullptr, *provider_name = nullptr;
int ret = 0;
int fd, i;
gid_t gid,
int fd)
{
- const struct lttng_userspace_probe_location_lookup_method *lookup_method = NULL;
+ const struct lttng_userspace_probe_location_lookup_method *lookup_method = nullptr;
enum lttng_userspace_probe_location_lookup_method_type type;
int ret;
case LTTNG_USERSPACE_PROBE_LOCATION_LOOKUP_METHOD_TYPE_TRACEPOINT_SDT:
{
int i;
- uint64_t *offsets = NULL;
+ uint64_t *offsets = nullptr;
uint32_t offsets_count;
struct lttng_kernel_abi_event_callsite callsite;
int fd)
{
int ret;
- const struct lttng_userspace_probe_location *location = NULL;
+ const struct lttng_userspace_probe_location *location = nullptr;
LTTNG_ASSERT(ev);
LTTNG_ASSERT(ev->type == LTTNG_EVENT_USERSPACE_PROBE);
int ret;
enum lttng_event_rule_status status;
enum lttng_event_rule_type event_rule_type;
- const struct lttng_userspace_probe_location *location = NULL;
+ const struct lttng_userspace_probe_location *location = nullptr;
LTTNG_ASSERT(rule);
LTTNG_ASSERT(creds);
case LTTNG_PROCESS_ATTR_VIRTUAL_GROUP_ID:
return session->tracker_vgid;
default:
- return NULL;
+ return nullptr;
}
}
int kernel_open_metadata(struct ltt_kernel_session *session)
{
int ret;
- struct ltt_kernel_metadata *lkm = NULL;
+ struct ltt_kernel_metadata *lkm = nullptr;
LTTNG_ASSERT(session);
/* Allocate kernel metadata */
lkm = trace_kernel_create_metadata();
- if (lkm == NULL) {
+ if (lkm == nullptr) {
goto error;
}
/*
* Make a kernel wait to make sure in-flight probe have completed.
*/
-void kernel_wait_quiescent(void)
+void kernel_wait_quiescent()
{
int ret;
int fd = kernel_tracer_fd;
while ((ret = kernctl_create_stream(channel->fd)) >= 0) {
lks = trace_kernel_create_stream(channel->channel->name, channel->stream_count);
- if (lks == NULL) {
+ if (lks == nullptr) {
ret = close(ret);
if (ret) {
PERROR("close");
}
fp = fdopen(fd, "r");
- if (fp == NULL) {
+ if (fp == nullptr) {
PERROR("kernel tracepoint list fdopen");
goto error_fp;
}
*/
nbmem = KERNEL_EVENT_INIT_LIST_SIZE;
elist = calloc<lttng_event>(nbmem);
- if (elist == NULL) {
+ if (elist == nullptr) {
PERROR("alloc list events");
count = -ENOMEM;
goto end;
DBG("Reallocating event list from %zu to %zu bytes", nbmem, new_nbmem);
new_elist = (lttng_event *) realloc(elist,
new_nbmem * sizeof(struct lttng_event));
- if (new_elist == NULL) {
+ if (new_elist == nullptr) {
PERROR("realloc list events");
free(event);
free(elist);
/*
* Kernel work-arounds called at the start of sessiond main().
*/
-int init_kernel_workarounds(void)
+int init_kernel_workarounds()
{
int ret;
FILE *fp;
{
struct lttng_trace_chunk *trace_chunk;
- if (ksess == NULL) {
+ if (ksess == nullptr) {
DBG3("No kernel session when tearing down session");
return;
}
/* Teardown of data required by destroy notifiers. */
void kernel_free_session(struct ltt_kernel_session *ksess)
{
- if (ksess == NULL) {
+ if (ksess == nullptr) {
return;
}
trace_kernel_free_session(ksess);
*/
void kernel_destroy_channel(struct ltt_kernel_channel *kchan)
{
- struct ltt_kernel_session *ksess = NULL;
+ struct ltt_kernel_session *ksess = nullptr;
LTTNG_ASSERT(kchan);
LTTNG_ASSERT(kchan->channel);
struct consumer_socket *socket;
struct lttng_ht_iter iter;
struct ltt_kernel_metadata *saved_metadata;
- char *trace_path = NULL;
+ char *trace_path = nullptr;
size_t consumer_path_offset = 0;
LTTNG_ASSERT(ksess);
* Return 1 on success, 0 when feature is not supported, negative value in case
* of errors.
*/
-int kernel_supports_ring_buffer_snapshot_sample_positions(void)
+int kernel_supports_ring_buffer_snapshot_sample_positions()
{
/*
* RING_BUFFER_SNAPSHOT_SAMPLE_POSITIONS was introduced in 2.3
* Return 1 on success, 0 when feature is not supported, negative value in case
* of errors.
*/
-int kernel_supports_ring_buffer_packet_sequence_number(void)
+int kernel_supports_ring_buffer_packet_sequence_number()
{
/*
* Packet sequence number was introduced in LTTng 2.8,
* Return 1 on success, 0 when feature is not supported, negative value in case
* of errors.
*/
-int kernel_supports_event_notifiers(void)
+int kernel_supports_event_notifiers()
{
/*
* Event notifiers were introduced in LTTng 2.13, lttng-modules ABI 2.6.
/*
* Setup necessary data for kernel tracer action.
*/
-int init_kernel_tracer(void)
+int init_kernel_tracer()
{
int ret;
bool is_root = !getuid();
}
kernel_token_to_event_notifier_rule_ht = cds_lfht_new(
- DEFAULT_HT_SIZE, 1, 0, CDS_LFHT_AUTO_RESIZE | CDS_LFHT_ACCOUNTING, NULL);
+ DEFAULT_HT_SIZE, 1, 0, CDS_LFHT_AUTO_RESIZE | CDS_LFHT_ACCOUNTING, nullptr);
if (!kernel_token_to_event_notifier_rule_ht) {
goto error_token_ht;
}
}
}
-void cleanup_kernel_tracer(void)
+void cleanup_kernel_tracer()
{
DBG2("Closing kernel event notifier group notification file descriptor");
if (kernel_tracer_event_notifier_group_notification_fd >= 0) {
}
if (kernel_token_to_event_notifier_rule_ht) {
- const int ret = cds_lfht_destroy(kernel_token_to_event_notifier_rule_ht, NULL);
+ const int ret = cds_lfht_destroy(kernel_token_to_event_notifier_rule_ht, nullptr);
LTTNG_ASSERT(ret == 0);
}
free(syscall_table);
}
-bool kernel_tracer_is_initialized(void)
+bool kernel_tracer_is_initialized()
{
return kernel_tracer_fd >= 0;
}
struct ltt_kernel_event_notifier_rule *event_notifier_rule;
struct lttng_kernel_abi_event_notifier kernel_event_notifier = {};
unsigned int capture_bytecode_count = 0, i;
- const struct lttng_condition *condition = NULL;
- const struct lttng_event_rule *event_rule = NULL;
+ const struct lttng_condition *condition = nullptr;
+ const struct lttng_event_rule *event_rule = nullptr;
enum lttng_condition_status cond_status;
LTTNG_ASSERT(trigger);
lttng_condition_event_rule_matches_get_capture_bytecode_at_index(condition,
i);
- if (capture_bytecode == NULL) {
+ if (capture_bytecode == nullptr) {
ERR("Unexpected NULL capture bytecode on condition");
error_code_ret = LTTNG_ERR_KERN_ENABLE_FAIL;
goto capture_error;
return error_code_ret;
}
-int kernel_get_notification_fd(void)
+int kernel_get_notification_fd()
{
return kernel_tracer_event_notifier_group_notification_fd;
}
/* Overflow, stop everything, something went really wrong. */
ERR("Syscall listing memory size overflow. Stopping");
free(syscall_table);
- syscall_table = NULL;
+ syscall_table = nullptr;
ret = -EINVAL;
goto error;
}
syscall_table[index].name, name, sizeof(syscall_table[index].name))) {
ret = -EINVAL;
free(syscall_table);
- syscall_table = NULL;
+ syscall_table = nullptr;
goto error;
}
/*
{
struct lttng_ht_node_str *node;
struct lttng_ht_iter iter;
- struct syscall *ksyscall = NULL;
+ struct syscall *ksyscall = nullptr;
LTTNG_ASSERT(ht);
LTTNG_ASSERT(name);
ssize_t ret;
struct lttng_event *events;
/* Hash table used to filter duplicate out. */
- struct lttng_ht *syscalls_ht = NULL;
+ struct lttng_ht *syscalls_ht = nullptr;
LTTNG_ASSERT(_events);
#ifdef LTTNG_EMBED_HELP
#include <lttng-sessiond.8.h>
#else
- NULL
+ nullptr
#endif
;
/* Command line options */
static const struct option long_options[] = {
- { "client-sock", required_argument, 0, 'c' },
- { "apps-sock", required_argument, 0, 'a' },
- { "kconsumerd-cmd-sock", required_argument, 0, '\0' },
- { "kconsumerd-err-sock", required_argument, 0, '\0' },
- { "ustconsumerd32-cmd-sock", required_argument, 0, '\0' },
- { "ustconsumerd32-err-sock", required_argument, 0, '\0' },
- { "ustconsumerd64-cmd-sock", required_argument, 0, '\0' },
- { "ustconsumerd64-err-sock", required_argument, 0, '\0' },
- { "consumerd32-path", required_argument, 0, '\0' },
- { "consumerd32-libdir", required_argument, 0, '\0' },
- { "consumerd64-path", required_argument, 0, '\0' },
- { "consumerd64-libdir", required_argument, 0, '\0' },
- { "daemonize", no_argument, 0, 'd' },
- { "background", no_argument, 0, 'b' },
- { "sig-parent", no_argument, 0, 'S' },
- { "help", no_argument, 0, 'h' },
- { "group", required_argument, 0, 'g' },
- { "version", no_argument, 0, 'V' },
- { "quiet", no_argument, 0, 'q' },
- { "verbose", no_argument, 0, 'v' },
- { "verbose-consumer", no_argument, 0, '\0' },
- { "no-kernel", no_argument, 0, '\0' },
- { "pidfile", required_argument, 0, 'p' },
- { "agent-tcp-port", required_argument, 0, '\0' },
- { "config", required_argument, 0, 'f' },
- { "load", required_argument, 0, 'l' },
- { "kmod-probes", required_argument, 0, '\0' },
- { "extra-kmod-probes", required_argument, 0, '\0' },
- { EVENT_NOTIFIER_ERROR_BUFFER_SIZE_KERNEL_OPTION_STR, required_argument, 0, '\0' },
- { EVENT_NOTIFIER_ERROR_BUFFER_SIZE_USERSPACE_OPTION_STR, required_argument, 0, '\0' },
- { NULL, 0, 0, 0 }
+ { "client-sock", required_argument, nullptr, 'c' },
+ { "apps-sock", required_argument, nullptr, 'a' },
+ { "kconsumerd-cmd-sock", required_argument, nullptr, '\0' },
+ { "kconsumerd-err-sock", required_argument, nullptr, '\0' },
+ { "ustconsumerd32-cmd-sock", required_argument, nullptr, '\0' },
+ { "ustconsumerd32-err-sock", required_argument, nullptr, '\0' },
+ { "ustconsumerd64-cmd-sock", required_argument, nullptr, '\0' },
+ { "ustconsumerd64-err-sock", required_argument, nullptr, '\0' },
+ { "consumerd32-path", required_argument, nullptr, '\0' },
+ { "consumerd32-libdir", required_argument, nullptr, '\0' },
+ { "consumerd64-path", required_argument, nullptr, '\0' },
+ { "consumerd64-libdir", required_argument, nullptr, '\0' },
+ { "daemonize", no_argument, nullptr, 'd' },
+ { "background", no_argument, nullptr, 'b' },
+ { "sig-parent", no_argument, nullptr, 'S' },
+ { "help", no_argument, nullptr, 'h' },
+ { "group", required_argument, nullptr, 'g' },
+ { "version", no_argument, nullptr, 'V' },
+ { "quiet", no_argument, nullptr, 'q' },
+ { "verbose", no_argument, nullptr, 'v' },
+ { "verbose-consumer", no_argument, nullptr, '\0' },
+ { "no-kernel", no_argument, nullptr, '\0' },
+ { "pidfile", required_argument, nullptr, 'p' },
+ { "agent-tcp-port", required_argument, nullptr, '\0' },
+ { "config", required_argument, nullptr, 'f' },
+ { "load", required_argument, nullptr, 'l' },
+ { "kmod-probes", required_argument, nullptr, '\0' },
+ { "extra-kmod-probes", required_argument, nullptr, '\0' },
+ { EVENT_NOTIFIER_ERROR_BUFFER_SIZE_KERNEL_OPTION_STR, required_argument, nullptr, '\0' },
+ { EVENT_NOTIFIER_ERROR_BUFFER_SIZE_USERSPACE_OPTION_STR, required_argument, nullptr, '\0' },
+ { nullptr, 0, nullptr, 0 }
};
/* Command line options to ignore from configuration file */
* Notify the main thread to initiate the teardown of the worker threads by
* writing to the main quit pipe.
*/
-static void notify_main_quit_pipe(void)
+static void notify_main_quit_pipe()
{
int ret;
/*
* Close every consumer sockets.
*/
-static void close_consumer_sockets(void)
+static void close_consumer_sockets()
{
int ret;
/*
* Cleanup the session daemon's data structures.
*/
-static void sessiond_cleanup(void)
+static void sessiond_cleanup()
{
int ret;
struct ltt_session_list *session_list = session_get_list();
/*
* Cleanup the daemon's option data structures.
*/
-static void sessiond_cleanup_options(void)
+static void sessiond_cleanup_options()
{
DBG("Cleaning up options");
unsigned long v;
errno = 0;
- v = strtoul(arg, NULL, 0);
+ v = strtoul(arg, nullptr, 0);
if (errno != 0 || !isdigit(arg[0])) {
ERR("Wrong value in --agent-tcp-port parameter: %s", arg);
return -1;
unsigned long v;
errno = 0;
- v = strtoul(arg, NULL, 0);
+ v = strtoul(arg, nullptr, 0);
if (errno != 0 || !isdigit(arg[0])) {
ERR("Wrong value in --%s parameter: %s",
EVENT_NOTIFIER_ERROR_BUFFER_SIZE_KERNEL_OPTION_STR,
unsigned long v;
errno = 0;
- v = strtoul(arg, NULL, 0);
+ v = strtoul(arg, nullptr, 0);
if (errno != 0 || !isdigit(arg[0])) {
ERR("Wrong value in --%s parameter: %s",
EVENT_NOTIFIER_ERROR_BUFFER_SIZE_USERSPACE_OPTION_STR,
return ret;
}
-static void print_version(void)
+static void print_version()
{
fprintf(stdout, "%s\n", VERSION);
}
int ret = 0, c = 0, option_index = 0;
int orig_optopt = optopt, orig_optind = optind;
char *optstring;
- char *config_path = NULL;
+ char *config_path = nullptr;
optstring = utils_generate_optstring(long_options,
sizeof(long_options) / sizeof(struct option));
}
ret = config_get_section_entries(
- config_path, config_section_name, config_entry_handler, NULL);
+ config_path, config_section_name, config_entry_handler, nullptr);
if (ret) {
if (ret > 0) {
ERR("Invalid configuration option at line %i", ret);
/* Reset getopt's global state */
optopt = orig_optopt;
optind = orig_optind;
- while (1) {
+ while (true) {
option_index = -1;
/*
* getopt_long() will not set option_index if it encounters a
* unset.
*/
ret = set_option(
- c, optarg, option_index < 0 ? NULL : long_options[option_index].name);
+ c, optarg, option_index < 0 ? nullptr : long_options[option_index].name);
if (ret < 0) {
break;
}
/*
* Create lockfile using the rundir and return its fd.
*/
-static int create_lockfile(void)
+static int create_lockfile()
{
return utils_create_lock_file(the_config.lock_file_path.value);
}
*
* Also attempts to create and hold the lock file.
*/
-static int check_existing_daemon(void)
+static int check_existing_daemon()
{
int ret = 0;
return ret;
}
-static void sessiond_cleanup_lock_file(void)
+static void sessiond_cleanup_lock_file()
{
int ret;
/*
* Create the lttng run directory needed for all global sockets and pipe.
*/
-static int create_lttng_rundir(void)
+static int create_lttng_rundir()
{
int ret;
static int set_consumer_sockets(struct consumer_data *consumer_data)
{
int ret;
- char *path = NULL;
+ char *path = nullptr;
switch (consumer_data->type) {
case LTTNG_CONSUMER_KERNEL:
* Setup signal handler for :
* SIGINT, SIGTERM, SIGPIPE
*/
-static int set_signal_handler(void)
+static int set_signal_handler()
{
int ret = 0;
struct sigaction sa;
sa.sa_flags = SA_SIGINFO;
sa.sa_sigaction = sighandler;
- if ((ret = sigaction(SIGTERM, &sa, NULL)) < 0) {
+ if ((ret = sigaction(SIGTERM, &sa, nullptr)) < 0) {
PERROR("sigaction");
return ret;
}
- if ((ret = sigaction(SIGINT, &sa, NULL)) < 0) {
+ if ((ret = sigaction(SIGINT, &sa, nullptr)) < 0) {
PERROR("sigaction");
return ret;
}
- if ((ret = sigaction(SIGUSR1, &sa, NULL)) < 0) {
+ if ((ret = sigaction(SIGUSR1, &sa, nullptr)) < 0) {
PERROR("sigaction");
return ret;
}
- if ((ret = sigaction(SIGBUS, &sa, NULL)) < 0) {
+ if ((ret = sigaction(SIGBUS, &sa, nullptr)) < 0) {
PERROR("sigaction");
return ret;
}
sa.sa_flags = 0;
sa.sa_handler = SIG_IGN;
- if ((ret = sigaction(SIGPIPE, &sa, NULL)) < 0) {
+ if ((ret = sigaction(SIGPIPE, &sa, nullptr)) < 0) {
PERROR("sigaction");
return ret;
}
* Set open files limit to unlimited. This daemon can open a large number of
* file descriptors in order to consume multiple kernel traces.
*/
-static void set_ulimit(void)
+static void set_ulimit()
{
int ret;
struct rlimit lim;
}
}
-static int write_pidfile(void)
+static int write_pidfile()
{
return utils_create_pid_file(getpid(), the_config.pid_file_path.value);
}
-static int set_clock_plugin_env(void)
+static int set_clock_plugin_env()
{
int ret = 0;
- char *env_value = NULL;
+ char *env_value = nullptr;
if (!the_config.lttng_ust_clock_plugin.value) {
goto end;
return ret;
}
-static void destroy_all_sessions_and_wait(void)
+static void destroy_all_sessions_and_wait()
{
struct ltt_session *session, *tmp;
struct ltt_session_list *session_list;
goto unlock_session;
}
(void) cmd_stop_trace(session);
- (void) cmd_destroy_session(session, the_notification_thread_handle, NULL);
+ (void) cmd_destroy_session(session, the_notification_thread_handle, nullptr);
unlock_session:
session_unlock(session);
session_put(session);
DBG("Destruction of all sessions completed");
}
-static void unregister_all_triggers(void)
+static void unregister_all_triggers()
{
enum lttng_error_code ret_code;
enum lttng_trigger_status trigger_status;
- struct lttng_triggers *triggers = NULL;
+ struct lttng_triggers *triggers = nullptr;
unsigned int trigger_count, i;
const struct lttng_credentials creds = {
.uid = LTTNG_OPTIONAL_INIT_VALUE(0),
return run_as_create_worker(procname, run_as_worker_post_fork_cleanup, &the_config);
}
-static void sessiond_uuid_log(void)
+static void sessiond_uuid_log()
{
char uuid_str[LTTNG_UUID_STR_LEN];
{
int ret = 0, retval = 0;
const char *env_app_timeout;
- struct lttng_pipe *ust32_channel_monitor_pipe = NULL, *ust64_channel_monitor_pipe = NULL,
- *kernel_channel_monitor_pipe = NULL;
+ struct lttng_pipe *ust32_channel_monitor_pipe = nullptr,
+ *ust64_channel_monitor_pipe = nullptr,
+ *kernel_channel_monitor_pipe = nullptr;
struct timer_thread_parameters timer_thread_parameters;
/* Rotation thread handle. */
- struct rotation_thread_handle *rotation_thread_handle = NULL;
+ struct rotation_thread_handle *rotation_thread_handle = nullptr;
/* Queue of rotation jobs populated by the sessiond-timer. */
- struct rotation_thread_timer_queue *rotation_timer_queue = NULL;
- struct lttng_thread *client_thread = NULL;
- struct lttng_thread *notification_thread = NULL;
- struct lttng_thread *register_apps_thread = NULL;
+ struct rotation_thread_timer_queue *rotation_timer_queue = nullptr;
+ struct lttng_thread *client_thread = nullptr;
+ struct lttng_thread *notification_thread = nullptr;
+ struct lttng_thread *register_apps_thread = nullptr;
enum event_notifier_error_accounting_status event_notifier_error_accounting_status;
logger_set_thread_name("Main", false);
}
/* Load sessions. */
- ret = config_load_session(the_config.load_session_path.value, NULL, 1, 1, NULL);
+ ret = config_load_session(the_config.load_session_path.value, nullptr, 1, 1, nullptr);
if (ret) {
ERR("Session load failed: %s", error_get_str(ret));
retval = -1;
health_code_update();
- while (1) {
+ while (true) {
DBG("Apps thread polling");
/* Inifinite blocking call, waiting for transmission */
DBG("Application communication apps thread cleanup complete");
rcu_thread_offline();
rcu_unregister_thread();
- return NULL;
+ return nullptr;
}
static bool shutdown_application_management_thread(void *data)
bool launch_application_management_thread(int apps_cmd_pipe_read_fd)
{
struct lttng_pipe *quit_pipe;
- struct thread_notifiers *notifiers = NULL;
+ struct thread_notifiers *notifiers = nullptr;
struct lttng_thread *thread;
notifiers = zmalloc<thread_notifiers>();
struct thread_notifiers *notifiers = (thread_notifiers *) data;
struct consumer_data *consumer_data = notifiers->consumer_data;
const auto thread_quit_pipe_fd = lttng_pipe_get_readfd(notifiers->quit_pipe);
- struct consumer_socket *cmd_socket_wrapper = NULL;
+ struct consumer_socket *cmd_socket_wrapper = nullptr;
DBG("[thread] Manage consumer started");
/* Create metadata socket lock. */
consumer_data->metadata_sock.lock = zmalloc<pthread_mutex_t>();
- if (consumer_data->metadata_sock.lock == NULL) {
+ if (consumer_data->metadata_sock.lock == nullptr) {
PERROR("zmalloc pthread mutex");
mark_thread_intialization_as_failed(notifiers);
goto error;
}
- pthread_mutex_init(consumer_data->metadata_sock.lock, NULL);
+ pthread_mutex_init(consumer_data->metadata_sock.lock, nullptr);
DBG("Consumer command socket ready (fd: %d)", consumer_data->cmd_sock);
DBG("Consumer metadata socket ready (fd: %d)", consumer_data->metadata_fd);
/* Discard the socket wrapper as it is no longer needed. */
consumer_destroy_socket(cmd_socket_wrapper);
- cmd_socket_wrapper = NULL;
+ cmd_socket_wrapper = nullptr;
/* The thread is completely initialized, signal that it is ready. */
mark_thread_as_ready(notifiers);
/* Infinite blocking call, waiting for transmission */
- while (1) {
+ while (true) {
health_code_update();
/* Exit the thread because the thread quit pipe has been triggered. */
rcu_thread_offline();
rcu_unregister_thread();
- return NULL;
+ return nullptr;
}
static bool shutdown_consumer_management_thread(void *data)
bool launch_consumer_management_thread(struct consumer_data *consumer_data)
{
struct lttng_pipe *quit_pipe;
- struct thread_notifiers *notifiers = NULL;
+ struct thread_notifiers *notifiers = nullptr;
struct lttng_thread *thread;
notifiers = zmalloc<thread_notifiers>();
continue;
}
session_lock(session);
- if (session->kernel_session == NULL) {
+ if (session->kernel_session == nullptr) {
session_unlock(session);
session_put(session);
continue;
continue;
}
session_lock(session);
- if (session->kernel_session == NULL) {
+ if (session->kernel_session == nullptr) {
session_unlock(session);
session_put(session);
continue;
* means that tracing is started so it is safe to send
* our updated stream fds.
*/
- if (ksess->consumer_fds_sent != 1 || ksess->consumer == NULL) {
+ if (ksess->consumer_fds_sent != 1 || ksess->consumer == nullptr) {
ret = -1;
goto error;
}
goto error_testpoint;
}
- while (1) {
+ while (true) {
health_code_update();
if (update_poll_flag == 1) {
}
health_unregister(the_health_sessiond);
DBG("Kernel thread dying");
- return NULL;
+ return nullptr;
}
static bool shutdown_kernel_management_thread(void *data)
bool launch_kernel_management_thread(int kernel_poll_pipe_read_fd)
{
struct lttng_pipe *quit_pipe;
- struct thread_notifiers *notifiers = NULL;
+ struct thread_notifiers *notifiers = nullptr;
struct lttng_thread *thread;
notifiers = zmalloc<thread_notifiers>();
{
int ret = 0;
- *ctx = kmod_new(NULL, NULL);
+ *ctx = kmod_new(nullptr, nullptr);
if (!ctx) {
PERROR("Unable to create kmod library context");
ret = -ENOMEM;
*/
DIAGNOSTIC_PUSH
DIAGNOSTIC_IGNORE_SUGGEST_ATTRIBUTE_FORMAT
- kmod_set_log_fn(*ctx, log_kmod, NULL);
+ kmod_set_log_fn(*ctx, log_kmod, nullptr);
DIAGNOSTIC_POP
ret = kmod_load_resources(*ctx);
if (ret < 0) {
}
for (i = 0; i < entries; i++) {
- struct kmod_module *mod = NULL;
+ struct kmod_module *mod = nullptr;
ret = kmod_module_new_from_name(ctx, modules[i].name, &mod);
if (ret < 0) {
goto error;
}
- ret = kmod_module_probe_insert_module(mod, 0, NULL, NULL, NULL, NULL);
+ ret = kmod_module_probe_insert_module(mod, 0, nullptr, nullptr, nullptr, nullptr);
if (ret == -EEXIST) {
DBG("Module %s is already loaded", modules[i].name);
ret = 0;
ret = kmod_module_remove_module(mod, 0);
deps = kmod_module_get_dependencies(mod);
- if (deps != NULL) {
+ if (deps != nullptr) {
kmod_list_foreach(itr, deps)
{
struct kmod_module *dep = kmod_module_get_module(itr);
}
for (i = entries - 1; i >= 0; i--) {
- struct kmod_module *mod = NULL;
+ struct kmod_module *mod = nullptr;
if (!modules[i].loaded) {
continue;
/*
* Remove control kernel module(s) in reverse load order.
*/
-void modprobe_remove_lttng_control(void)
+void modprobe_remove_lttng_control()
{
modprobe_remove_lttng(kern_modules_control_core, ARRAY_SIZE(kern_modules_control_core));
}
-static void free_probes(void)
+static void free_probes()
{
int i;
free(probes[i].name);
}
free(probes);
- probes = NULL;
+ probes = nullptr;
nr_probes = 0;
}
/*
* Remove data kernel modules in reverse load order.
*/
-void modprobe_remove_lttng_data(void)
+void modprobe_remove_lttng_data()
{
if (!probes) {
return;
/*
* Remove all kernel modules in reverse order.
*/
-void modprobe_remove_lttng_all(void)
+void modprobe_remove_lttng_all()
{
modprobe_remove_lttng_data();
modprobe_remove_lttng_control();
/*
* Load control kernel module(s).
*/
-int modprobe_lttng_control(void)
+int modprobe_lttng_control()
{
return modprobe_lttng(kern_modules_control_core, ARRAY_SIZE(kern_modules_control_core));
}
* Grow global list of probes (double capacity or set it to 1 if
* currently 0 and copy existing data).
*/
-static int grow_probes(void)
+static int grow_probes()
{
int i;
struct kern_modules_param *tmp_probes;
if (!next) {
break;
}
- cur_list = NULL;
+ cur_list = nullptr;
/* filter leading spaces */
while (*next == ' ') {
/*
* Load data kernel module(s).
*/
-int modprobe_lttng_data(void)
+int modprobe_lttng_data()
{
int ret, i;
char *list;
struct lttng_event_notifier_notification *lttng_event_notifier_notification_create(
uint64_t tracer_token, enum lttng_domain_type domain, char *payload, size_t payload_size)
{
- struct lttng_event_notifier_notification *notification = NULL;
+ struct lttng_event_notifier_notification *notification = nullptr;
LTTNG_ASSERT(domain != LTTNG_DOMAIN_NONE);
LTTNG_ASSERT((payload && payload_size) || (!payload && !payload_size));
notification = zmalloc<lttng_event_notifier_notification>();
- if (notification == NULL) {
+ if (notification == nullptr) {
ERR("Error allocating notification");
goto end;
}
return session_info;
}
- return NULL;
+ return nullptr;
}
static struct session_info *get_session_info_by_name(const struct notification_thread_state *state,
uint64_t session_id;
const auto found = sample_session_id_by_name(name, &session_id);
- return found ? get_session_info_by_id(state, session_id) : NULL;
+ return found ? get_session_info_by_id(state, session_id) : nullptr;
}
static const char *notification_command_type_str(enum notification_thread_command_type type)
caa_container_of(node, struct lttng_trigger_ht_element, node_by_name_uid);
status = lttng_trigger_get_name(trigger_ht_element->trigger, &element_trigger_name);
- element_trigger_name = status == LTTNG_TRIGGER_STATUS_OK ? element_trigger_name : NULL;
+ element_trigger_name = status == LTTNG_TRIGGER_STATUS_OK ? element_trigger_name : nullptr;
status = lttng_trigger_get_name(trigger_key, &key_name);
- key_name = status == LTTNG_TRIGGER_STATUS_OK ? key_name : NULL;
+ key_name = status == LTTNG_TRIGGER_STATUS_OK ? key_name : nullptr;
/*
* Compare the names.
LTTNG_ASSERT(session_info);
if (session_info->channel_infos_ht) {
- ret = cds_lfht_destroy(session_info->channel_infos_ht, NULL);
+ ret = cds_lfht_destroy(session_info->channel_infos_ht, nullptr);
if (ret) {
ERR("Failed to destroy channel information hash table");
}
lttng_ref_init(&session_info->ref, session_info_destroy);
session_info->channel_infos_ht = cds_lfht_new(
- DEFAULT_HT_SIZE, 1, 0, CDS_LFHT_AUTO_RESIZE | CDS_LFHT_ACCOUNTING, NULL);
+ DEFAULT_HT_SIZE, 1, 0, CDS_LFHT_AUTO_RESIZE | CDS_LFHT_ACCOUNTING, nullptr);
if (!session_info->channel_infos_ht) {
goto error;
}
return session_info;
error:
session_info_put(session_info);
- return NULL;
+ return nullptr;
}
static void session_info_add_channel(struct session_info *session_info,
return channel_info;
error:
channel_info_destroy(channel_info);
- return NULL;
+ return nullptr;
}
bool notification_client_list_get(struct notification_client_list *list)
cds_lfht_del(list->notification_trigger_clients_ht,
&list->notification_trigger_clients_ht_node);
rcu_read_unlock();
- list->notification_trigger_clients_ht = NULL;
+ list->notification_trigger_clients_ht = nullptr;
}
cds_list_for_each_entry_safe (client_list_element, tmp, &list->clients_list, node) {
free(client_list_element);
goto end;
}
- pthread_mutex_init(&client_list->lock, NULL);
+ pthread_mutex_init(&client_list->lock, nullptr);
/*
* The trigger that owns the condition has the first reference to this
* client list.
error_put_client_list:
notification_client_list_put(client_list);
- client_list = NULL;
+ client_list = nullptr;
end:
return client_list;
{
struct cds_lfht_node *node;
struct cds_lfht_iter iter;
- struct notification_client_list *list = NULL;
+ struct notification_client_list *list = nullptr;
rcu_read_lock();
cds_lfht_lookup(state->notification_trigger_clients_ht,
if (node) {
list = lttng::utils::container_of(
node, ¬ification_client_list::notification_trigger_clients_ht_node);
- list = notification_client_list_get(list) ? list : NULL;
+ list = notification_client_list_get(list) ? list : nullptr;
}
rcu_read_unlock();
int ret;
struct cds_lfht_iter iter;
struct cds_lfht_node *node;
- struct channel_info *channel_info = NULL;
- struct channel_key *channel_key = NULL;
- struct channel_state_sample *last_sample = NULL;
- struct lttng_channel_trigger_list *channel_trigger_list = NULL;
+ struct channel_info *channel_info = nullptr;
+ struct channel_key *channel_key = nullptr;
+ struct channel_state_sample *last_sample = nullptr;
+ struct lttng_channel_trigger_list *channel_trigger_list = nullptr;
rcu_read_lock();
}
ret = evaluate_buffer_condition(
- condition, evaluation, state, NULL, last_sample, channel_info);
+ condition, evaluation, state, nullptr, last_sample, channel_info);
if (ret) {
WARN("Fatal error occurred while evaluating a newly subscribed-to condition");
goto end;
static const char *get_condition_session_name(const struct lttng_condition *condition)
{
- const char *session_name = NULL;
+ const char *session_name = nullptr;
enum lttng_condition_status status;
switch (lttng_condition_get_type(condition)) {
struct notification_thread_state *state)
{
int ret;
- struct lttng_evaluation *evaluation = NULL;
+ struct lttng_evaluation *evaluation = nullptr;
struct notification_client_list client_list = {
.lock = PTHREAD_MUTEX_INITIALIZER,
.ref = {},
- .condition = NULL,
+ .condition = nullptr,
.triggers_list = {},
.clients_list = {},
- .notification_trigger_clients_ht = NULL,
+ .notification_trigger_clients_ht = nullptr,
.notification_trigger_clients_ht_node = {},
.rcu_node = {},
};
object_uid = session_info->uid;
object_gid = session_info->gid;
- ret = evaluate_session_condition(condition, session_info, NULL, &evaluation);
+ ret = evaluate_session_condition(condition, session_info, nullptr, &evaluation);
session_info_put(session_info);
break;
}
enum lttng_notification_channel_status *_status)
{
int ret = 0;
- struct notification_client_list *client_list = NULL;
- struct lttng_condition_list_element *condition_list_element = NULL;
- struct notification_client_list_element *client_list_element = NULL;
+ struct notification_client_list *client_list = nullptr;
+ struct lttng_condition_list_element *condition_list_element = nullptr;
+ struct notification_client_list_element *client_list_element = nullptr;
struct lttng_trigger_ht_element *trigger_ht_element;
enum lttng_notification_channel_status status = LTTNG_NOTIFICATION_CHANNEL_STATUS_OK;
*/
CDS_INIT_LIST_HEAD(&condition_list_element->node);
condition_list_element->condition = condition;
- condition = NULL;
+ condition = nullptr;
cds_list_add(&condition_list_element->node, &client->condition_list);
client_list = get_client_list_from_condition(state, condition_list_element->condition);
}
pthread_mutex_unlock(&client_list->lock);
notification_client_list_put(client_list);
- client_list = NULL;
+ client_list = nullptr;
end:
lttng_condition_destroy(condition);
if (_status) {
{
struct cds_lfht_iter iter;
struct cds_lfht_node *node;
- struct notification_client *client = NULL;
+ struct notification_client *client = nullptr;
ASSERT_RCU_READ_LOCKED();
{
struct cds_lfht_iter iter;
struct cds_lfht_node *node;
- struct notification_client *client = NULL;
+ struct notification_client *client = nullptr;
ASSERT_RCU_READ_LOCKED();
{
enum lttng_condition_status status;
enum lttng_domain_type condition_domain;
- const char *condition_session_name = NULL;
- const char *condition_channel_name = NULL;
+ const char *condition_session_name = nullptr;
+ const char *condition_channel_name = nullptr;
status = lttng_condition_buffer_usage_get_domain_type(condition, &condition_domain);
LTTNG_ASSERT(status == LTTNG_CONDITION_STATUS_OK);
static struct lttng_session_trigger_list *
get_session_trigger_list(struct notification_thread_state *state, const char *session_name)
{
- struct lttng_session_trigger_list *list = NULL;
+ struct lttng_session_trigger_list *list = nullptr;
struct cds_lfht_node *node;
struct cds_lfht_iter iter;
static struct lttng_session_trigger_list *
lttng_session_trigger_list_create(const char *session_name, struct cds_lfht *session_triggers_ht)
{
- struct lttng_session_trigger_list *list = NULL;
+ struct lttng_session_trigger_list *list = nullptr;
char *session_name_copy = strdup(session_name);
if (!session_name_copy) {
const char *session_name)
{
int trigger_count = 0;
- struct lttng_session_trigger_list *session_trigger_list = NULL;
- struct lttng_trigger_ht_element *trigger_ht_element = NULL;
+ struct lttng_session_trigger_list *session_trigger_list = nullptr;
+ struct lttng_trigger_ht_element *trigger_ht_element = nullptr;
struct cds_lfht_iter iter;
session_trigger_list =
return session_trigger_list;
error:
lttng_session_trigger_list_destroy(session_trigger_list);
- return NULL;
+ return nullptr;
}
static struct session_info *create_and_publish_session_info(struct notification_thread_state *state,
uid_t uid,
gid_t gid)
{
- struct session_info *session = NULL;
+ struct session_info *session = nullptr;
struct lttng_session_trigger_list *trigger_list;
rcu_read_lock();
}
/* Transferred ownership to the new session. */
- trigger_list = NULL;
+ trigger_list = nullptr;
if (cds_lfht_add_unique(state->sessions_ht,
hash_session_info(session),
error:
rcu_read_unlock();
session_info_put(session);
- return NULL;
+ return nullptr;
}
static int handle_notification_thread_command_add_channel(struct notification_thread_state *state,
enum lttng_error_code *cmd_result)
{
struct cds_list_head trigger_list;
- struct channel_info *new_channel_info = NULL;
+ struct channel_info *new_channel_info = nullptr;
struct channel_key channel_key = {
.key = channel_key_int,
.domain = channel_domain,
};
- struct lttng_channel_trigger_list *channel_trigger_list = NULL;
- struct lttng_trigger_ht_element *trigger_ht_element = NULL;
+ struct lttng_channel_trigger_list *channel_trigger_list = nullptr;
+ struct lttng_trigger_ht_element *trigger_ht_element = nullptr;
int trigger_count = 0;
struct cds_lfht_iter iter;
- struct session_info *session_info = NULL;
+ struct session_info *session_info = nullptr;
DBG("Adding channel: channel name = `%s`, session id = %" PRIu64 ", channel key = %" PRIu64
", domain = %s",
lttng_trace_archive_location_get(location);
new_session_state.rotation.location = location;
} else {
- new_session_state.rotation.location = NULL;
+ new_session_state.rotation.location = nullptr;
}
session_creds = {
const struct lttng_condition *condition;
struct lttng_trigger *trigger;
struct notification_client_list *client_list;
- struct lttng_evaluation *evaluation = NULL;
+ struct lttng_evaluation *evaluation = nullptr;
enum action_executor_status executor_status;
trigger = trigger_list_element->trigger;
executor_status = action_executor_enqueue_trigger(
state->executor, trigger, evaluation, &session_creds, client_list);
notification_client_list_put(client_list);
- evaluation = NULL;
+ evaluation = nullptr;
switch (executor_status) {
case ACTION_EXECUTOR_STATUS_OK:
break;
{
int ret = 0;
enum lttng_error_code cmd_result = LTTNG_OK;
- struct notification_event_tracer_event_source_element *element = NULL;
+ struct notification_event_tracer_event_source_element *element = nullptr;
element = zmalloc<notification_event_tracer_event_source_element>();
if (!element) {
}
}
- source_element = NULL;
+ source_element = nullptr;
end:
return source_element;
}
{
int ret = 0;
enum lttng_error_code cmd_result = LTTNG_OK;
- struct notification_event_tracer_event_source_element *source_element = NULL;
+ struct notification_event_tracer_event_source_element *source_element = nullptr;
source_element = find_tracer_event_source_element(state, tracer_event_source_fd);
enum lttng_error_code cmd_result = LTTNG_OK;
struct cds_lfht_iter iter;
struct lttng_trigger_ht_element *trigger_ht_element;
- struct lttng_triggers *local_triggers = NULL;
+ struct lttng_triggers *local_triggers = nullptr;
const struct lttng_credentials *creds;
rcu_read_lock();
/* Transferring ownership to the caller. */
*triggers = local_triggers;
- local_triggers = NULL;
+ local_triggers = nullptr;
end:
rcu_read_unlock();
struct cds_lfht_node *node;
uint64_t error_counter_index = 0;
struct lttng_condition *condition = lttng_trigger_get_condition(trigger);
- struct notification_trigger_tokens_ht_element *trigger_tokens_ht_element = NULL;
+ struct notification_trigger_tokens_ht_element *trigger_tokens_ht_element = nullptr;
trigger_tokens_ht_element = zmalloc<notification_trigger_tokens_ht_element>();
if (!trigger_tokens_ht_element) {
{
int ret = 0;
struct lttng_condition *condition;
- struct notification_client_list *client_list = NULL;
- struct lttng_trigger_ht_element *trigger_ht_element = NULL;
+ struct notification_client_list *client_list = nullptr;
+ struct lttng_trigger_ht_element *trigger_ht_element = nullptr;
struct cds_lfht_node *node;
const char *trigger_name;
bool free_trigger = true;
- struct lttng_evaluation *evaluation = NULL;
+ struct lttng_evaluation *evaluation = nullptr;
struct lttng_credentials object_creds;
uid_t object_uid;
gid_t object_gid;
* Ownership of the trigger and of its wrapper was transfered to
* the triggers_ht. Same for token ht element if necessary.
*/
- trigger_ht_element = NULL;
+ trigger_ht_element = nullptr;
free_trigger = false;
switch (get_condition_binding_object(condition)) {
LTTNG_OPTIONAL_SET(&object_creds.uid, session_info->uid);
LTTNG_OPTIONAL_SET(&object_creds.gid, session_info->gid);
- ret = evaluate_session_condition(condition, session_info, NULL, &evaluation);
+ ret = evaluate_session_condition(condition, session_info, nullptr, &evaluation);
session_info_put(session_info);
break;
}
*/
executor_status = action_executor_enqueue_trigger(
state->executor, trigger, evaluation, &object_creds, client_list);
- evaluation = NULL;
+ evaluation = nullptr;
switch (executor_status) {
case ACTION_EXECUTOR_STATUS_OK:
break;
struct cds_lfht_iter iter;
struct cds_lfht_node *triggers_ht_node;
struct notification_client_list *client_list;
- struct lttng_trigger_ht_element *trigger_ht_element = NULL;
+ struct lttng_trigger_ht_element *trigger_ht_element = nullptr;
const struct lttng_condition *condition = lttng_trigger_get_const_condition(trigger);
enum lttng_error_code cmd_reply;
/* Put new reference and the hashtable's reference. */
notification_client_list_put(client_list);
notification_client_list_put(client_list);
- client_list = NULL;
+ client_list = nullptr;
}
/* Remove trigger from triggers_ht. */
break;
case NOTIFICATION_COMMAND_TYPE_LIST_TRIGGERS:
{
- struct lttng_triggers *triggers = NULL;
+ struct lttng_triggers *triggers = nullptr;
ret = handle_notification_thread_command_list_triggers(
handle,
goto end;
case NOTIFICATION_COMMAND_TYPE_GET_TRIGGER:
{
- struct lttng_trigger *trigger = NULL;
+ struct lttng_trigger *trigger = nullptr;
ret = handle_notification_thread_command_get_trigger(
state, cmd->parameters.get_trigger.trigger, &trigger, &cmd->reply_code);
end:
if (cmd->is_async) {
free(cmd);
- cmd = NULL;
+ cmd = nullptr;
} else {
lttng_waiter_wake_up(&cmd->reply_waiter);
}
goto error;
}
- pthread_mutex_init(&client->lock, NULL);
+ pthread_mutex_init(&client->lock, nullptr);
client->id = state->next_notification_client_id++;
CDS_INIT_LIST_HEAD(&client->condition_list);
lttng_payload_init(&client->communication.inbound.payload);
/* Release all conditions to which the client was subscribed. */
cds_list_for_each_entry_safe (condition_list_element, tmp, &client->condition_list, node) {
(void) notification_thread_client_unsubscribe(
- client, condition_list_element->condition, state, NULL);
+ client, condition_list_element->condition, state, nullptr);
}
/*
rcu_read_lock();
cds_lfht_for_each_entry (state->triggers_ht, &iter, trigger_ht_element, node) {
int ret = handle_notification_thread_command_unregister_trigger(
- state, trigger_ht_element->trigger, NULL);
+ state, trigger_ht_element->trigger, nullptr);
if (ret) {
error_occurred = true;
}
msg->size);
/* msg is not valid anymore due to lttng_dynamic_buffer_set_size. */
- msg = NULL;
+ msg = nullptr;
end:
return ret;
}
{
int ret;
uint64_t token;
- struct lttng_event_notifier_notification *notification = NULL;
- char *capture_buffer = NULL;
+ struct lttng_event_notifier_notification *notification = nullptr;
+ char *capture_buffer = nullptr;
size_t capture_buffer_size;
void *reception_buffer;
size_t reception_size;
}
if (capture_buffer_size == 0) {
- capture_buffer = NULL;
+ capture_buffer = nullptr;
goto skip_capture;
}
skip_capture:
notification = lttng_event_notifier_notification_create(
token, domain, capture_buffer, capture_buffer_size);
- if (notification == NULL) {
+ if (notification == nullptr) {
goto end;
}
/*
* Ownership transfered to the lttng_event_notifier_notification object.
*/
- capture_buffer = NULL;
+ capture_buffer = nullptr;
end:
free(capture_buffer);
struct cds_lfht_node *node;
struct cds_lfht_iter iter;
struct notification_trigger_tokens_ht_element *element;
- struct lttng_evaluation *evaluation = NULL;
+ struct lttng_evaluation *evaluation = nullptr;
enum action_executor_status executor_status;
- struct notification_client_list *client_list = NULL;
+ struct notification_client_list *client_list = nullptr;
int ret;
unsigned int capture_count = 0;
notification->capture_buf_size,
false);
- if (evaluation == NULL) {
+ if (evaluation == nullptr) {
ERR("Failed to create event rule matches evaluation while creating and enqueuing action executor job");
ret = -1;
goto end_unlock;
client_list = get_client_list_from_condition(
state, lttng_trigger_get_const_condition(element->trigger));
executor_status = action_executor_enqueue_trigger(
- state->executor, element->trigger, evaluation, NULL, client_list);
+ state->executor, element->trigger, evaluation, nullptr, client_list);
switch (executor_status) {
case ACTION_EXECUTOR_STATUS_OK:
ret = 0;
enum lttng_domain_type domain)
{
int ret = 0;
- struct lttng_event_notifier_notification *notification = NULL;
+ struct lttng_event_notifier_notification *notification = nullptr;
notification = recv_one_event_notifier_notification(pipe, domain);
- if (notification == NULL) {
+ if (notification == nullptr) {
/* Reception failed, don't consider it fatal. */
ERR("Error receiving an event notifier notification from tracer: fd = %i, domain = %s",
pipe,
{
int ret = 0;
struct lttcomm_consumer_channel_monitor_msg sample_msg;
- struct channel_info *channel_info = NULL;
+ struct channel_info *channel_info = nullptr;
struct cds_lfht_node *node;
struct cds_lfht_iter iter;
struct lttng_channel_trigger_list *channel_trigger_list;
cds_list_for_each_entry (trigger_list_element, &session_trigger_list->list, node) {
const struct lttng_condition *condition;
struct lttng_trigger *trigger;
- struct notification_client_list *client_list = NULL;
- struct lttng_evaluation *evaluation = NULL;
+ struct notification_client_list *client_list = nullptr;
+ struct lttng_evaluation *evaluation = nullptr;
enum action_executor_status executor_status;
ret = 0;
executor_status = action_executor_enqueue_trigger(
state->executor, trigger, evaluation, &session_creds, client_list);
notification_client_list_put(client_list);
- evaluation = NULL;
+ evaluation = nullptr;
switch (executor_status) {
case ACTION_EXECUTOR_STATUS_OK:
break;
cds_list_for_each_entry (trigger_list_element, &channel_trigger_list->list, node) {
const struct lttng_condition *condition;
struct lttng_trigger *trigger;
- struct notification_client_list *client_list = NULL;
- struct lttng_evaluation *evaluation = NULL;
+ struct notification_client_list *client_list = nullptr;
+ struct lttng_evaluation *evaluation = nullptr;
enum action_executor_status executor_status;
ret = 0;
condition,
&evaluation,
state,
- previous_sample_available ? &channel_previous_sample : NULL,
+ previous_sample_available ? &channel_previous_sample : nullptr,
&channel_new_sample,
channel_info);
if (caa_unlikely(ret)) {
executor_status = action_executor_enqueue_trigger(
state->executor, trigger, evaluation, &channel_creds, client_list);
notification_client_list_put(client_list);
- evaluation = NULL;
+ evaluation = nullptr;
switch (executor_status) {
case ACTION_EXECUTOR_STATUS_OK:
break;
handle->cmd_queue.event_fd = event_fd;
CDS_INIT_LIST_HEAD(&handle->cmd_queue.list);
- ret = pthread_mutex_init(&handle->cmd_queue.lock, NULL);
+ ret = pthread_mutex_init(&handle->cmd_queue.lock, nullptr);
if (ret) {
goto error;
}
return handle;
error:
notification_thread_handle_destroy(handle);
- return NULL;
+ return nullptr;
}
-static char *get_notification_channel_sock_path(void)
+static char *get_notification_channel_sock_path()
{
int ret;
bool is_root = !getuid();
return sock_path;
error:
free(sock_path);
- return NULL;
+ return nullptr;
}
static void notification_channel_socket_destroy(int fd)
}
}
-static int notification_channel_socket_create(void)
+static int notification_channel_socket_create()
{
int fd = -1, ret;
char *sock_path = get_notification_channel_sock_path();
if (state->client_socket_ht) {
ret = handle_notification_thread_client_disconnect_all(state);
LTTNG_ASSERT(!ret);
- ret = cds_lfht_destroy(state->client_socket_ht, NULL);
+ ret = cds_lfht_destroy(state->client_socket_ht, nullptr);
LTTNG_ASSERT(!ret);
}
if (state->client_id_ht) {
- ret = cds_lfht_destroy(state->client_id_ht, NULL);
+ ret = cds_lfht_destroy(state->client_id_ht, nullptr);
LTTNG_ASSERT(!ret);
}
if (state->triggers_ht) {
ret = handle_notification_thread_trigger_unregister_all(state);
LTTNG_ASSERT(!ret);
- ret = cds_lfht_destroy(state->triggers_ht, NULL);
+ ret = cds_lfht_destroy(state->triggers_ht, nullptr);
LTTNG_ASSERT(!ret);
}
if (state->channel_triggers_ht) {
- ret = cds_lfht_destroy(state->channel_triggers_ht, NULL);
+ ret = cds_lfht_destroy(state->channel_triggers_ht, nullptr);
LTTNG_ASSERT(!ret);
}
if (state->channel_state_ht) {
- ret = cds_lfht_destroy(state->channel_state_ht, NULL);
+ ret = cds_lfht_destroy(state->channel_state_ht, nullptr);
LTTNG_ASSERT(!ret);
}
if (state->notification_trigger_clients_ht) {
- ret = cds_lfht_destroy(state->notification_trigger_clients_ht, NULL);
+ ret = cds_lfht_destroy(state->notification_trigger_clients_ht, nullptr);
LTTNG_ASSERT(!ret);
}
if (state->channels_ht) {
- ret = cds_lfht_destroy(state->channels_ht, NULL);
+ ret = cds_lfht_destroy(state->channels_ht, nullptr);
LTTNG_ASSERT(!ret);
}
if (state->sessions_ht) {
- ret = cds_lfht_destroy(state->sessions_ht, NULL);
+ ret = cds_lfht_destroy(state->sessions_ht, nullptr);
LTTNG_ASSERT(!ret);
}
if (state->triggers_by_name_uid_ht) {
- ret = cds_lfht_destroy(state->triggers_by_name_uid_ht, NULL);
+ ret = cds_lfht_destroy(state->triggers_by_name_uid_ht, nullptr);
LTTNG_ASSERT(!ret);
}
if (state->trigger_tokens_ht) {
- ret = cds_lfht_destroy(state->trigger_tokens_ht, NULL);
+ ret = cds_lfht_destroy(state->trigger_tokens_ht, nullptr);
LTTNG_ASSERT(!ret);
}
/*
* See comment in struct lttng_session_trigger_list.
*/
if (state->session_triggers_ht) {
- ret = cds_lfht_destroy(state->session_triggers_ht, NULL);
+ ret = cds_lfht_destroy(state->session_triggers_ht, nullptr);
LTTNG_ASSERT(!ret);
}
if (state->notification_channel_socket >= 0) {
}
state->client_socket_ht = cds_lfht_new(
- DEFAULT_HT_SIZE, 1, 0, CDS_LFHT_AUTO_RESIZE | CDS_LFHT_ACCOUNTING, NULL);
+ DEFAULT_HT_SIZE, 1, 0, CDS_LFHT_AUTO_RESIZE | CDS_LFHT_ACCOUNTING, nullptr);
if (!state->client_socket_ht) {
goto error;
}
state->client_id_ht = cds_lfht_new(
- DEFAULT_HT_SIZE, 1, 0, CDS_LFHT_AUTO_RESIZE | CDS_LFHT_ACCOUNTING, NULL);
+ DEFAULT_HT_SIZE, 1, 0, CDS_LFHT_AUTO_RESIZE | CDS_LFHT_ACCOUNTING, nullptr);
if (!state->client_id_ht) {
goto error;
}
state->channel_triggers_ht = cds_lfht_new(
- DEFAULT_HT_SIZE, 1, 0, CDS_LFHT_AUTO_RESIZE | CDS_LFHT_ACCOUNTING, NULL);
+ DEFAULT_HT_SIZE, 1, 0, CDS_LFHT_AUTO_RESIZE | CDS_LFHT_ACCOUNTING, nullptr);
if (!state->channel_triggers_ht) {
goto error;
}
state->session_triggers_ht = cds_lfht_new(
- DEFAULT_HT_SIZE, 1, 0, CDS_LFHT_AUTO_RESIZE | CDS_LFHT_ACCOUNTING, NULL);
+ DEFAULT_HT_SIZE, 1, 0, CDS_LFHT_AUTO_RESIZE | CDS_LFHT_ACCOUNTING, nullptr);
if (!state->session_triggers_ht) {
goto error;
}
state->channel_state_ht = cds_lfht_new(
- DEFAULT_HT_SIZE, 1, 0, CDS_LFHT_AUTO_RESIZE | CDS_LFHT_ACCOUNTING, NULL);
+ DEFAULT_HT_SIZE, 1, 0, CDS_LFHT_AUTO_RESIZE | CDS_LFHT_ACCOUNTING, nullptr);
if (!state->channel_state_ht) {
goto error;
}
state->notification_trigger_clients_ht = cds_lfht_new(
- DEFAULT_HT_SIZE, 1, 0, CDS_LFHT_AUTO_RESIZE | CDS_LFHT_ACCOUNTING, NULL);
+ DEFAULT_HT_SIZE, 1, 0, CDS_LFHT_AUTO_RESIZE | CDS_LFHT_ACCOUNTING, nullptr);
if (!state->notification_trigger_clients_ht) {
goto error;
}
state->channels_ht = cds_lfht_new(
- DEFAULT_HT_SIZE, 1, 0, CDS_LFHT_AUTO_RESIZE | CDS_LFHT_ACCOUNTING, NULL);
+ DEFAULT_HT_SIZE, 1, 0, CDS_LFHT_AUTO_RESIZE | CDS_LFHT_ACCOUNTING, nullptr);
if (!state->channels_ht) {
goto error;
}
state->sessions_ht = cds_lfht_new(
- DEFAULT_HT_SIZE, 1, 0, CDS_LFHT_AUTO_RESIZE | CDS_LFHT_ACCOUNTING, NULL);
+ DEFAULT_HT_SIZE, 1, 0, CDS_LFHT_AUTO_RESIZE | CDS_LFHT_ACCOUNTING, nullptr);
if (!state->sessions_ht) {
goto error;
}
state->triggers_ht = cds_lfht_new(
- DEFAULT_HT_SIZE, 1, 0, CDS_LFHT_AUTO_RESIZE | CDS_LFHT_ACCOUNTING, NULL);
+ DEFAULT_HT_SIZE, 1, 0, CDS_LFHT_AUTO_RESIZE | CDS_LFHT_ACCOUNTING, nullptr);
if (!state->triggers_ht) {
goto error;
}
state->triggers_by_name_uid_ht = cds_lfht_new(
- DEFAULT_HT_SIZE, 1, 0, CDS_LFHT_AUTO_RESIZE | CDS_LFHT_ACCOUNTING, NULL);
+ DEFAULT_HT_SIZE, 1, 0, CDS_LFHT_AUTO_RESIZE | CDS_LFHT_ACCOUNTING, nullptr);
if (!state->triggers_by_name_uid_ht) {
goto error;
}
state->trigger_tokens_ht = cds_lfht_new(
- DEFAULT_HT_SIZE, 1, 0, CDS_LFHT_AUTO_RESIZE | CDS_LFHT_ACCOUNTING, NULL);
+ DEFAULT_HT_SIZE, 1, 0, CDS_LFHT_AUTO_RESIZE | CDS_LFHT_ACCOUNTING, nullptr);
if (!state->trigger_tokens_ht) {
goto error;
}
rcu_thread_offline();
rcu_unregister_thread();
health_unregister(the_health_sessiond);
- return NULL;
+ return nullptr;
}
static bool shutdown_notification_thread(void *thread_data)
struct lttng_thread *thread;
thread = lttng_thread_create(
- "Notification", thread_notification, shutdown_notification_thread, NULL, handle);
+ "Notification", thread_notification, shutdown_notification_thread, nullptr, handle);
if (!thread) {
goto error;
}
wait_until_thread_is_ready(handle);
return thread;
error:
- return NULL;
+ return nullptr;
}
health_code_update();
- while (1) {
+ while (true) {
DBG3("[ust-thread] Manage notify polling");
/* Inifinite blocking call, waiting for transmission */
health_unregister(the_health_sessiond);
rcu_thread_offline();
rcu_unregister_thread();
- return NULL;
+ return nullptr;
}
static bool shutdown_application_notification_thread(void *data)
#include <signal.h>
/* Notify parents that we are ready for cmd and health check */
-void sessiond_signal_parents(void)
+void sessiond_signal_parents()
{
/*
* Notify parent pid that we are ready to accept command
/*
* Creates the application socket.
*/
-static int create_application_socket(void)
+static int create_application_socket()
{
int ret = 0;
int apps_sock;
/* See shm.c for this call implying mmap, shm and futex calls */
wait_shm_mmap = shm_ust_get_mmap(the_config.wait_shm_path.value, is_root);
- if (wait_shm_mmap == NULL) {
+ if (wait_shm_mmap == nullptr) {
goto error;
}
* Gets allocated in this thread, enqueued to a global queue, dequeued
* and freed in the manage apps thread.
*/
- struct ust_command *ust_cmd = NULL;
+ struct ust_command *ust_cmd = nullptr;
const bool is_root = (getuid() == 0);
struct thread_state *thread_state = (struct thread_state *) data;
const int application_socket = thread_state->application_socket;
goto error_poll_add;
}
- while (1) {
+ while (true) {
DBG("Accepting application registration");
/* Inifinite blocking call, waiting for transmission */
/* Create UST registration command for enqueuing */
ust_cmd = zmalloc<ust_command>();
- if (ust_cmd == NULL) {
+ if (ust_cmd == nullptr) {
PERROR("ust command zmalloc");
ret = close(sock);
if (ret) {
ERR("Health error occurred in %s", __func__);
}
health_unregister(the_health_sessiond);
- return NULL;
+ return nullptr;
}
static bool shutdown_application_registration_thread(void *data)
{
int ret;
struct lttng_pipe *quit_pipe;
- struct thread_state *thread_state = NULL;
- struct lttng_thread *thread = NULL;
+ struct thread_state *thread_state = nullptr;
+ struct lttng_thread *thread = nullptr;
const bool is_root = (getuid() == 0);
int application_socket = -1;
*/
application_socket = -1;
if (!wait_thread_status(thread_state)) {
- thread_state = NULL;
+ thread_state = nullptr;
goto error;
}
}
}
error_alloc:
- return NULL;
+ return nullptr;
}
#include <urcu.h>
#include <urcu/list.h>
-struct lttng_notification_channel *rotate_notification_channel = NULL;
+struct lttng_notification_channel *rotate_notification_channel = nullptr;
struct rotation_thread {
struct lttng_poll_event events;
}
}
-struct rotation_thread_timer_queue *rotation_thread_timer_queue_create(void)
+struct rotation_thread_timer_queue *rotation_thread_timer_queue_create()
{
- struct rotation_thread_timer_queue *queue = NULL;
+ struct rotation_thread_timer_queue *queue = nullptr;
queue = zmalloc<rotation_thread_timer_queue>();
if (!queue) {
queue->event_pipe = lttng_pipe_open(FD_CLOEXEC | O_NONBLOCK);
CDS_INIT_LIST_HEAD(&queue->list);
- pthread_mutex_init(&queue->lock, NULL);
+ pthread_mutex_init(&queue->lock, nullptr);
end:
return queue;
}
return handle;
error:
rotation_thread_handle_destroy(handle);
- return NULL;
+ return nullptr;
}
/*
{
int ret;
const char dummy = '!';
- struct rotation_thread_job *job = NULL;
+ struct rotation_thread_job *job = nullptr;
const char *job_type_str = get_job_type_str(job_type);
pthread_mutex_lock(&queue->lock);
* rotations can start now.
*/
chunk_status = lttng_trace_chunk_get_name(
- session->chunk_being_archived, &archived_chunk_name, NULL);
+ session->chunk_being_archived, &archived_chunk_name, nullptr);
LTTNG_ASSERT(chunk_status == LTTNG_TRACE_CHUNK_STATUS_OK);
free(session->last_archived_chunk_name);
session->last_archived_chunk_name = strdup(archived_chunk_name);
struct notification_thread_handle *notification_thread_handle)
{
int ret = 0;
- const char *condition_session_name = NULL;
+ const char *condition_session_name = nullptr;
enum lttng_condition_type condition_type;
enum lttng_condition_status condition_status;
enum lttng_evaluation_status evaluation_status;
}
ret = cmd_rotate_session(
- session, NULL, false, LTTNG_TRACE_CHUNK_COMMAND_TYPE_MOVE_TO_COMPLETED);
+ session, nullptr, false, LTTNG_TRACE_CHUNK_COMMAND_TYPE_MOVE_TO_COMPLETED);
switch (ret) {
case LTTNG_OK:
break;
{
int ret;
bool notification_pending;
- struct lttng_notification *notification = NULL;
+ struct lttng_notification *notification = nullptr;
enum lttng_notification_channel_status status;
status = lttng_notification_channel_has_pending_notification(rotate_notification_channel,
health_unregister(the_health_sessiond);
rcu_thread_offline();
rcu_unregister_thread();
- return NULL;
+ return nullptr;
}
static bool shutdown_rotation_thread(void *thread_data)
struct lttng_thread *thread;
thread = lttng_thread_create(
- "Rotation", thread_rotation, shutdown_rotation_thread, NULL, handle);
+ "Rotation", thread_rotation, shutdown_rotation_thread, nullptr, handle);
if (!thread) {
goto error;
}
}
if (attr->extended.ptr) {
- struct lttng_channel_extended *ext = NULL;
+ struct lttng_channel_extended *ext = nullptr;
ext = (struct lttng_channel_extended *) attr->extended.ptr;
ret = config_writer_write_element_unsigned_int(
struct lttng_ust_abi_channel_attr *attr)
{
int ret;
- struct ltt_ust_channel *channel = NULL;
+ struct ltt_ust_channel *channel = nullptr;
ret = config_writer_write_element_string(writer,
config_element_overwrite_mode,
instrumentation_string = config_event_type_syscall;
break;
default:
- instrumentation_string = NULL;
+ instrumentation_string = nullptr;
}
return instrumentation_string;
context_type_string = config_event_context_vsgid;
break;
default:
- context_type_string = NULL;
+ context_type_string = nullptr;
}
return context_type_string;
* are stored as a node of type event_perf_context_type.
*/
default:
- context_type_string = NULL;
+ context_type_string = nullptr;
break;
}
buffer_type_string = config_buffer_type_global;
break;
default:
- buffer_type_string = NULL;
+ buffer_type_string = nullptr;
}
return buffer_type_string;
loglevel_type_string = config_loglevel_type_single;
break;
default:
- loglevel_type_string = NULL;
+ loglevel_type_string = nullptr;
}
return loglevel_type_string;
*/
addr = event->event->u.kprobe.addr;
offset = event->event->u.kprobe.offset;
- symbol_name = addr ? NULL : event->event->u.kprobe.symbol_name;
+ symbol_name = addr ? nullptr : event->event->u.kprobe.symbol_name;
break;
case LTTNG_KERNEL_ABI_KRETPROBE:
addr = event->event->u.kretprobe.addr;
offset = event->event->u.kretprobe.offset;
- symbol_name = addr ? NULL : event->event->u.kretprobe.symbol_name;
+ symbol_name = addr ? nullptr : event->event->u.kretprobe.symbol_name;
break;
default:
LTTNG_ASSERT(1);
goto end;
}
} else {
- struct agent *agent = NULL;
+ struct agent *agent = nullptr;
agent = trace_ust_find_agent(session, ust_chan->domain);
if (!agent) {
const char *element_id_tracker, *element_target_id, *element_id;
const struct process_attr_tracker *tracker;
enum lttng_tracking_policy tracking_policy;
- struct lttng_process_attr_values *values = NULL;
+ struct lttng_process_attr_values *values = nullptr;
switch (process_attr) {
case LTTNG_PROCESS_ATTR_PROCESS_ID:
for (i = 0; i < count; i++) {
unsigned int integral_value = UINT_MAX;
- const char *name = NULL;
+ const char *name = nullptr;
const struct process_attr_value *value =
lttng_process_attr_tracker_values_get_at_index(values, i);
int ret, fd = -1;
char config_file_path[LTTNG_PATH_MAX];
size_t len;
- struct config_writer *writer = NULL;
+ struct config_writer *writer = nullptr;
size_t session_name_len;
const char *provided_path;
int file_open_flags = O_CREAT | O_WRONLY | O_TRUNC;
const char *forbidden_name_chars = "/";
/* Global hash table to keep the sessions, indexed by id. */
-struct lttng_ht *ltt_sessions_ht_by_id = NULL;
+struct lttng_ht *ltt_sessions_ht_by_id = nullptr;
/* Global hash table to keep the sessions, indexed by name. */
-struct lttng_ht *ltt_sessions_ht_by_name = NULL;
+struct lttng_ht *ltt_sessions_ht_by_name = nullptr;
/*
* Init tracing session list.
/*
* Return a pointer to the session list.
*/
-struct ltt_session_list *session_get_list(void)
+struct ltt_session_list *session_get_list()
{
return &the_session_list;
}
/*
* Returns once the session list is empty.
*/
-void session_list_wait_empty(void)
+void session_list_wait_empty()
{
pthread_mutex_lock(&the_session_list.lock);
while (!cds_list_empty(&the_session_list.head)) {
/*
* Acquire session list lock
*/
-void session_lock_list(void)
+void session_lock_list()
{
pthread_mutex_lock(&the_session_list.lock);
}
/*
* Try to acquire session list lock
*/
-int session_trylock_list(void)
+int session_trylock_list()
{
return pthread_mutex_trylock(&the_session_list.lock);
}
/*
* Release session list lock
*/
-void session_unlock_list(void)
+void session_unlock_list()
{
pthread_mutex_unlock(&the_session_list.lock);
}
*/
const char *session_get_net_consumer_hostname(const struct ltt_session *session)
{
- const char *hostname = NULL;
+ const char *hostname = nullptr;
const struct consumer_output *output;
output = session->kernel_session ? session->kernel_session->consumer :
session_get_trace_archive_location(const struct ltt_session *session)
{
int ret;
- struct lttng_trace_archive_location *location = NULL;
- char *chunk_path = NULL;
+ struct lttng_trace_archive_location *location = nullptr;
+ char *chunk_path = nullptr;
if (session->rotation_state != LTTNG_ROTATION_STATE_COMPLETED ||
!session->last_archived_chunk_name) {
*
* The session list lock must be held.
*/
-static int ltt_sessions_ht_alloc(void)
+static int ltt_sessions_ht_alloc()
{
int ret = 0;
*
* The session list lock must be held.
*/
-static void ltt_sessions_ht_destroy(void)
+static void ltt_sessions_ht_destroy()
{
if (ltt_sessions_ht_by_id) {
lttng_ht_destroy(ltt_sessions_ht_by_id);
- ltt_sessions_ht_by_id = NULL;
+ ltt_sessions_ht_by_id = nullptr;
}
if (ltt_sessions_ht_by_name) {
lttng_ht_destroy(ltt_sessions_ht_by_name);
- ltt_sessions_ht_by_name = NULL;
+ ltt_sessions_ht_by_name = nullptr;
}
return;
* Return `false` if hash table objects are null.
* The session list lock must be held.
*/
-static bool ltt_sessions_ht_empty(void)
+static bool ltt_sessions_ht_empty()
{
bool empty = false;
* `current_trace_chunk`.
*/
current_trace_chunk = session->current_trace_chunk;
- session->current_trace_chunk = NULL;
+ session->current_trace_chunk = nullptr;
if (session->ust_session) {
lttng_trace_chunk_put(session->ust_session->current_trace_chunk);
- session->ust_session->current_trace_chunk = NULL;
+ session->ust_session->current_trace_chunk = nullptr;
}
if (session->kernel_session) {
lttng_trace_chunk_put(session->kernel_session->current_trace_chunk);
- session->kernel_session->current_trace_chunk = NULL;
+ session->kernel_session->current_trace_chunk = nullptr;
}
if (!new_trace_chunk) {
ret = 0;
end:
if (_current_trace_chunk) {
*_current_trace_chunk = current_trace_chunk;
- current_trace_chunk = NULL;
+ current_trace_chunk = nullptr;
}
end_no_move:
rcu_read_unlock();
return ret;
error:
if (session->ust_session) {
- session->ust_session->current_trace_chunk = NULL;
+ session->ust_session->current_trace_chunk = nullptr;
}
if (session->kernel_session) {
- session->kernel_session->current_trace_chunk = NULL;
+ session->kernel_session->current_trace_chunk = nullptr;
}
/*
* Release references taken in the case where all references could not
const char *chunk_name_override)
{
int ret;
- struct lttng_trace_chunk *trace_chunk = NULL;
+ struct lttng_trace_chunk *trace_chunk = nullptr;
enum lttng_trace_chunk_status chunk_status;
- const time_t chunk_creation_ts = time(NULL);
+ const time_t chunk_creation_ts = time(nullptr);
bool is_local_trace;
const char *base_path;
- struct lttng_directory_handle *session_output_directory = NULL;
+ struct lttng_directory_handle *session_output_directory = nullptr;
const struct lttng_credentials session_credentials = {
.uid = LTTNG_OPTIONAL_INIT_VALUE(session->uid),
.gid = LTTNG_OPTIONAL_INIT_VALUE(session->gid),
if (!session->rotated) {
new_path = "";
} else {
- new_path = NULL;
+ new_path = nullptr;
}
} else {
new_path = DEFAULT_CHUNK_TMP_NEW_DIRECTORY;
}
chunk_status = lttng_trace_chunk_set_as_owner(trace_chunk, session_output_directory);
lttng_directory_handle_put(session_output_directory);
- session_output_directory = NULL;
+ session_output_directory = nullptr;
if (chunk_status != LTTNG_TRACE_CHUNK_STATUS_OK) {
goto error;
}
error:
lttng_directory_handle_put(session_output_directory);
lttng_trace_chunk_put(trace_chunk);
- trace_chunk = NULL;
+ trace_chunk = nullptr;
goto end;
}
struct cds_lfht_iter iter;
struct consumer_socket *socket;
enum lttng_trace_chunk_status chunk_status;
- const time_t chunk_close_timestamp = time(NULL);
+ const time_t chunk_close_timestamp = time(nullptr);
const char *new_path;
chunk_status = lttng_trace_chunk_set_close_command(trace_chunk, close_command);
new_path = "";
} else {
/* Use chunk name for new chunk. */
- new_path = NULL;
+ new_path = nullptr;
}
if (session->current_trace_chunk &&
!lttng_trace_chunk_get_name_overridden(session->current_trace_chunk)) {
if (!session->rotated) {
old_path = "";
} else {
- old_path = NULL;
+ old_path = nullptr;
}
/* We need to move back the .tmp_old_chunk to its rightful place. */
chunk_status = lttng_trace_chunk_rename_path(trace_chunk, old_path);
consumer_output_put(session->consumer);
kernel_free_session(ksess);
- session->kernel_session = NULL;
+ session->kernel_session = nullptr;
if (usess) {
trace_ust_free_session(usess);
- session->ust_session = NULL;
+ session->ust_session = nullptr;
}
lttng_dynamic_array_reset(&session->destroy_notifiers);
lttng_dynamic_array_reset(&session->clear_notifiers);
}
}
- return NULL;
+ return nullptr;
found:
- return session_get(iter) ? iter : NULL;
+ return session_get(iter) ? iter : nullptr;
}
/*
lttng_ht_lookup(ltt_sessions_ht_by_id, &id, &iter);
node = lttng_ht_iter_get_node_u64(&iter);
- if (node == NULL) {
+ if (node == nullptr) {
goto end;
}
ls = lttng::utils::container_of(node, <t_session::node);
DBG3("Session %" PRIu64 " found by id.", id);
- return session_get(ls) ? ls : NULL;
+ return session_get(ls) ? ls : nullptr;
end:
DBG3("Session %" PRIu64 " NOT found by id", id);
- return NULL;
+ return nullptr;
}
/*
{
int ret;
enum lttng_error_code ret_code;
- struct ltt_session *new_session = NULL;
+ struct ltt_session *new_session = nullptr;
ASSERT_LOCKED(the_session_list.lock);
if (name) {
lttng_dynamic_array_init(&new_session->destroy_notifiers,
sizeof(struct ltt_session_destroy_notifier_element),
- NULL);
+ nullptr);
lttng_dynamic_array_init(&new_session->clear_notifiers,
sizeof(struct ltt_session_clear_notifier_element),
- NULL);
+ nullptr);
urcu_ref_init(&new_session->ref);
- pthread_mutex_init(&new_session->lock, NULL);
+ pthread_mutex_init(&new_session->lock, nullptr);
- new_session->creation_time = time(NULL);
+ new_session->creation_time = time(nullptr);
if (new_session->creation_time == (time_t) -1) {
PERROR("Failed to sample session creation time");
ret_code = LTTNG_ERR_SESSION_FAIL;
/* Create default consumer output. */
new_session->consumer = consumer_create_output(CONSUMER_DST_LOCAL);
- if (new_session->consumer == NULL) {
+ if (new_session->consumer == nullptr) {
ret_code = LTTNG_ERR_NOMEM;
goto error;
}
return ret_code;
error:
session_put(new_session);
- new_session = NULL;
+ new_session = nullptr;
goto end;
}
LTTNG_ASSERT(chunk_status == LTTNG_TRACE_CHUNK_STATUS_OK);
LTTNG_OPTIONAL_SET(&session->last_archived_chunk_id, chunk_id);
lttng_trace_chunk_put(session->chunk_being_archived);
- session->chunk_being_archived = NULL;
+ session->chunk_being_archived = nullptr;
/*
* Fire the clear reply notifiers if we are completing a clear
* rotation.
lttng_ht_lookup(ltt_sessions_ht_by_name, name, &iter);
node = lttng_ht_iter_get_node_str(&iter);
- if (node == NULL) {
+ if (node == nullptr) {
found = false;
goto end;
}
* In other words, it prevents tracer configurations from changing while they
* are being transmitted to the various applications.
*/
-void session_lock_list(void);
-int session_trylock_list(void);
-void session_unlock_list(void);
+void session_lock_list();
+int session_trylock_list();
+void session_unlock_list();
void session_destroy(struct ltt_session *session);
int session_add_destroy_notifier(struct ltt_session *session,
struct ltt_session *session_find_by_name(const char *name);
struct ltt_session *session_find_by_id(ltt_session::id_t id);
-struct ltt_session_list *session_get_list(void);
-void session_list_wait_empty(void);
+struct ltt_session_list *session_get_list();
+void session_list_wait_empty();
bool session_access_ok(struct ltt_session *session, uid_t uid);
static void config_string_fini(struct config_string *str)
{
- config_string_set(str, NULL);
+ config_string_set(str, nullptr);
}
static void config_string_set_static(struct config_string *config_str, const char *value)
const char *home_path = utils_get_home_dir();
char *str;
- if (home_path == NULL) {
+ if (home_path == nullptr) {
ERR("Can't get HOME directory for sockets creation.");
ret = -1;
goto end;
goto end;
}
config_string_set(&config->rundir, str);
- str = NULL;
+ str = nullptr;
ret = asprintf(&str, DEFAULT_HOME_APPS_UNIX_SOCK, home_path);
if (ret < 0) {
goto end;
}
config_string_set(&config->apps_unix_sock_path, str);
- str = NULL;
+ str = nullptr;
ret = asprintf(&str, DEFAULT_HOME_CLIENT_UNIX_SOCK, home_path);
if (ret < 0) {
goto end;
}
config_string_set(&config->client_unix_sock_path, str);
- str = NULL;
+ str = nullptr;
ret = asprintf(&str, DEFAULT_HOME_APPS_WAIT_SHM_PATH, getuid());
if (ret < 0) {
goto end;
}
config_string_set(&config->wait_shm_path, str);
- str = NULL;
+ str = nullptr;
ret = asprintf(&str, DEFAULT_HOME_HEALTH_UNIX_SOCK, home_path);
if (ret < 0) {
goto end;
}
config_string_set(&config->health_unix_sock_path, str);
- str = NULL;
+ str = nullptr;
ret = 0;
end:
goto error;
}
config_string_set(&config->consumerd32_path, str);
- str = NULL;
+ str = nullptr;
ret = asprintf(&str, DEFAULT_USTCONSUMERD32_ERR_SOCK_PATH, config->rundir.value);
if (ret < 0) {
goto error;
}
config_string_set(&config->consumerd32_err_unix_sock_path, str);
- str = NULL;
+ str = nullptr;
ret = asprintf(&str, DEFAULT_USTCONSUMERD32_CMD_SOCK_PATH, config->rundir.value);
if (ret < 0) {
goto error;
}
config_string_set(&config->consumerd32_cmd_unix_sock_path, str);
- str = NULL;
+ str = nullptr;
/* 64 bits consumerd path setup */
ret = asprintf(&str, DEFAULT_USTCONSUMERD64_PATH, config->rundir.value);
goto error;
}
config_string_set(&config->consumerd64_path, str);
- str = NULL;
+ str = nullptr;
ret = asprintf(&str, DEFAULT_USTCONSUMERD64_ERR_SOCK_PATH, config->rundir.value);
if (ret < 0) {
goto error;
}
config_string_set(&config->consumerd64_err_unix_sock_path, str);
- str = NULL;
+ str = nullptr;
ret = asprintf(&str, DEFAULT_USTCONSUMERD64_CMD_SOCK_PATH, config->rundir.value);
if (ret < 0) {
goto error;
}
config_string_set(&config->consumerd64_cmd_unix_sock_path, str);
- str = NULL;
+ str = nullptr;
/* kconsumerd consumerd path setup */
ret = asprintf(&str, DEFAULT_KCONSUMERD_PATH, config->rundir.value);
goto error;
}
config_string_set(&config->kconsumerd_path, str);
- str = NULL;
+ str = nullptr;
ret = asprintf(&str, DEFAULT_KCONSUMERD_ERR_SOCK_PATH, config->rundir.value);
if (ret < 0) {
goto error;
}
config_string_set(&config->kconsumerd_err_unix_sock_path, str);
- str = NULL;
+ str = nullptr;
ret = asprintf(&str, DEFAULT_KCONSUMERD_CMD_SOCK_PATH, config->rundir.value);
if (ret < 0) {
goto error;
}
config_string_set(&config->kconsumerd_cmd_unix_sock_path, str);
- str = NULL;
+ str = nullptr;
ret = asprintf(&str, "%s/%s", config->rundir.value, DEFAULT_LTTNG_SESSIOND_PIDFILE);
if (ret < 0) {
goto error;
}
config_string_set(&config->pid_file_path, str);
- str = NULL;
+ str = nullptr;
ret = asprintf(&str, "%s/%s", config->rundir.value, DEFAULT_LTTNG_SESSIOND_LOCKFILE);
if (ret < 0) {
goto error;
}
config_string_set(&config->lock_file_path, str);
- str = NULL;
+ str = nullptr;
ret = asprintf(&str, "%s/%s", config->rundir.value, DEFAULT_LTTNG_SESSIOND_AGENTPORT_FILE);
if (ret < 0) {
goto error;
}
config_string_set(&config->agent_port_file_path, str);
- str = NULL;
+ str = nullptr;
/*
* Allow INSTALL_BIN_PATH to be used as a target path for the
struct snapshot *snapshot)
{
int ret = 0, nb_uri;
- struct lttng_uri *uris = NULL;
+ struct lttng_uri *uris = nullptr;
/* Create an array of URIs from URLs. */
nb_uri = uri_parse_str_urls(ctrl_url, data_url, &uris);
return ret;
}
-struct snapshot_output *snapshot_output_alloc(void)
+struct snapshot_output *snapshot_output_alloc()
{
return zmalloc<snapshot_output>();
}
struct snapshot_output *snapshot_find_output_by_name(const char *name, struct snapshot *snapshot)
{
struct lttng_ht_iter iter;
- struct snapshot_output *output = NULL;
+ struct snapshot_output *output = nullptr;
LTTNG_ASSERT(snapshot);
LTTNG_ASSERT(name);
}
/* Not found */
- return NULL;
+ return nullptr;
}
/*
{
struct lttng_ht_node_ulong *node;
struct lttng_ht_iter iter;
- struct snapshot_output *output = NULL;
+ struct snapshot_output *output = nullptr;
LTTNG_ASSERT(snapshot);
ASSERT_RCU_READ_LOCKED();
};
/* Snapshot object. */
-struct snapshot *snapshot_alloc(void);
+struct snapshot *snapshot_alloc();
void snapshot_destroy(struct snapshot *obj);
int snapshot_init(struct snapshot *obj);
void snapshot_delete_output(struct snapshot *snapshot,
struct snapshot_output *output);
/* Snapshot output object. */
-struct snapshot_output *snapshot_output_alloc(void);
+struct snapshot_output *snapshot_output_alloc();
void snapshot_output_destroy(struct snapshot_output *obj);
int snapshot_output_init(const struct ltt_session *session,
uint64_t max_size, const char *name,
*
* Return -1 on error or 0 if all pipes are created.
*/
-int sessiond_init_main_quit_pipe(void)
+int sessiond_init_main_quit_pipe()
{
int ret, i;
return ret;
}
-int sessiond_notify_main_quit_pipe(void)
+int sessiond_notify_main_quit_pipe()
{
return notify_thread_pipe(main_quit_pipe[1]);
}
-void sessiond_close_main_quit_pipe(void)
+void sessiond_close_main_quit_pipe()
{
utils_close_pipe(main_quit_pipe);
}
/* Release initial reference. */
lttng_thread_put(thread);
error_alloc:
- return NULL;
+ return nullptr;
}
bool lttng_thread_get(struct lttng_thread *thread)
return result;
}
-void lttng_thread_list_shutdown_orphans(void)
+void lttng_thread_list_shutdown_orphans()
{
struct lttng_thread *thread, *tmp;
*
* Returns once all orphaned threads have been joined.
*/
-void lttng_thread_list_shutdown_orphans(void);
+void lttng_thread_list_shutdown_orphans();
#endif /* THREAD_H */
its.it_interval.tv_nsec = its.it_value.tv_nsec;
}
- ret = timer_settime(*timer_id, 0, &its, NULL);
+ ret = timer_settime(*timer_id, 0, &its, nullptr);
if (ret == -1) {
PERROR("timer_settime");
goto error_destroy_timer;
}
timer_signal_thread_qs(signal);
- *timer_id = 0;
+ *timer_id = nullptr;
end:
return ret;
}
* Block the RT signals for the entire process. It must be called from the
* sessiond main before creating the threads
*/
-int timer_signal_init(void)
+int timer_signal_init()
{
int ret;
sigset_t mask;
/* Block signal for entire process, so only our thread processes it. */
setmask(&mask);
- ret = pthread_sigmask(SIG_BLOCK, &mask, NULL);
+ ret = pthread_sigmask(SIG_BLOCK, &mask, nullptr);
if (ret) {
errno = ret;
PERROR("pthread_sigmask");
setmask(&mask);
CMM_STORE_SHARED(timer_signal.tid, pthread_self());
- while (1) {
+ while (true) {
health_code_update();
health_poll_entry();
health_unregister(the_health_sessiond);
rcu_thread_offline();
rcu_unregister_thread();
- return NULL;
+ return nullptr;
}
static bool shutdown_timer_thread(void *data __attribute__((unused)))
struct lttng_thread *thread;
thread = lttng_thread_create(
- "Timer", thread_timer, shutdown_timer_thread, NULL, timer_thread_parameters);
+ "Timer", thread_timer, shutdown_timer_thread, nullptr, timer_thread_parameters);
if (!thread) {
goto error;
}
}
}
- return NULL;
+ return nullptr;
}
/*
DBG("Found event %s for channel %s", name, channel->channel->name);
return ev;
} else {
- return NULL;
+ return nullptr;
}
}
DBG("Found event %s for channel %s", name, channel->channel->name);
return ev;
} else {
- return NULL;
+ return nullptr;
}
}
*
* Return pointer to structure or NULL.
*/
-struct ltt_kernel_session *trace_kernel_create_session(void)
+struct ltt_kernel_session *trace_kernel_create_session()
{
- struct ltt_kernel_session *lks = NULL;
+ struct ltt_kernel_session *lks = nullptr;
/* Allocate a new ltt kernel session */
lks = zmalloc<ltt_kernel_session>();
- if (lks == NULL) {
+ if (lks == nullptr) {
PERROR("create kernel session zmalloc");
goto alloc_error;
}
lks->metadata_stream_fd = -1;
lks->channel_count = 0;
lks->stream_count_global = 0;
- lks->metadata = NULL;
+ lks->metadata = nullptr;
CDS_INIT_LIST_HEAD(&lks->channel_list.head);
lks->tracker_pid = process_attr_tracker_create();
goto error;
}
lks->consumer = consumer_create_output(CONSUMER_DST_LOCAL);
- if (lks->consumer == NULL) {
+ if (lks->consumer == nullptr) {
goto error;
}
free(lks);
alloc_error:
- return NULL;
+ return nullptr;
}
/*
struct ltt_kernel_channel *trace_kernel_create_channel(struct lttng_channel *chan)
{
struct ltt_kernel_channel *lkc;
- struct lttng_channel_extended *extended = NULL;
+ struct lttng_channel_extended *extended = nullptr;
LTTNG_ASSERT(chan);
lkc = zmalloc<ltt_kernel_channel>();
- if (lkc == NULL) {
+ if (lkc == nullptr) {
PERROR("ltt_kernel_channel zmalloc");
goto error;
}
lkc->channel = zmalloc<lttng_channel>();
- if (lkc->channel == NULL) {
+ if (lkc->channel == nullptr) {
PERROR("lttng_channel zmalloc");
goto error;
}
memcpy(lkc->channel, chan, sizeof(struct lttng_channel));
memcpy(extended, chan->attr.extended.ptr, sizeof(struct lttng_channel_extended));
lkc->channel->attr.extended.ptr = extended;
- extended = NULL;
+ extended = nullptr;
/*
* If we receive an empty string for channel name, it means the
}
free(extended);
free(lkc);
- return NULL;
+ return nullptr;
}
/*
enum lttng_error_code ret;
struct lttng_kernel_abi_event *attr;
struct ltt_kernel_event *local_kernel_event;
- struct lttng_userspace_probe_location *userspace_probe_location = NULL;
+ struct lttng_userspace_probe_location *userspace_probe_location = nullptr;
LTTNG_ASSERT(ev);
local_kernel_event = zmalloc<ltt_kernel_event>();
attr = zmalloc<lttng_kernel_abi_event>();
- if (local_kernel_event == NULL || attr == NULL) {
+ if (local_kernel_event == nullptr || attr == nullptr) {
PERROR("kernel event zmalloc");
ret = LTTNG_ERR_NOMEM;
goto error;
break;
case LTTNG_EVENT_USERSPACE_PROBE:
{
- const struct lttng_userspace_probe_location *location = NULL;
- const struct lttng_userspace_probe_location_lookup_method *lookup = NULL;
+ const struct lttng_userspace_probe_location *location = nullptr;
+ const struct lttng_userspace_probe_location_lookup_method *lookup = nullptr;
location = lttng_event_get_userspace_probe_location(ev);
if (!location) {
enum lttng_event_rule_type event_rule_type;
enum lttng_condition_status condition_status;
struct ltt_kernel_event_notifier_rule *local_kernel_token_event_rule;
- const struct lttng_condition *condition = NULL;
- const struct lttng_event_rule *event_rule = NULL;
+ const struct lttng_condition *condition = nullptr;
+ const struct lttng_event_rule *event_rule = nullptr;
LTTNG_ASSERT(event_notifier_rule);
LTTNG_ASSERT(event_rule_type != LTTNG_EVENT_RULE_TYPE_UNKNOWN);
local_kernel_token_event_rule = zmalloc<ltt_kernel_event_notifier_rule>();
- if (local_kernel_token_event_rule == NULL) {
+ if (local_kernel_token_event_rule == nullptr) {
PERROR("Failed to allocate ltt_kernel_token_event_rule structure");
ret = LTTNG_ERR_NOMEM;
goto error;
case LTTNG_EVENT_RULE_TYPE_KERNEL_KPROBE:
{
uint64_t address = 0, offset = 0;
- const char *symbol_name = NULL;
- const struct lttng_kernel_probe_location *location = NULL;
+ const char *symbol_name = nullptr;
+ const struct lttng_kernel_probe_location *location = nullptr;
enum lttng_kernel_probe_location_status k_status;
enum lttng_event_rule_status status;
}
case LTTNG_EVENT_RULE_TYPE_KERNEL_UPROBE:
{
- const struct lttng_userspace_probe_location *location = NULL;
- const struct lttng_userspace_probe_location_lookup_method *lookup = NULL;
+ const struct lttng_userspace_probe_location *location = nullptr;
+ const struct lttng_userspace_probe_location_lookup_method *lookup = nullptr;
enum lttng_event_rule_status status;
status = lttng_event_rule_kernel_uprobe_get_location(rule, &location);
*
* Return pointer to structure or NULL.
*/
-struct ltt_kernel_metadata *trace_kernel_create_metadata(void)
+struct ltt_kernel_metadata *trace_kernel_create_metadata()
{
int ret;
struct ltt_kernel_metadata *lkm;
lkm = zmalloc<ltt_kernel_metadata>();
chan = zmalloc<lttng_channel>();
- if (lkm == NULL || chan == NULL) {
+ if (lkm == nullptr || chan == nullptr) {
PERROR("kernel metadata zmalloc");
goto error;
}
error:
free(lkm);
free(chan);
- return NULL;
+ return nullptr;
}
/*
LTTNG_ASSERT(name);
lks = zmalloc<ltt_kernel_stream>();
- if (lks == NULL) {
+ if (lks == nullptr) {
PERROR("kernel stream zmalloc");
goto error;
}
return lks;
error:
- return NULL;
+ return nullptr;
}
/*
}
}
- if (session->metadata != NULL) {
+ if (session->metadata != nullptr) {
trace_kernel_destroy_metadata(session->metadata);
}
/*
* Create functions malloc() the data structure.
*/
-struct ltt_kernel_session *trace_kernel_create_session(void);
+struct ltt_kernel_session *trace_kernel_create_session();
struct ltt_kernel_channel *trace_kernel_create_channel(
struct lttng_channel *chan);
enum lttng_error_code trace_kernel_create_event(struct lttng_event *ev,
char *filter_expression, struct lttng_bytecode *filter,
struct ltt_kernel_event **kernel_event);
-struct ltt_kernel_metadata *trace_kernel_create_metadata(void);
+struct ltt_kernel_metadata *trace_kernel_create_metadata();
struct ltt_kernel_stream *trace_kernel_create_stream(const char *name,
unsigned int count);
struct ltt_kernel_context *trace_kernel_create_context(
lttng_ht_lookup(ht, (void *) name, &iter);
node = lttng_ht_iter_get_node_str(&iter);
- if (node == NULL) {
+ if (node == nullptr) {
goto error;
}
error:
DBG2("Trace UST channel %s not found by name", name);
- return NULL;
+ return nullptr;
}
/*
&key,
&iter.iter);
node = lttng_ht_iter_get_node_str(&iter);
- if (node == NULL) {
+ if (node == nullptr) {
goto error;
}
error:
DBG2("Trace UST event %s NOT found", key.name);
- return NULL;
+ return nullptr;
}
/*
struct agent *trace_ust_find_agent(struct ltt_ust_session *session,
enum lttng_domain_type domain_type)
{
- struct agent *agt = NULL;
+ struct agent *agt = nullptr;
struct lttng_ht_node_u64 *node;
struct lttng_ht_iter iter;
uint64_t key;
/* Allocate a new ltt ust session */
lus = zmalloc<ltt_ust_session>();
- if (lus == NULL) {
+ if (lus == nullptr) {
PERROR("create ust session zmalloc");
goto error_alloc;
}
goto error;
}
lus->consumer = consumer_create_output(CONSUMER_DST_LOCAL);
- if (lus->consumer == NULL) {
+ if (lus->consumer == nullptr) {
goto error;
}
lttng_ht_destroy(lus->agents);
free(lus);
error_alloc:
- return NULL;
+ return nullptr;
}
/*
LTTNG_ASSERT(chan);
luc = zmalloc<ltt_ust_channel>();
- if (luc == NULL) {
+ if (luc == nullptr) {
PERROR("ltt_ust_channel zmalloc");
goto error;
}
}
local_ust_event = zmalloc<ltt_ust_event>();
- if (local_ust_event == NULL) {
+ if (local_ust_event == nullptr) {
PERROR("ust event zmalloc");
ret = LTTNG_ERR_NOMEM;
goto error;
*/
struct ltt_ust_context *trace_ust_create_context(const struct lttng_event_context *ctx)
{
- struct ltt_ust_context *uctx = NULL;
+ struct ltt_ust_context *uctx = nullptr;
int utype;
LTTNG_ASSERT(ctx);
break;
case LTTNG_UST_ABI_CONTEXT_APP_CONTEXT:
{
- char *provider_name = NULL, *ctx_name = NULL;
+ char *provider_name = nullptr, *ctx_name = nullptr;
provider_name = strdup(ctx->u.app_ctx.provider_name);
if (!provider_name) {
return uctx;
error:
trace_ust_destroy_context(uctx);
- return NULL;
+ return nullptr;
}
static void destroy_id_tracker_node_rcu(struct rcu_head *head)
}
rcu_read_unlock();
lttng_ht_destroy(id_tracker->ht);
- id_tracker->ht = NULL;
+ id_tracker->ht = nullptr;
}
static struct ust_id_tracker_node *
if (node) {
return lttng::utils::container_of(node, &ust_id_tracker_node::node);
} else {
- return NULL;
+ return nullptr;
}
}
case LTTNG_PROCESS_ATTR_VIRTUAL_GROUP_ID:
return &session->vgid_tracker;
default:
- return NULL;
+ return nullptr;
}
}
case LTTNG_PROCESS_ATTR_VIRTUAL_GROUP_ID:
return session->tracker_vgid;
default:
- return NULL;
+ return nullptr;
}
}
int trace_ust_regenerate_metadata(struct ltt_ust_session *usess)
{
int ret = 0;
- struct buffer_reg_uid *uid_reg = NULL;
- struct buffer_reg_session *session_reg = NULL;
+ struct buffer_reg_uid *uid_reg = nullptr;
+ struct buffer_reg_session *session_reg = nullptr;
rcu_read_lock();
cds_list_for_each_entry (uid_reg, &usess->buffer_reg_uid_list, lnode) {
free(node);
}
-struct process_attr_tracker *process_attr_tracker_create(void)
+struct process_attr_tracker *process_attr_tracker_create()
{
struct process_attr_tracker *tracker;
tracker = zmalloc<process_attr_tracker>();
if (!tracker) {
- return NULL;
+ return nullptr;
}
(void) process_attr_tracker_set_tracking_policy(tracker, LTTNG_TRACKING_POLICY_INCLUDE_ALL);
tracker->inclusion_set_ht = cds_lfht_new(
- DEFAULT_HT_SIZE, 1, 0, CDS_LFHT_AUTO_RESIZE | CDS_LFHT_ACCOUNTING, NULL);
+ DEFAULT_HT_SIZE, 1, 0, CDS_LFHT_AUTO_RESIZE | CDS_LFHT_ACCOUNTING, nullptr);
if (!tracker->inclusion_set_ht) {
goto error;
}
return tracker;
error:
process_attr_tracker_destroy(tracker);
- return NULL;
+ return nullptr;
}
static void
process_attr_tracker_remove_value_node(tracker, value_node);
}
rcu_read_unlock();
- ret = cds_lfht_destroy(tracker->inclusion_set_ht, NULL);
+ ret = cds_lfht_destroy(tracker->inclusion_set_ht, nullptr);
LTTNG_ASSERT(ret == 0);
- tracker->inclusion_set_ht = NULL;
+ tracker->inclusion_set_ht = nullptr;
}
static int process_attr_tracker_create_inclusion_set(struct process_attr_tracker *tracker)
{
LTTNG_ASSERT(!tracker->inclusion_set_ht);
tracker->inclusion_set_ht = cds_lfht_new(
- DEFAULT_HT_SIZE, 1, 0, CDS_LFHT_AUTO_RESIZE | CDS_LFHT_ACCOUNTING, NULL);
+ DEFAULT_HT_SIZE, 1, 0, CDS_LFHT_AUTO_RESIZE | CDS_LFHT_ACCOUNTING, nullptr);
return tracker->inclusion_set_ht ? 0 : -1;
}
return node ? lttng::utils::container_of(
node, &process_attr_tracker_value_node::inclusion_set_ht_node) :
- NULL;
+ nullptr;
}
/* Protected by session mutex held by caller. */
const struct process_attr_value *value)
{
enum process_attr_tracker_status status = PROCESS_ATTR_TRACKER_STATUS_OK;
- struct process_attr_value *value_copy = NULL;
- struct process_attr_tracker_value_node *value_node = NULL;
+ struct process_attr_value *value_copy = nullptr;
+ struct process_attr_tracker_value_node *value_node = nullptr;
rcu_read_lock();
if (tracker->policy != LTTNG_TRACKING_POLICY_INCLUDE_SET) {
cds_lfht_add(tracker->inclusion_set_ht,
process_attr_value_hash(value_copy),
&value_node->inclusion_set_ht_node);
- value_copy = NULL;
- value_node = NULL;
+ value_copy = nullptr;
+ value_node = nullptr;
end:
if (value_copy) {
process_attr_value_destroy(value_copy);
struct process_attr_tracker_value_node *value_node;
enum process_attr_tracker_status status = PROCESS_ATTR_TRACKER_STATUS_OK;
struct lttng_process_attr_values *values;
- struct process_attr_value *new_value = NULL;
+ struct process_attr_value *new_value = nullptr;
values = lttng_process_attr_values_create();
if (!values) {
goto error_unlock;
}
- new_value = NULL;
+ new_value = nullptr;
}
rcu_read_unlock();
*_values = values;
PROCESS_ATTR_TRACKER_STATUS_INVALID_TRACKING_POLICY,
};
-struct process_attr_tracker *process_attr_tracker_create(void);
+struct process_attr_tracker *process_attr_tracker_create();
void process_attr_tracker_destroy(struct process_attr_tracker *tracker);
enum lttng_tracking_policy process_attr_tracker_get_tracking_policy(
enum lttng_trigger_status status;
uint64_t discarded_tracer_messages_count;
enum event_notifier_error_accounting_status error_accounting_status;
- struct lttng_error_query_result *discarded_tracer_messages_counter = NULL;
+ struct lttng_error_query_result *discarded_tracer_messages_counter = nullptr;
const char *trigger_name;
uid_t trigger_owner;
}
/* Ownership transferred to the results. */
- discarded_tracer_messages_counter = NULL;
+ discarded_tracer_messages_counter = nullptr;
status = LTTNG_TRIGGER_STATUS_OK;
end:
#include <set>
#include <stack>
#include <unordered_set>
+#include <utility>
namespace lst = lttng::sessiond::trace;
namespace tsdl = lttng::sessiond::tsdl;
variant_tsdl_keyword_sanitizer(tsdl::details::type_overrider& type_overrides,
type_lookup_function lookup_type) :
- _type_overrides{ type_overrides }, _lookup_type(lookup_type)
+ _type_overrides{ type_overrides }, _lookup_type(std::move(lookup_type))
{
}
};
using unsafe_names = std::set<const char *, _c_string_comparator>;
- virtual void visit(const lst::field& field) override final
+ void visit(const lst::field& field) final
{
_type_overrides.type(field.get_type()).accept(*this);
}
- virtual void visit(const lst::integer_type& type __attribute__((unused))) override final
+ void visit(const lst::integer_type& type __attribute__((unused))) final
{
}
- virtual void visit(const lst::floating_point_type& type
- __attribute__((unused))) override final
+ void visit(const lst::floating_point_type& type __attribute__((unused))) final
{
}
- virtual void visit(const lst::signed_enumeration_type& type
- __attribute__((unused))) override final
+ void visit(const lst::signed_enumeration_type& type __attribute__((unused))) final
{
}
- virtual void visit(const lst::unsigned_enumeration_type& type
- __attribute__((unused))) override final
+ void visit(const lst::unsigned_enumeration_type& type __attribute__((unused))) final
{
}
- virtual void visit(const lst::static_length_array_type& type
- __attribute__((unused))) override final
+ void visit(const lst::static_length_array_type& type __attribute__((unused))) final
{
}
- virtual void visit(const lst::dynamic_length_array_type& type
- __attribute__((unused))) override final
+ void visit(const lst::dynamic_length_array_type& type __attribute__((unused))) final
{
}
- virtual void visit(const lst::static_length_blob_type& type
- __attribute__((unused))) override final
+ void visit(const lst::static_length_blob_type& type __attribute__((unused))) final
{
}
- virtual void visit(const lst::dynamic_length_blob_type& type
- __attribute__((unused))) override final
+ void visit(const lst::dynamic_length_blob_type& type __attribute__((unused))) final
{
}
- virtual void visit(const lst::null_terminated_string_type& type
- __attribute__((unused))) override final
+ void visit(const lst::null_terminated_string_type& type __attribute__((unused))) final
{
}
- virtual void visit(const lst::structure_type& type) override final
+ void visit(const lst::structure_type& type) final
{
/* Recurse into structure attributes. */
for (const auto& field : type.fields_) {
_type_overrides.publish(type, std::move(sanitized_variant_type));
}
- virtual void visit(const lst::variant_type<
- lst::signed_enumeration_type::mapping::range_t::range_integer_t>& type)
- override final
+ void visit(const lst::variant_type<
+ lst::signed_enumeration_type::mapping::range_t::range_integer_t>& type) final
{
visit_variant(type);
}
- virtual void visit(const lst::variant_type<
- lst::unsigned_enumeration_type::mapping::range_t::range_integer_t>& type)
- override final
+ void visit(const lst::variant_type<
+ lst::unsigned_enumeration_type::mapping::range_t::range_integer_t>& type) final
{
visit_variant(type);
}
- virtual void visit(const lst::static_length_string_type& type
- __attribute__((unused))) override final
+ void visit(const lst::static_length_string_type& type __attribute__((unused))) final
{
}
- virtual void visit(const lst::dynamic_length_string_type& type
- __attribute__((unused))) override final
+ void visit(const lst::dynamic_length_string_type& type __attribute__((unused))) final
{
}
nonstd::nullopt) :
_indentation_level{ indentation_level },
_trace_abi{ abi },
- _bypass_identifier_escape{ false },
+
_default_clock_class_name{ in_default_clock_class_name ?
in_default_clock_class_name->c_str() :
nullptr },
}
private:
- virtual void visit(const lst::field& field) override final
+ void visit(const lst::field& field) final
{
/*
* Hack: keep the name of the field being visited since
_description += ";";
}
- virtual void visit(const lst::integer_type& type) override final
+ void visit(const lst::integer_type& type) final
{
_description += "integer { ";
_description += " }";
}
- virtual void visit(const lst::floating_point_type& type) override final
+ void visit(const lst::floating_point_type& type) final
{
_description += fmt::format(
"floating_point {{ align = {alignment}; mant_dig = {mantissa_digits}; exp_dig = {exponent_digits};",
_description += "}";
}
- virtual void visit(const lst::signed_enumeration_type& type) override final
+ void visit(const lst::signed_enumeration_type& type) final
{
visit_enumeration(type);
}
- virtual void visit(const lst::unsigned_enumeration_type& type) override final
+ void visit(const lst::unsigned_enumeration_type& type) final
{
visit_enumeration(type);
}
- virtual void visit(const lst::static_length_array_type& type) override final
+ void visit(const lst::static_length_array_type& type) final
{
if (type.alignment != 0) {
LTTNG_ASSERT(_current_field_name.size() > 0);
_type_suffixes.emplace(fmt::format("[{}]", type.length));
}
- virtual void visit(const lst::dynamic_length_array_type& type) override final
+ void visit(const lst::dynamic_length_array_type& type) final
{
if (type.alignment != 0) {
/*
*(type.length_field_location.elements_.end() - 1))));
}
- virtual void visit(const lst::static_length_blob_type& type) override final
+ void visit(const lst::static_length_blob_type& type) final
{
/* This type doesn't exist in CTF 1.x, express it as a static length array of
* uint8_t. */
visit(*array);
}
- virtual void visit(const lst::dynamic_length_blob_type& type) override final
+ void visit(const lst::dynamic_length_blob_type& type) final
{
/* This type doesn't exist in CTF 1.x, express it as a dynamic length array of
* uint8_t. */
visit(*array);
}
- virtual void visit(const lst::null_terminated_string_type& type) override final
+ void visit(const lst::null_terminated_string_type& type) final
{
/* Defaults to UTF-8. */
if (type.encoding_ == lst::null_terminated_string_type::encoding::ASCII) {
}
}
- virtual void visit(const lst::structure_type& type) override final
+ void visit(const lst::structure_type& type) final
{
_indentation_level++;
_description += "struct {";
_description += "}";
}
- virtual void visit(const lst::variant_type<
- lst::signed_enumeration_type::mapping::range_t::range_integer_t>& type)
- override final
+ void visit(const lst::variant_type<
+ lst::signed_enumeration_type::mapping::range_t::range_integer_t>& type) final
{
visit_variant(type);
}
- virtual void visit(const lst::variant_type<
- lst::unsigned_enumeration_type::mapping::range_t::range_integer_t>& type)
- override final
+ void visit(const lst::variant_type<
+ lst::unsigned_enumeration_type::mapping::range_t::range_integer_t>& type) final
{
visit_variant(type);
}
lst::integer_type::base::DECIMAL);
}
- virtual void visit(const lst::static_length_string_type& type) override final
+ void visit(const lst::static_length_string_type& type) final
{
/*
* TSDL expresses static-length strings as arrays of 8-bit integer with
visit(*char_array);
}
- virtual void visit(const lst::dynamic_length_string_type& type) override final
+ void visit(const lst::dynamic_length_string_type& type) final
{
/*
* TSDL expresses dynamic-length strings as arrays of 8-bit integer with
/* Description in TSDL format. */
std::string _description;
- bool _bypass_identifier_escape;
+ bool _bypass_identifier_escape{ false };
const char *_default_clock_class_name;
const tsdl::details::type_overrider& _type_overrides;
};
{
}
- virtual void visit(const lst::environment_field<int64_t>& field) override
+ void visit(const lst::environment_field<int64_t>& field) override
{
_environment += fmt::format(" {} = {};\n", field.name, field.value);
}
- virtual void visit(const lst::environment_field<const char *>& field) override
+ void visit(const lst::environment_field<const char *>& field) override
{
- _environment += fmt::format(
- " {} = \"{}\";\n", field.name, escape_tsdl_env_string_value(field.value));
+ _environment += fmt::format(" {} = \"{}\";\n",
+ field.name,
+ escape_tsdl_env_string_value(field.value));
}
/* Only call once. */
tsdl::trace_class_visitor::trace_class_visitor(
const lst::abi& trace_abi,
tsdl::append_metadata_fragment_function append_metadata_fragment) :
- _trace_abi{ trace_abi }, _append_metadata_fragment(append_metadata_fragment)
+ _trace_abi{ trace_abi }, _append_metadata_fragment(std::move(append_metadata_fragment))
{
}
*/
static lsu::registry_session *get_session_registry(const struct ust_app_session *ua_sess)
{
- lsu::registry_session *registry = NULL;
+ lsu::registry_session *registry = nullptr;
LTTNG_ASSERT(ua_sess);
/*
* Return the incremented value of next_channel_key.
*/
-static uint64_t get_next_channel_key(void)
+static uint64_t get_next_channel_key()
{
uint64_t ret;
/*
* Return the atomically incremented value of next_session_id.
*/
-static uint64_t get_next_session_id(void)
+static uint64_t get_next_session_id()
{
uint64_t ret;
ASSERT_RCU_READ_LOCKED();
free(ua_event->filter);
- if (ua_event->exclusion != NULL)
+ if (ua_event->exclusion != nullptr)
free(ua_event->exclusion);
- if (ua_event->obj != NULL) {
+ if (ua_event->obj != nullptr) {
pthread_mutex_lock(&app->sock_lock);
ret = lttng_ust_ctl_release_object(sock, ua_event->obj);
pthread_mutex_unlock(&app->sock_lock);
LTTNG_ASSERT(ua_event_notifier_rule);
- if (ua_event_notifier_rule->exclusion != NULL) {
+ if (ua_event_notifier_rule->exclusion != nullptr) {
free(ua_event_notifier_rule->exclusion);
}
- if (ua_event_notifier_rule->obj != NULL) {
+ if (ua_event_notifier_rule->obj != nullptr) {
pthread_mutex_lock(&app->sock_lock);
ret = lttng_ust_ctl_release_object(sock, ua_event_notifier_rule->obj);
pthread_mutex_unlock(&app->sock_lock);
}
}
- if (ua_chan->obj != NULL) {
+ if (ua_chan->obj != nullptr) {
/* Remove channel from application UST object descriptor. */
iter.iter.node = &ua_chan->ust_objd_node.node;
ret = lttng_ht_del(app->ust_objd, &iter);
int send_zero_data)
{
int ret;
- char *metadata_str = NULL;
+ char *metadata_str = nullptr;
size_t len, offset, new_metadata_len_sent;
ssize_t ret_val;
uint64_t metadata_key, metadata_version;
/*
* Alloc new UST app session.
*/
-static struct ust_app_session *alloc_ust_app_session(void)
+static struct ust_app_session *alloc_ust_app_session()
{
struct ust_app_session *ua_sess;
/* Init most of the default value by allocating and zeroing */
ua_sess = zmalloc<ust_app_session>();
- if (ua_sess == NULL) {
+ if (ua_sess == nullptr) {
PERROR("malloc");
goto error_free;
}
ua_sess->handle = -1;
ua_sess->channels = lttng_ht_new(0, LTTNG_HT_TYPE_STRING);
ua_sess->metadata_attr.type = LTTNG_UST_ABI_CHAN_METADATA;
- pthread_mutex_init(&ua_sess->lock, NULL);
+ pthread_mutex_init(&ua_sess->lock, nullptr);
return ua_sess;
error_free:
- return NULL;
+ return nullptr;
}
/*
/* Init most of the default value by allocating and zeroing */
ua_chan = zmalloc<ust_app_channel>();
- if (ua_chan == NULL) {
+ if (ua_chan == nullptr) {
PERROR("malloc");
goto error;
}
return ua_chan;
error:
- return NULL;
+ return nullptr;
}
/*
*
* Return newly allocated stream pointer or NULL on error.
*/
-struct ust_app_stream *ust_app_alloc_stream(void)
+struct ust_app_stream *ust_app_alloc_stream()
{
- struct ust_app_stream *stream = NULL;
+ struct ust_app_stream *stream = nullptr;
stream = zmalloc<ust_app_stream>();
- if (stream == NULL) {
+ if (stream == nullptr) {
PERROR("zmalloc ust app stream");
goto error;
}
/* Init most of the default value by allocating and zeroing */
ua_event = zmalloc<ust_app_event>();
- if (ua_event == NULL) {
+ if (ua_event == nullptr) {
PERROR("Failed to allocate ust_app_event structure");
goto error;
}
return ua_event;
error:
- return NULL;
+ return nullptr;
}
/*
enum lttng_event_rule_generate_exclusions_status generate_exclusion_status;
enum lttng_condition_status cond_status;
struct ust_app_event_notifier_rule *ua_event_notifier_rule;
- struct lttng_condition *condition = NULL;
- const struct lttng_event_rule *event_rule = NULL;
+ struct lttng_condition *condition = nullptr;
+ const struct lttng_event_rule *event_rule = nullptr;
ua_event_notifier_rule = zmalloc<ust_app_event_notifier_rule>();
- if (ua_event_notifier_rule == NULL) {
+ if (ua_event_notifier_rule == nullptr) {
PERROR("Failed to allocate ust_app_event_notifier_rule structure");
goto error;
}
lttng_trigger_put(trigger);
error:
free(ua_event_notifier_rule);
- return NULL;
+ return nullptr;
}
/*
struct ust_app_ctx *ua_ctx;
ua_ctx = zmalloc<ust_app_ctx>();
- if (ua_ctx == NULL) {
+ if (ua_ctx == nullptr) {
goto error;
}
if (uctx) {
memcpy(&ua_ctx->ctx, uctx, sizeof(ua_ctx->ctx));
if (uctx->ctx == LTTNG_UST_ABI_CONTEXT_APP_CONTEXT) {
- char *provider_name = NULL, *ctx_name = NULL;
+ char *provider_name = nullptr, *ctx_name = nullptr;
provider_name = strdup(uctx->u.app_ctx.provider_name);
ctx_name = strdup(uctx->u.app_ctx.ctx_name);
return ua_ctx;
error:
free(ua_ctx);
- return NULL;
+ return nullptr;
}
/*
static struct lttng_ust_abi_filter_bytecode *
create_ust_filter_bytecode_from_bytecode(const struct lttng_bytecode *orig_f)
{
- struct lttng_ust_abi_filter_bytecode *filter = NULL;
+ struct lttng_ust_abi_filter_bytecode *filter = nullptr;
/* Copy filter bytecode. */
filter = zmalloc<lttng_ust_abi_filter_bytecode>(sizeof(*filter) + orig_f->len);
static struct lttng_ust_abi_capture_bytecode *
create_ust_capture_bytecode_from_bytecode(const struct lttng_bytecode *orig_f)
{
- struct lttng_ust_abi_capture_bytecode *capture = NULL;
+ struct lttng_ust_abi_capture_bytecode *capture = nullptr;
/* Copy capture bytecode. */
capture = zmalloc<lttng_ust_abi_capture_bytecode>(sizeof(*capture) + orig_f->len);
lttng_ht_lookup(ust_app_ht_by_sock, (void *) ((unsigned long) sock), &iter);
node = lttng_ht_iter_get_node_ulong(&iter);
- if (node == NULL) {
+ if (node == nullptr) {
DBG2("UST app find by sock %d not found", sock);
goto error;
}
return lttng::utils::container_of(node, &ust_app::sock_n);
error:
- return NULL;
+ return nullptr;
}
/*
lttng_ht_lookup(ust_app_ht_by_notify_sock, (void *) ((unsigned long) sock), &iter);
node = lttng_ht_iter_get_node_ulong(&iter);
- if (node == NULL) {
+ if (node == nullptr) {
DBG2("UST app find by notify sock %d not found", sock);
goto error;
}
return lttng::utils::container_of(node, &ust_app::notify_sock_n);
error:
- return NULL;
+ return nullptr;
}
/*
{
struct lttng_ht_iter iter;
struct lttng_ht_node_str *node;
- struct ust_app_event *event = NULL;
+ struct ust_app_event *event = nullptr;
struct ust_app_ht_key key;
LTTNG_ASSERT(name);
&key,
&iter.iter);
node = lttng_ht_iter_get_node_str(&iter);
- if (node == NULL) {
+ if (node == nullptr) {
goto end;
}
{
struct lttng_ht_iter iter;
struct lttng_ht_node_u64 *node;
- struct ust_app_event_notifier_rule *event_notifier_rule = NULL;
+ struct ust_app_event_notifier_rule *event_notifier_rule = nullptr;
LTTNG_ASSERT(ht);
ASSERT_RCU_READ_LOCKED();
lttng_ht_lookup(ht, &token, &iter);
node = lttng_ht_iter_get_node_u64(&iter);
- if (node == NULL) {
+ if (node == nullptr) {
DBG2("UST app event notifier rule token not found: token = %" PRIu64, token);
goto end;
}
struct lttng_ust_abi_object_data *ust_object)
{
int ret;
- struct lttng_ust_abi_filter_bytecode *ust_bytecode = NULL;
+ struct lttng_ust_abi_filter_bytecode *ust_bytecode = nullptr;
health_code_update();
struct lttng_ust_abi_object_data *ust_object)
{
int ret;
- struct lttng_ust_abi_capture_bytecode *ust_bytecode = NULL;
+ struct lttng_ust_abi_capture_bytecode *ust_bytecode = nullptr;
health_code_update();
static struct lttng_ust_abi_event_exclusion *
create_ust_exclusion_from_exclusion(const struct lttng_event_exclusion *exclusion)
{
- struct lttng_ust_abi_event_exclusion *ust_exclusion = NULL;
+ struct lttng_ust_abi_event_exclusion *ust_exclusion = nullptr;
size_t exclusion_alloc_size = sizeof(struct lttng_ust_abi_event_exclusion) +
LTTNG_UST_ABI_SYM_NAME_LEN * exclusion->count;
struct lttng_ust_abi_object_data *ust_object)
{
int ret;
- struct lttng_ust_abi_event_exclusion *ust_exclusions = NULL;
+ struct lttng_ust_abi_event_exclusion *ust_exclusions = nullptr;
LTTNG_ASSERT(exclusions && exclusions->count > 0);
{
int ret = 0;
enum lttng_condition_status condition_status;
- const struct lttng_condition *condition = NULL;
+ const struct lttng_condition *condition = nullptr;
struct lttng_ust_abi_event_notifier event_notifier;
- const struct lttng_event_rule *event_rule = NULL;
+ const struct lttng_event_rule *event_rule = nullptr;
unsigned int capture_bytecode_count = 0, i;
enum lttng_condition_status cond_status;
enum lttng_event_rule_type event_rule_type;
exclusion_alloc_size = sizeof(struct lttng_event_exclusion) +
LTTNG_UST_ABI_SYM_NAME_LEN * uevent->exclusion->count;
ua_event->exclusion = zmalloc<lttng_event_exclusion>(exclusion_alloc_size);
- if (ua_event->exclusion == NULL) {
+ if (ua_event->exclusion == nullptr) {
PERROR("malloc");
} else {
memcpy(ua_event->exclusion, uevent->exclusion, exclusion_alloc_size);
__lookup_session_by_app(usess, app, &iter);
node = lttng_ht_iter_get_node_u64(&iter);
- if (node == NULL) {
+ if (node == nullptr) {
goto error;
}
return lttng::utils::container_of(node, &ust_app_session::node);
error:
- return NULL;
+ return nullptr;
}
/*
* that if the buffer registry can be found, its ust registry is
* non-NULL.
*/
- buffer_reg_uid_destroy(reg_uid, NULL);
+ buffer_reg_uid_destroy(reg_uid, nullptr);
goto error;
}
health_code_update();
ua_sess = lookup_session_by_app(usess, app);
- if (ua_sess == NULL) {
+ if (ua_sess == nullptr) {
DBG2("UST app pid: %d session id %" PRIu64 " not found, creating it",
app->pid,
usess->id);
ua_sess = alloc_ust_app_session();
- if (ua_sess == NULL) {
+ if (ua_sess == nullptr) {
/* Only malloc can failed so something is really wrong */
ret = -ENOMEM;
goto error;
switch (usess->buffer_type) {
case LTTNG_BUFFER_PER_PID:
/* Init local registry. */
- ret = setup_buffer_reg_pid(ua_sess, app, NULL);
+ ret = setup_buffer_reg_pid(ua_sess, app, nullptr);
if (ret < 0) {
delete_ust_app_session(-1, ua_sess, app);
goto error;
break;
case LTTNG_BUFFER_PER_UID:
/* Look for a global registry. If none exists, create one. */
- ret = setup_buffer_reg_uid(usess, ua_sess, app, NULL);
+ ret = setup_buffer_reg_uid(usess, ua_sess, app, nullptr);
if (ret < 0) {
delete_ust_app_session(-1, ua_sess, app);
goto error;
{
struct lttng_ht_iter iter;
struct lttng_ht_node_ulong *node;
- struct ust_app_ctx *app_ctx = NULL;
+ struct ust_app_ctx *app_ctx = nullptr;
LTTNG_ASSERT(uctx);
LTTNG_ASSERT(ht);
}
ua_ctx = alloc_ust_app_ctx(uctx);
- if (ua_ctx == NULL) {
+ if (ua_ctx == nullptr) {
/* malloc failed */
ret = -ENOMEM;
goto error;
lttng_ht_lookup(ua_sess->channels, (void *) uchan->name, &iter);
ua_chan_node = lttng_ht_iter_get_node_str(&iter);
- if (ua_chan_node == NULL) {
+ if (ua_chan_node == nullptr) {
DBG2("Unable to find channel %s in ust session id %" PRIu64,
uchan->name,
ua_sess->tracing_id);
* stream call does not release the object.
*/
reg_stream->obj.ust = stream->obj;
- stream->obj = NULL;
+ stream->obj = nullptr;
buffer_reg_stream_add(reg_stream, buf_reg_chan);
/* We don't need the streams anymore. */
struct buffer_reg_channel **regp)
{
int ret;
- struct buffer_reg_channel *buf_reg_chan = NULL;
+ struct buffer_reg_channel *buf_reg_chan = nullptr;
LTTNG_ASSERT(reg_sess);
LTTNG_ASSERT(ua_chan);
}
buf_reg_chan->obj.ust = ua_chan->obj;
- ua_chan->obj = NULL;
+ ua_chan->obj = nullptr;
return 0;
int ret;
struct buffer_reg_uid *reg_uid;
struct buffer_reg_channel *buf_reg_chan;
- struct ltt_session *session = NULL;
+ struct ltt_session *session = nullptr;
enum lttng_error_code notification_ret;
LTTNG_ASSERT(app);
int ret;
lsu::registry_session *registry;
enum lttng_error_code cmd_ret;
- struct ltt_session *session = NULL;
+ struct ltt_session *session = nullptr;
uint64_t chan_reg_key;
LTTNG_ASSERT(app);
/* Lookup channel in the ust app session */
lttng_ht_lookup(ua_sess->channels, (void *) uchan->name, &iter);
ua_chan_node = lttng_ht_iter_get_node_str(&iter);
- if (ua_chan_node != NULL) {
+ if (ua_chan_node != nullptr) {
ua_chan = lttng::utils::container_of(ua_chan_node, &ust_app_channel::node);
goto end;
}
ua_chan = alloc_ust_app_channel(uchan->name, ua_sess, &uchan->attr);
- if (ua_chan == NULL) {
+ if (ua_chan == nullptr) {
/* Only malloc can fail here */
ret = -ENOMEM;
goto error;
ASSERT_RCU_READ_LOCKED();
ua_event = alloc_ust_app_event(uevent->attr.name, &uevent->attr);
- if (ua_event == NULL) {
+ if (ua_event == nullptr) {
/* Only failure mode of alloc_ust_app_event(). */
ret = -ENOMEM;
goto end;
ASSERT_RCU_READ_LOCKED();
ua_event_notifier_rule = alloc_ust_app_event_notifier_rule(trigger);
- if (ua_event_notifier_rule == NULL) {
+ if (ua_event_notifier_rule == nullptr) {
ret = -ENOMEM;
goto end;
}
int ret = 0;
struct ust_app_channel *metadata;
struct consumer_socket *socket;
- struct ltt_session *session = NULL;
+ struct ltt_session *session = nullptr;
LTTNG_ASSERT(ua_sess);
LTTNG_ASSERT(app);
}
/* Allocate UST metadata */
- metadata = alloc_ust_app_channel(DEFAULT_METADATA_NAME, ua_sess, NULL);
+ metadata = alloc_ust_app_channel(DEFAULT_METADATA_NAME, ua_sess, nullptr);
if (!metadata) {
/* malloc() failed */
ret = -ENOMEM;
*/
struct ust_app *ust_app_find_by_pid(pid_t pid)
{
- struct ust_app *app = NULL;
+ struct ust_app *app = nullptr;
struct lttng_ht_node_ulong *node;
struct lttng_ht_iter iter;
lttng_ht_lookup(ust_app_ht, (void *) ((unsigned long) pid), &iter);
node = lttng_ht_iter_get_node_ulong(&iter);
- if (node == NULL) {
+ if (node == nullptr) {
DBG2("UST app no found with pid %d", pid);
goto error;
}
struct ust_app *ust_app_create(struct ust_register_msg *msg, int sock)
{
int ret;
- struct ust_app *lta = NULL;
- struct lttng_pipe *event_notifier_event_source_pipe = NULL;
+ struct ust_app *lta = nullptr;
+ struct lttng_pipe *event_notifier_event_source_pipe = nullptr;
LTTNG_ASSERT(msg);
LTTNG_ASSERT(sock >= 0);
}
lta = zmalloc<ust_app>();
- if (lta == NULL) {
+ if (lta == nullptr) {
PERROR("malloc");
goto error_free_pipe;
}
lta->pid = msg->pid;
lttng_ht_node_init_ulong(<a->pid_n, (unsigned long) lta->pid);
lta->sock = sock;
- pthread_mutex_init(<a->sock_lock, NULL);
+ pthread_mutex_init(<a->sock_lock, nullptr);
lttng_ht_node_init_ulong(<a->sock_n, (unsigned long) lta->sock);
CDS_INIT_LIST_HEAD(<a->teardown_head);
lttng_pipe_destroy(event_notifier_event_source_pipe);
lttng_fd_put(LTTNG_FD_APPS, 2);
error:
- return NULL;
+ return nullptr;
}
/*
LTTNG_ASSERT(app);
LTTNG_ASSERT(app->notify_sock >= 0);
- app->registration_time = time(NULL);
+ app->registration_time = time(nullptr);
rcu_read_lock();
{
int ret;
int event_pipe_write_fd;
- struct lttng_ust_abi_object_data *event_notifier_group = NULL;
+ struct lttng_ust_abi_object_data *event_notifier_group = nullptr;
enum lttng_error_code lttng_ret;
enum event_notifier_error_accounting_status event_notifier_error_accounting_status;
error:
lttng_ust_ctl_release_object(app->sock, app->event_notifier_group.object);
free(app->event_notifier_group.object);
- app->event_notifier_group.object = NULL;
+ app->event_notifier_group.object = nullptr;
return ret;
}
nbmem = UST_APP_EVENT_LIST_SIZE;
tmp_event = calloc<lttng_event>(nbmem);
- if (tmp_event == NULL) {
+ if (tmp_event == nullptr) {
PERROR("zmalloc ust app events");
ret = -ENOMEM;
goto error;
new_nbmem);
new_tmp_event = (lttng_event *) realloc(
tmp_event, new_nbmem * sizeof(struct lttng_event));
- if (new_tmp_event == NULL) {
+ if (new_tmp_event == nullptr) {
int release_ret;
PERROR("realloc ust app events");
nbmem = UST_APP_EVENT_LIST_SIZE;
tmp_event = calloc<lttng_event_field>(nbmem);
- if (tmp_event == NULL) {
+ if (tmp_event == nullptr) {
PERROR("zmalloc ust app event fields");
ret = -ENOMEM;
goto error;
new_nbmem);
new_tmp_event = (lttng_event_field *) realloc(
tmp_event, new_nbmem * sizeof(struct lttng_event_field));
- if (new_tmp_event == NULL) {
+ if (new_tmp_event == nullptr) {
int release_ret;
PERROR("realloc ust app event fields");
/*
* Free and clean all traceable apps of the global list.
*/
-void ust_app_clean_list(void)
+void ust_app_clean_list()
{
int ret;
struct ust_app *app;
/*
* Init UST app hash table.
*/
-int ust_app_ht_alloc(void)
+int ust_app_ht_alloc()
{
ust_app_ht = lttng_ht_new(0, LTTNG_HT_TYPE_ULONG);
if (!ust_app_ht) {
continue;
}
ua_sess = lookup_session_by_app(usess, app);
- if (ua_sess == NULL) {
+ if (ua_sess == nullptr) {
continue;
}
continue;
}
ua_sess = lookup_session_by_app(usess, app);
- if (ua_sess == NULL) {
+ if (ua_sess == nullptr) {
continue;
}
continue;
}
ua_sess = lookup_session_by_app(usess, app);
- if (ua_sess == NULL) {
+ if (ua_sess == nullptr) {
/* Next app */
continue;
}
/* Lookup channel in the ust app session */
lttng_ht_lookup(ua_sess->channels, (void *) uchan->name, &uiter);
ua_chan_node = lttng_ht_iter_get_node_str(&uiter);
- if (ua_chan_node == NULL) {
+ if (ua_chan_node == nullptr) {
DBG2("Channel %s not found in session id %" PRIu64 " for app pid %d."
"Skipping",
uchan->name,
uevent->filter,
uevent->attr.loglevel,
uevent->exclusion);
- if (ua_event == NULL) {
+ if (ua_event == nullptr) {
DBG2("Event %s not found in channel %s for app pid %d."
"Skipping",
uevent->attr.name,
struct ust_app_channel **_ua_chan)
{
int ret = 0;
- struct ust_app_channel *ua_chan = NULL;
+ struct ust_app_channel *ua_chan = nullptr;
LTTNG_ASSERT(ua_sess);
ASSERT_LOCKED(ua_sess->lock);
copy_channel_attr_to_ustctl(&ua_sess->metadata_attr, &uchan->attr);
ret = 0;
} else {
- struct ltt_ust_context *uctx = NULL;
+ struct ltt_ust_context *uctx = nullptr;
/*
* Create channel onto application and synchronize its
uevent->filter,
uevent->attr.loglevel,
uevent->exclusion);
- if (ua_event == NULL) {
+ if (ua_event == nullptr) {
DBG3("UST app enable event %s not found for app PID %d."
"Skipping app",
uevent->attr.name,
}
ua_sess = lookup_session_by_app(usess, app);
- if (ua_sess == NULL) {
+ if (ua_sess == nullptr) {
/* The session is in teardown process. Ignore and continue. */
goto end;
}
}
ua_sess = lookup_session_by_app(usess, app);
- if (ua_sess == NULL) {
+ if (ua_sess == nullptr) {
goto end_no_session;
}
cds_lfht_for_each_entry (ust_app_ht->ht, &iter.iter, app, pid_n.node) {
ua_sess = lookup_session_by_app(usess, app);
- if (ua_sess == NULL) {
+ if (ua_sess == nullptr) {
continue;
}
(void) ust_app_flush_app_session(app, ua_sess);
cds_lfht_for_each_entry (ust_app_ht->ht, &iter.iter, app, pid_n.node) {
ua_sess = lookup_session_by_app(usess, app);
- if (ua_sess == NULL) {
+ if (ua_sess == nullptr) {
continue;
}
(void) ust_app_clear_quiescent_app_session(app, ua_sess);
__lookup_session_by_app(usess, app, &iter);
node = lttng_ht_iter_get_node_u64(&iter);
- if (node == NULL) {
+ if (node == nullptr) {
/* Session is being or is deleted. */
goto end;
}
struct ust_app *app)
{
int ret = 0;
- struct ust_app_event *ua_event = NULL;
+ struct ust_app_event *ua_event = nullptr;
ua_event = find_ust_app_event(ua_chan->events,
uevent->attr.name,
enum lttng_error_code ret_code;
enum lttng_trigger_status t_status;
struct lttng_ht_iter app_trigger_iter;
- struct lttng_triggers *triggers = NULL;
+ struct lttng_triggers *triggers = nullptr;
struct ust_app_event_notifier_rule *event_notifier_rule;
unsigned int count, i;
static void ust_app_synchronize(struct ltt_ust_session *usess, struct ust_app *app)
{
int ret = 0;
- struct ust_app_session *ua_sess = NULL;
+ struct ust_app_session *ua_sess = nullptr;
/*
* The application's configuration should only be synchronized for
*/
LTTNG_ASSERT(usess->active);
- ret = find_or_create_ust_app_session(usess, app, &ua_sess, NULL);
+ ret = find_or_create_ust_app_session(usess, app, &ua_sess, nullptr);
if (ret < 0) {
/* Tracer is probably gone or ENOMEM. */
if (ua_sess) {
struct ust_app_session *ua_sess;
ua_sess = lookup_session_by_app(usess, app);
- if (ua_sess == NULL) {
+ if (ua_sess == nullptr) {
return;
}
destroy_app_session(app, ua_sess);
return;
}
- if (app->event_notifier_group.object == NULL) {
+ if (app->event_notifier_group.object == nullptr) {
WARN("UST app global update of event notifiers for app skipped since communication handle is null: app = '%s', pid = %d",
app->name,
app->pid);
rcu_read_unlock();
}
-void ust_app_global_update_all_event_notifier_rules(void)
+void ust_app_global_update_all_event_notifier_rules()
{
struct lttng_ht_iter iter;
struct ust_app *app;
int ret = 0;
struct lttng_ht_node_str *ua_chan_node;
struct lttng_ht_iter iter, uiter;
- struct ust_app_channel *ua_chan = NULL;
+ struct ust_app_channel *ua_chan = nullptr;
struct ust_app_session *ua_sess;
struct ust_app *app;
continue;
}
ua_sess = lookup_session_by_app(usess, app);
- if (ua_sess == NULL) {
+ if (ua_sess == nullptr) {
continue;
}
/* Lookup channel in the ust app session */
lttng_ht_lookup(ua_sess->channels, (void *) uchan->name, &uiter);
ua_chan_node = lttng_ht_iter_get_node_str(&uiter);
- if (ua_chan_node == NULL) {
+ if (ua_chan_node == nullptr) {
goto next_app;
}
ua_chan = caa_container_of(ua_chan_node, struct ust_app_channel, node);
{
struct lttng_ht_node_ulong *node;
struct lttng_ht_iter iter;
- struct ust_app_session *ua_sess = NULL;
+ struct ust_app_session *ua_sess = nullptr;
LTTNG_ASSERT(app);
ASSERT_RCU_READ_LOCKED();
lttng_ht_lookup(app->ust_sessions_objd, (void *) ((unsigned long) objd), &iter);
node = lttng_ht_iter_get_node_ulong(&iter);
- if (node == NULL) {
+ if (node == nullptr) {
DBG2("UST app session find by objd %d not found", objd);
goto error;
}
{
struct lttng_ht_node_ulong *node;
struct lttng_ht_iter iter;
- struct ust_app_channel *ua_chan = NULL;
+ struct ust_app_channel *ua_chan = nullptr;
LTTNG_ASSERT(app);
ASSERT_RCU_READ_LOCKED();
lttng_ht_lookup(app->ust_objd, (void *) ((unsigned long) objd), &iter);
node = lttng_ht_iter_get_node_ulong(&iter);
- if (node == NULL) {
+ if (node == nullptr) {
DBG2("UST app channel find by objd %d not found", objd);
goto error;
}
enum lttng_error_code status = LTTNG_OK;
struct lttng_ht_iter iter;
struct ust_app *app;
- char *trace_path = NULL;
+ char *trace_path = nullptr;
LTTNG_ASSERT(usess);
LTTNG_ASSERT(output);
struct lttng_ht_iter uiter;
ua_sess = lookup_session_by_app(usess, app);
- if (ua_sess == NULL) {
+ if (ua_sess == nullptr) {
continue;
}
rcu_read_lock();
ua_sess = lookup_session_by_app(usess, app);
- if (ua_sess == NULL) {
+ if (ua_sess == nullptr) {
/* The session is in teardown process. Ignore and continue. */
goto end;
}
void ust_app_global_update(struct ltt_ust_session *usess, struct ust_app *app);
void ust_app_global_update_all(struct ltt_ust_session *usess);
void ust_app_global_update_event_notifier_rules(struct ust_app *app);
-void ust_app_global_update_all_event_notifier_rules(void);
+void ust_app_global_update_all_event_notifier_rules();
-void ust_app_clean_list(void);
-int ust_app_ht_alloc(void);
+void ust_app_clean_list();
+int ust_app_ht_alloc();
struct ust_app *ust_app_find_by_pid(pid_t pid);
-struct ust_app_stream *ust_app_alloc_stream(void);
+struct ust_app_stream *ust_app_alloc_stream();
int ust_app_recv_registration(int sock, struct ust_register_msg *msg);
int ust_app_recv_notify(int sock);
void ust_app_add(struct ust_app *app);
int ust_app_setup_event_notifier_group(struct ust_app *app);
static inline
-int ust_app_supported(void)
+int ust_app_supported()
{
return 1;
}
* to complete, thus removing imprecision caused by preemption.
* May return a negative offset.
*/
-lst::clock_class::scycles_t measure_clock_offset(void)
+lst::clock_class::scycles_t measure_clock_offset()
{
struct offset_sample offset_best_sample = {
.offset = 0,
int ret, output;
uint32_t chan_id;
uint64_t key, chan_reg_key;
- char *pathname = NULL;
+ char *pathname = nullptr;
struct lttcomm_consumer_msg msg;
char shm_path[PATH_MAX] = "";
char root_shm_path[PATH_MAX] = "";
}
/* Next, get all streams. */
- while (1) {
+ while (true) {
struct ust_app_stream *stream;
/* Create UST stream */
stream = ust_app_alloc_stream();
- if (stream == NULL) {
+ if (stream == nullptr) {
ret = -ENOMEM;
goto error;
}
#include <common/make-unique.hpp>
#include <unordered_map>
+#include <utility>
namespace lst = lttng::sessiond::trace;
namespace lsu = lttng::sessiond::ust;
session_attributes(registry_enum_getter_fn reg_enum_getter,
lst::byte_order native_trace_byte_order) :
- get_registry_enum{ reg_enum_getter },
+ get_registry_enum{ std::move(reg_enum_getter) },
_native_trace_byte_order{ native_trace_byte_order }
{
}
const lttng_ust_ctl_field *end,
const session_attributes& session_attributes,
const lttng_ust_ctl_field **next_ust_ctl_field,
- publish_field_fn publish_field,
- lookup_field_fn lookup_field,
+ const publish_field_fn& publish_field,
+ const lookup_field_fn& lookup_field,
lst::field_location::root lookup_root,
lst::field_location::elements& current_field_location_elements,
lsu::ctl_field_quirks quirks);
const lttng_ust_ctl_field *end,
const session_attributes& session_attributes,
const lttng_ust_ctl_field **next_ust_ctl_field,
- publish_field_fn publish_field,
- lookup_field_fn lookup_field,
+ const publish_field_fn& publish_field,
+ const lookup_field_fn& lookup_field,
lst::field_location::root lookup_root,
lst::field_location::elements& current_field_location_elements,
lsu::ctl_field_quirks quirks);
const lttng_ust_ctl_field *end,
const session_attributes& session_attributes,
const lttng_ust_ctl_field **next_ust_ctl_field,
- publish_field_fn publish_field,
- lookup_field_fn lookup_field,
+ const publish_field_fn& publish_field,
+ const lookup_field_fn& lookup_field,
lst::field_location::root lookup_root,
lst::field_location::elements& current_field_location_elements,
lsu::ctl_field_quirks quirks)
const lttng_ust_ctl_field *end,
const session_attributes& session_attributes,
const lttng_ust_ctl_field **next_ust_ctl_field,
- publish_field_fn publish_field,
+ const publish_field_fn& publish_field,
lst::field_location::root lookup_root,
lst::field_location::elements& current_field_location_elements,
lsu::ctl_field_quirks quirks __attribute__((unused)))
element_uctl_type.u.basic.integer.encoding);
}
- const auto length_field_name = fmt::format("_{}_length", sequence_uctl_field.name);
+ auto length_field_name = fmt::format("_{}_length", sequence_uctl_field.name);
auto element_type =
create_integer_type_from_ust_ctl_basic_type(element_uctl_type, session_attributes);
auto length_type =
current_field_location_elements;
length_field_location_elements.emplace_back(length_field_name);
- const lst::field_location length_field_location{
- lookup_root, std::move(length_field_location_elements)
- };
+ lst::field_location length_field_location{ lookup_root,
+ std::move(length_field_location_elements) };
/* Publish an implicit length field _before_ the sequence field. */
publish_field(lttng::make_unique<lst::field>(std::move(length_field_name),
const lttng_ust_ctl_field *end,
const session_attributes& session_attributes,
const lttng_ust_ctl_field **next_ust_ctl_field,
- publish_field_fn publish_field,
- lookup_field_fn lookup_field,
+ const publish_field_fn& publish_field,
+ const lookup_field_fn& lookup_field,
lst::field_location::root lookup_root,
lst::field_location::elements& current_field_location_elements,
lsu::ctl_field_quirks quirks)
current_field_location_elements;
length_field_location_elements.emplace_back(std::move(length_field_name));
- const lst::field_location length_field_location{
- lookup_root, std::move(length_field_location_elements)
- };
+ lst::field_location length_field_location{ lookup_root,
+ std::move(length_field_location_elements) };
/* Validate existence of length field (throws if not found). */
const auto& length_field = lookup_field(length_field_location);
const lttng_ust_ctl_field *end,
const session_attributes& session_attributes,
const lttng_ust_ctl_field **next_ust_ctl_field,
- lookup_field_fn lookup_field,
+ const lookup_field_fn& lookup_field,
lst::field_location::root lookup_root,
lst::field_location::elements& current_field_location_elements,
lsu::ctl_field_quirks quirks)
current_field_location_elements;
selector_field_location_elements.emplace_back(tag_name);
- const lst::field_location selector_field_location{
- lookup_root, std::move(selector_field_location_elements)
- };
+ lst::field_location selector_field_location{ lookup_root,
+ std::move(selector_field_location_elements) };
/* Validate existence of selector field (throws if not found). */
const auto& selector_field = lookup_field(selector_field_location);
const lttng_ust_ctl_field *end,
const session_attributes& session_attributes,
const lttng_ust_ctl_field **next_ust_ctl_field,
- publish_field_fn publish_field,
- lookup_field_fn lookup_field,
+ const publish_field_fn& publish_field,
+ const lookup_field_fn& lookup_field,
lst::field_location::root lookup_root,
lst::field_location::elements& current_field_location_elements,
lsu::ctl_field_quirks quirks)
const lttng_ust_ctl_field *end,
const session_attributes& session_attributes,
const lttng_ust_ctl_field **next_ust_ctl_field,
- publish_field_fn publish_field,
- lookup_field_fn lookup_field,
+ const publish_field_fn& publish_field,
+ const lookup_field_fn& lookup_field,
lst::field_location::root lookup_root,
lst::field_location::elements& current_field_location_elements,
lsu::ctl_field_quirks quirks)
#include <common/make-unique.hpp>
#include <common/urcu.hpp>
+#include <utility>
+
namespace lst = lttng::sessiond::trace;
namespace lsu = lttng::sessiond::ust;
_key{ -1ULL },
_consumer_key{ -1ULL },
_next_event_id{ 0 },
- _is_registered_listener{ channel_registered_listener },
- _event_added_listener{ event_added_listener },
+ _is_registered_listener{ std::move(channel_registered_listener) },
+ _event_added_listener{ std::move(event_added_listener) },
_is_registered{ false }
{
_events = lttng_ht_new(0, LTTNG_HT_TYPE_STRING);
lttng_buffer_type buffer_type,
const ust_app& app,
uint32_t& out_event_id);
- virtual ~registry_channel();
+ ~registry_channel() override;
- virtual const lttng::sessiond::trace::type *event_context() const override final;
+ const lttng::sessiond::trace::type *event_context() const final;
void event_context(lttng::sessiond::trace::type::cuptr context);
/* Channel was registered to at least one application. */
uint32_t _next_event_id;
private:
- virtual void _accept_on_event_classes(
- lttng::sessiond::trace::trace_class_visitor& trace_class_visitor) const override final;
+ void _accept_on_event_classes(
+ lttng::sessiond::trace::trace_class_visitor& trace_class_visitor) const final;
registered_listener_fn _is_registered_listener;
event_added_listener_fn _event_added_listener;
std::vector<lttng::sessiond::trace::field::cuptr> fields,
int loglevel_value,
nonstd::optional<std::string> model_emf_uri);
- virtual ~registry_event() = default;
+ ~registry_event() override = default;
/* Both objd are set by the tracer. */
const int session_objd;
[this](const std::string& fragment) { _append_metadata_fragment(fragment); }) },
_packet_header{ _create_packet_header() }
{
- pthread_mutex_init(&_lock, NULL);
+ pthread_mutex_init(&_lock, nullptr);
if (_shm_path.size() > 0) {
if (run_as_mkdir_recursive(_shm_path.c_str(), S_IRWXU | S_IRWXG, euid, egid)) {
LTTNG_THROW_POSIX("run_as_mkdir_recursive", errno);
}
/* hash/match functions are specified at call site. */
- _enums->match_fct = NULL;
- _enums->hash_fct = NULL;
+ _enums->match_fct = nullptr;
+ _enums->hash_fct = nullptr;
_channels.reset(lttng_ht_new(0, LTTNG_HT_TYPE_U64));
if (!_channels) {
lsu::registry_enum::const_rcu_protected_reference
lsu::registry_session::enumeration(const char *enum_name, uint64_t enum_id) const
{
- lsu::registry_enum *reg_enum = NULL;
+ lsu::registry_enum *reg_enum = nullptr;
struct lttng_ht_node_str *node;
struct lttng_ht_iter iter;
lttng::urcu::unique_read_lock rcu_lock;
lsu::registry_enum *
lsu::registry_session::_lookup_enum(const lsu::registry_enum *reg_enum_lookup) const
{
- lsu::registry_enum *reg_enum = NULL;
+ lsu::registry_enum *reg_enum = nullptr;
struct lttng_ht_node_str *node;
struct lttng_ht_iter iter;
uint64_t *enum_id)
{
struct cds_lfht_node *nodep;
- lsu::registry_enum *reg_enum = NULL, *old_reg_enum;
+ lsu::registry_enum *reg_enum = nullptr, *old_reg_enum;
lttng::urcu::read_lock_guard read_lock_guard;
auto entries =
lttng::make_unique_wrapper<lttng_ust_ctl_enum_entry, lttng::free>(raw_entries);
const char *enum_name, uint64_t enum_id) const;
void regenerate_metadata();
- virtual ~registry_session();
+ ~registry_session() override;
- virtual const lttng::sessiond::trace::type *packet_header() const noexcept override;
+ const lttng::sessiond::trace::type *packet_header() const noexcept override;
/*
* With multiple writers and readers, use this lock to access
uid_t euid,
gid_t egid,
uint64_t tracing_id);
- virtual void accept(
+ void accept(
trace::trace_class_environment_visitor& environment_visitor) const override;
void _generate_metadata();
registry_enum *_lookup_enum(const registry_enum *target_enum) const;
lttng::sessiond::trace::type::cuptr _create_packet_header() const;
- virtual void _accept_on_clock_classes(
+ void _accept_on_clock_classes(
lttng::sessiond::trace::trace_class_visitor& trace_class_visitor)
- const override final;
- virtual void _accept_on_stream_classes(
+ const final;
+ void _accept_on_stream_classes(
lttng::sessiond::trace::trace_class_visitor& trace_class_visitor)
- const override final;
+ const final;
/* Next channel ID available for a newly registered channel. */
uint32_t _next_channel_id = 0;
_mappings;
protected:
- virtual bool _is_equal(const registry_enum& base_other) const noexcept
+ bool _is_equal(const registry_enum& base_other) const noexcept override
{
const auto &other = static_cast<decltype(*this)&>(base_other);
static struct poptOption long_options[] = {
/* longName, shortName, argInfo, argPtr, value, descrip, argDesc */
- { "help", 'h', POPT_ARG_NONE, 0, OPT_HELP, 0, 0 },
- { "session", 's', POPT_ARG_STRING, &opt_session_name, 0, 0, 0 },
- { "channel", 'c', POPT_ARG_STRING, &opt_channel_name, 0, 0, 0 },
- { "kernel", 'k', POPT_ARG_VAL, &opt_kernel, 1, 0, 0 },
- { "userspace", 'u', POPT_ARG_NONE, 0, OPT_USERSPACE, 0, 0 },
- { "jul", 'j', POPT_ARG_NONE, 0, OPT_JUL, 0, 0 },
- { "log4j", 'l', POPT_ARG_NONE, 0, OPT_LOG4J, 0, 0 },
- { "type", 't', POPT_ARG_STRING, &opt_type, OPT_TYPE, 0, 0 },
- { "list", 0, POPT_ARG_NONE, NULL, OPT_LIST, NULL, NULL },
- { "list-options", 0, POPT_ARG_NONE, NULL, OPT_LIST_OPTIONS, NULL, NULL },
- { 0, 0, 0, 0, 0, 0, 0 }
+ { "help", 'h', POPT_ARG_NONE, nullptr, OPT_HELP, nullptr, nullptr },
+ { "session", 's', POPT_ARG_STRING, &opt_session_name, 0, nullptr, nullptr },
+ { "channel", 'c', POPT_ARG_STRING, &opt_channel_name, 0, nullptr, nullptr },
+ { "kernel", 'k', POPT_ARG_VAL, &opt_kernel, 1, nullptr, nullptr },
+ { "userspace", 'u', POPT_ARG_NONE, nullptr, OPT_USERSPACE, nullptr, nullptr },
+ { "jul", 'j', POPT_ARG_NONE, nullptr, OPT_JUL, nullptr, nullptr },
+ { "log4j", 'l', POPT_ARG_NONE, nullptr, OPT_LOG4J, nullptr, nullptr },
+ { "type", 't', POPT_ARG_STRING, &opt_type, OPT_TYPE, nullptr, nullptr },
+ { "list", 0, POPT_ARG_NONE, nullptr, OPT_LIST, nullptr, nullptr },
+ { "list-options", 0, POPT_ARG_NONE, nullptr, OPT_LIST_OPTIONS, nullptr, nullptr },
+ { nullptr, 0, 0, nullptr, 0, nullptr, nullptr }
};
/*
{
int ret, i = 0;
- while (ctx_opts[i].symbol != NULL) {
+ while (ctx_opts[i].symbol != nullptr) {
if (strcmp(opt, ctx_opts[i].symbol) == 0) {
ret = i;
goto end;
return ret;
}
-static enum lttng_domain_type get_domain(void)
+static enum lttng_domain_type get_domain()
{
if (opt_kernel) {
return LTTNG_DOMAIN_KERNEL;
}
}
-static int mi_open(void)
+static int mi_open()
{
int ret;
strncpy(context->u.perf_counter.name, opt->symbol, LTTNG_SYMBOL_NAME_LEN);
context->u.perf_counter.name[LTTNG_SYMBOL_NAME_LEN - 1] = '\0';
/* Replace : and - by _ */
- while ((ptr = strchr(context->u.perf_counter.name, '-')) != NULL) {
+ while ((ptr = strchr(context->u.perf_counter.name, '-')) != nullptr) {
*ptr = '_';
}
- while ((ptr = strchr(context->u.perf_counter.name, ':')) != NULL) {
+ while ((ptr = strchr(context->u.perf_counter.name, ':')) != nullptr) {
*ptr = '_';
}
break;
/*
* Pretty print context type.
*/
-static int print_ctx_type(void)
+static int print_ctx_type()
{
FILE *ofp = stdout;
int i = 0;
}
}
- while (ctx_opts[i].symbol != NULL) {
+ while (ctx_opts[i].symbol != nullptr) {
if (!ctx_opts[i].hide_help) {
if (lttng_opt_mi) {
populate_context(&context, &ctx_opts[i]);
dom.type = get_domain();
handle = lttng_create_handle(session_name, &dom);
- if (handle == NULL) {
+ if (handle == nullptr) {
ret = CMD_ERROR;
goto error;
}
}
}
- ret = lttng_add_context(handle, &context, NULL, opt_channel_name);
+ ret = lttng_add_context(handle, &context, nullptr, opt_channel_name);
if (ret < 0) {
ERR("%s: %s", type->opt->symbol, lttng_strerror(ret));
warn = 1;
free(type);
}
-static struct ctx_type *create_ctx_type(void)
+static struct ctx_type *create_ctx_type()
{
struct ctx_type *type = zmalloc<ctx_type>();
if (!type->opt) {
PERROR("malloc ctx_type options");
destroy_ctx_type(type);
- type = NULL;
+ type = nullptr;
goto end;
}
end:
if (!next) {
break;
}
- cur_list = NULL;
+ cur_list = nullptr;
switch (field_pos) {
case 0:
if (strncmp(next, "perf", 4) != 0) {
static struct ctx_type *get_context_type(const char *ctx)
{
int opt_index, ret;
- struct ctx_type *type = NULL;
+ struct ctx_type *type = nullptr;
const char app_ctx_prefix[] = "$app.";
- char *provider_name = NULL, *ctx_name = NULL;
+ char *provider_name = nullptr, *ctx_name = nullptr;
size_t i, len, colon_pos = 0, provider_name_len, ctx_name_len;
if (!ctx) {
free(provider_name);
free(ctx_name);
destroy_ctx_type(type);
- return NULL;
+ return nullptr;
}
/*
int opt, ret = CMD_SUCCESS, command_ret = CMD_SUCCESS;
static poptContext pc;
struct ctx_type *type, *tmptype;
- char *session_name = NULL;
- const char *leftover = NULL;
+ char *session_name = nullptr;
+ const char *leftover = nullptr;
if (argc < 2) {
ret = CMD_ERROR;
goto end;
}
- pc = poptGetContext(NULL, argc, argv, long_options, 0);
+ pc = poptGetContext(nullptr, argc, argv, long_options, 0);
poptReadDefaultConfig(pc, 0);
while ((opt = poptGetNextOpt(pc)) != -1) {
if (!opt_session_name) {
session_name = get_session_name();
- if (session_name == NULL) {
+ if (session_name == nullptr) {
ret = CMD_ERROR;
goto end;
}
int match;
char s_hex[19];
char name[LTTNG_SYMBOL_NAME_LEN];
- char *symbol_name = NULL;
+ char *symbol_name = nullptr;
uint64_t offset;
/* Check for symbol+offset. */
PERROR("Failed to copy kernel probe location symbol name.");
goto error;
}
- offset = strtoull(s_hex, NULL, 0);
+ offset = strtoull(s_hex, nullptr, 0);
*location = lttng_kernel_probe_location_symbol_create(symbol_name, offset);
if (!*location) {
goto error;
}
- address = strtoull(s_hex, NULL, 0);
+ address = strtoull(s_hex, nullptr, 0);
*location = lttng_kernel_probe_location_address_create(address);
if (!*location) {
ERR("Failed to create symbol kernel probe location.");
error:
/* No match */
ret = -1;
- *location = NULL;
+ *location = nullptr;
end:
free(symbol_name);
static struct lttng_event_expr *
ir_op_load_expr_to_event_expr(const struct ir_load_expression *load_expr, const char *capture_str)
{
- char *provider_name = NULL;
- struct lttng_event_expr *event_expr = NULL;
+ char *provider_name = nullptr;
+ struct lttng_event_expr *event_expr = nullptr;
const struct ir_load_expression_op *load_expr_op = load_expr->child;
const enum ir_load_expression_type load_expr_child_type = load_expr_op->type;
error:
lttng_event_expr_destroy(event_expr);
- event_expr = NULL;
+ event_expr = nullptr;
end:
free(provider_name);
static struct lttng_event_expr *ir_op_load_to_event_expr(const struct ir_op *ir,
const char *capture_str)
{
- struct lttng_event_expr *event_expr = NULL;
+ struct lttng_event_expr *event_expr = nullptr;
LTTNG_ASSERT(ir->op == IR_OP_LOAD);
static struct lttng_event_expr *ir_op_root_to_event_expr(const struct ir_op *ir,
const char *capture_str)
{
- struct lttng_event_expr *event_expr = NULL;
+ struct lttng_event_expr *event_expr = nullptr;
LTTNG_ASSERT(ir->op == IR_OP_ROOT);
ir = ir->u.root.child;
static struct parse_event_rule_res parse_event_rule(int *argc, const char ***argv, int argc_offset)
{
enum lttng_event_rule_type event_rule_type = LTTNG_EVENT_RULE_TYPE_UNKNOWN;
- struct argpar_iter *argpar_iter = NULL;
- const struct argpar_item *argpar_item = NULL;
+ struct argpar_iter *argpar_iter = nullptr;
+ const struct argpar_item *argpar_item = nullptr;
int consumed_args = -1;
- struct lttng_kernel_probe_location *kernel_probe_location = NULL;
- struct lttng_userspace_probe_location *userspace_probe_location = NULL;
+ struct lttng_kernel_probe_location *kernel_probe_location = nullptr;
+ struct lttng_userspace_probe_location *userspace_probe_location = nullptr;
struct parse_event_rule_res res = {};
- struct lttng_event_expr *event_expr = NULL;
- struct filter_parser_ctx *parser_ctx = NULL;
- struct lttng_log_level_rule *log_level_rule = NULL;
+ struct lttng_event_expr *event_expr = nullptr;
+ struct filter_parser_ctx *parser_ctx = nullptr;
+ struct lttng_log_level_rule *log_level_rule = nullptr;
/* Event rule type option */
- char *event_rule_type_str = NULL;
+ char *event_rule_type_str = nullptr;
/* Tracepoint and syscall options. */
- char *name = NULL;
+ char *name = nullptr;
/* Array of strings. */
struct lttng_dynamic_pointer_array exclude_names;
/* For userspace / kernel probe and function. */
- char *location = NULL;
- char *event_name = NULL;
+ char *location = nullptr;
+ char *event_name = nullptr;
/* Filter. */
- char *filter = NULL;
+ char *filter = nullptr;
/* Log level. */
- char *log_level_str = NULL;
+ char *log_level_str = nullptr;
lttng_dynamic_pointer_array_init(&res.capture_descriptors, destroy_event_expr);
enum parse_next_item_status status;
status = parse_next_item(
- argpar_iter, &argpar_item, argc_offset, *argv, false, NULL, NULL);
+ argpar_iter, &argpar_item, argc_offset, *argv, false, nullptr, nullptr);
if (status == PARSE_NEXT_ITEM_STATUS_ERROR ||
status == PARSE_NEXT_ITEM_STATUS_ERROR_MEMORY) {
goto error;
* The ownership of event expression was
* transferred to the dynamic array.
*/
- event_expr = NULL;
+ event_expr = nullptr;
break;
}
log_level);
}
- if (log_level_rule == NULL) {
+ if (log_level_rule == nullptr) {
ERR("Failed to create log level rule object.");
goto error;
}
error:
lttng_event_rule_destroy(res.er);
- res.er = NULL;
+ res.er = nullptr;
lttng_dynamic_pointer_array_reset(&res.capture_descriptors);
end:
res = parse_event_rule(argc, argv, argc_offset);
if (!res.er) {
- c = NULL;
+ c = nullptr;
goto error;
}
c = lttng_condition_event_rule_matches_create(res.er);
lttng_event_rule_destroy(res.er);
- res.er = NULL;
+ res.er = nullptr;
if (!c) {
goto error;
}
}
/* Ownership of event expression moved to `c` */
- *expr = NULL;
+ *expr = nullptr;
}
goto end;
error:
lttng_condition_destroy(c);
- c = NULL;
+ c = nullptr;
end:
lttng_dynamic_pointer_array_reset(&res.capture_descriptors);
{ "event-rule-matches", handle_condition_event },
};
-static void print_valid_condition_names(void)
+static void print_valid_condition_names()
{
unsigned int i;
{
int i;
struct lttng_condition *cond;
- const struct condition_descr *descr = NULL;
+ const struct condition_descr *descr = nullptr;
for (i = 0; i < ARRAY_SIZE(condition_descrs); i++) {
if (strcmp(condition_name, condition_descrs[i].name) == 0) {
goto end;
error:
- cond = NULL;
+ cond = nullptr;
end:
return cond;
}
int ret;
size_t num_token = 0;
struct lttng_dynamic_pointer_array tokens;
- struct lttng_rate_policy *policy = NULL;
+ struct lttng_rate_policy *policy = nullptr;
enum lttng_rate_policy_type policy_type;
unsigned long long value;
char *policy_type_str;
char *policy_value_str;
LTTNG_ASSERT(policy_str);
- lttng_dynamic_pointer_array_init(&tokens, NULL);
+ lttng_dynamic_pointer_array_init(&tokens, nullptr);
/* Rate policy fields are separated by ':'. */
- ret = strutils_split(policy_str, ':', 1, &tokens);
+ ret = strutils_split(policy_str, ':', true, &tokens);
if (ret == 0) {
num_token = lttng_dynamic_pointer_array_get_count(&tokens);
}
abort();
}
- if (policy == NULL) {
+ if (policy == nullptr) {
ERR("Failed to create rate policy `%s`.", policy_str);
}
static struct lttng_action *handle_action_notify(int *argc, const char ***argv, int argc_offset)
{
- struct lttng_action *action = NULL;
- struct argpar_iter *argpar_iter = NULL;
- const struct argpar_item *argpar_item = NULL;
- struct lttng_rate_policy *policy = NULL;
+ struct lttng_action *action = nullptr;
+ struct argpar_iter *argpar_iter = nullptr;
+ const struct argpar_item *argpar_item = nullptr;
+ struct lttng_rate_policy *policy = nullptr;
argpar_iter = argpar_iter_create(*argc, *argv, notify_action_opt_descrs);
if (!argpar_iter) {
argc_offset,
*argv,
false,
- NULL,
+ nullptr,
"While parsing `notify` action:");
if (status == PARSE_NEXT_ITEM_STATUS_ERROR ||
status == PARSE_NEXT_ITEM_STATUS_ERROR_MEMORY) {
error:
lttng_action_destroy(action);
- action = NULL;
+ action = nullptr;
end:
lttng_rate_policy_destroy(policy);
argpar_item_destroy(argpar_item);
int *argc,
const char ***argv,
int argc_offset,
- struct lttng_action *(*create_action_cb)(void),
+ struct lttng_action *(*create_action_cb)(),
enum lttng_action_status (*set_session_name_cb)(struct lttng_action *, const char *),
enum lttng_action_status (*set_rate_policy_cb)(struct lttng_action *,
const struct lttng_rate_policy *),
const char *action_name)
{
- struct lttng_action *action = NULL;
- struct argpar_iter *argpar_iter = NULL;
- const struct argpar_item *argpar_item = NULL;
- const char *session_name_arg = NULL;
+ struct lttng_action *action = nullptr;
+ struct argpar_iter *argpar_iter = nullptr;
+ const struct argpar_item *argpar_item = nullptr;
+ const char *session_name_arg = nullptr;
enum lttng_action_status action_status;
- struct lttng_rate_policy *policy = NULL;
+ struct lttng_rate_policy *policy = nullptr;
LTTNG_ASSERT(set_session_name_cb);
LTTNG_ASSERT(set_rate_policy_cb);
argc_offset,
*argv,
false,
- NULL,
+ nullptr,
"While parsing `%s` action:",
action_name);
if (status == PARSE_NEXT_ITEM_STATUS_ERROR ||
error:
lttng_action_destroy(action);
- action = NULL;
+ action = nullptr;
end:
lttng_rate_policy_destroy(policy);
static struct lttng_action *
handle_action_snapshot_session(int *argc, const char ***argv, int argc_offset)
{
- struct lttng_action *action = NULL;
- struct argpar_iter *argpar_iter = NULL;
- const struct argpar_item *argpar_item = NULL;
- const char *session_name_arg = NULL;
- char *snapshot_name_arg = NULL;
- char *ctrl_url_arg = NULL;
- char *data_url_arg = NULL;
- char *max_size_arg = NULL;
- char *url_arg = NULL;
- char *path_arg = NULL;
- char *error = NULL;
+ struct lttng_action *action = nullptr;
+ struct argpar_iter *argpar_iter = nullptr;
+ const struct argpar_item *argpar_item = nullptr;
+ const char *session_name_arg = nullptr;
+ char *snapshot_name_arg = nullptr;
+ char *ctrl_url_arg = nullptr;
+ char *data_url_arg = nullptr;
+ char *max_size_arg = nullptr;
+ char *url_arg = nullptr;
+ char *path_arg = nullptr;
+ char *error = nullptr;
enum lttng_action_status action_status;
- struct lttng_snapshot_output *snapshot_output = NULL;
- struct lttng_rate_policy *policy = NULL;
+ struct lttng_snapshot_output *snapshot_output = nullptr;
+ struct lttng_rate_policy *policy = nullptr;
int ret;
unsigned int locations_specified = 0;
argc_offset,
*argv,
false,
- NULL,
+ nullptr,
"While parsing `snapshot` action:");
if (status == PARSE_NEXT_ITEM_STATUS_ERROR ||
status == PARSE_NEXT_ITEM_STATUS_ERROR_MEMORY) {
goto error;
}
- num_uris = uri_parse_str_urls(url_arg, NULL, &uris);
+ num_uris = uri_parse_str_urls(url_arg, nullptr, &uris);
if (num_uris < 1) {
ERR("Failed to parse '%s' as an URL.", url_arg);
goto error;
}
/* Ownership of `snapshot_output` has been transferred to the action. */
- snapshot_output = NULL;
+ snapshot_output = nullptr;
}
if (policy) {
error:
lttng_action_destroy(action);
- action = NULL;
+ action = nullptr;
free(error);
end:
free(snapshot_name_arg);
{ "snapshot-session", handle_action_snapshot_session },
};
-static void print_valid_action_names(void)
+static void print_valid_action_names()
{
unsigned int i;
{
int i;
struct lttng_action *action;
- const struct action_descr *descr = NULL;
+ const struct action_descr *descr = nullptr;
for (i = 0; i < ARRAY_SIZE(action_descrs); i++) {
if (strcmp(action_name, action_descrs[i].name) == 0) {
goto end;
error:
- action = NULL;
+ action = nullptr;
end:
return action;
}
int ret;
int my_argc = argc - 1;
const char **my_argv = argv + 1;
- struct lttng_condition *condition = NULL;
+ struct lttng_condition *condition = nullptr;
struct lttng_dynamic_pointer_array actions;
- struct argpar_iter *argpar_iter = NULL;
- const struct argpar_item *argpar_item = NULL;
- const struct argpar_error *argpar_error = NULL;
- struct lttng_action *action_list = NULL;
- struct lttng_action *action = NULL;
- struct lttng_trigger *trigger = NULL;
- char *name = NULL;
+ struct argpar_iter *argpar_iter = nullptr;
+ const struct argpar_item *argpar_item = nullptr;
+ const struct argpar_error *argpar_error = nullptr;
+ struct lttng_action *action_list = nullptr;
+ struct lttng_action *action = nullptr;
+ struct lttng_trigger *trigger = nullptr;
+ char *name = nullptr;
int i;
- char *owner_uid = NULL;
+ char *owner_uid = nullptr;
enum lttng_error_code ret_code;
- struct mi_writer *mi_writer = NULL;
+ struct mi_writer *mi_writer = nullptr;
lttng_dynamic_pointer_array_init(&actions, lttng_actions_destructor);
my_argv,
true,
&argpar_error,
- NULL);
+ nullptr);
if (status == PARSE_NEXT_ITEM_STATUS_ERROR) {
if (argpar_error_type(argpar_error) == ARGPAR_ERROR_TYPE_MISSING_OPT_ARG) {
- int opt_id = argpar_error_opt_descr(argpar_error, NULL)->id;
+ int opt_id = argpar_error_opt_descr(argpar_error, nullptr)->id;
if (opt_id == OPT_CONDITION) {
print_valid_condition_names();
}
/* Ownership of the action was transferred to the list. */
- action = NULL;
+ action = nullptr;
break;
}
* the action. We can destroy ours.
*/
lttng_action_destroy(action);
- action = NULL;
+ action = nullptr;
}
trigger = lttng_trigger_create(condition, action_list);
}
if (lttng_opt_mi) {
- ret_code = lttng_trigger_mi_serialize(trigger, mi_writer, NULL);
+ ret_code = lttng_trigger_mi_serialize(trigger, mi_writer, nullptr);
if (ret_code != LTTNG_OK) {
goto error;
}
static struct poptOption long_options[] = {
/* longName, shortName, argInfo, argPtr, value, descrip, argDesc */
- { "help", 'h', POPT_ARG_NONE, 0, OPT_HELP, 0, 0 },
- { "all", 'a', POPT_ARG_VAL, &opt_clear_all, 1, 0, 0 },
- { "list-options", 0, POPT_ARG_NONE, NULL, OPT_LIST_OPTIONS, NULL, NULL },
- { 0, 0, 0, 0, 0, 0, 0 }
+ { "help", 'h', POPT_ARG_NONE, nullptr, OPT_HELP, nullptr, nullptr },
+ { "all", 'a', POPT_ARG_VAL, &opt_clear_all, 1, nullptr, nullptr },
+ { "list-options", 0, POPT_ARG_NONE, nullptr, OPT_LIST_OPTIONS, nullptr, nullptr },
+ { nullptr, 0, 0, nullptr, 0, nullptr, nullptr }
};
/*
static int clear_session(struct lttng_session *session)
{
enum lttng_clear_handle_status status = LTTNG_CLEAR_HANDLE_STATUS_OK;
- struct lttng_clear_handle *handle = NULL;
+ struct lttng_clear_handle *handle = nullptr;
enum lttng_error_code ret_code;
bool printed_wait_msg = false;
int ret;
int opt;
int ret = CMD_SUCCESS, i, command_ret = CMD_SUCCESS, success = 1;
static poptContext pc;
- char *session_name = NULL;
- const char *arg_session_name = NULL;
- const char *leftover = NULL;
- struct lttng_session *sessions = NULL;
+ char *session_name = nullptr;
+ const char *arg_session_name = nullptr;
+ const char *leftover = nullptr;
+ struct lttng_session *sessions = nullptr;
int count;
int found;
- pc = poptGetContext(NULL, argc, argv, long_options, 0);
+ pc = poptGetContext(nullptr, argc, argv, long_options, 0);
poptReadDefaultConfig(pc, 0);
while ((opt = poptGetNextOpt(pc)) != -1) {
session_name = get_session_name();
} else {
session_name = strdup(arg_session_name);
- if (session_name == NULL) {
+ if (session_name == nullptr) {
PERROR("Failed to copy session name");
}
}
- if (session_name == NULL) {
+ if (session_name == nullptr) {
command_ret = CMD_ERROR;
success = 0;
goto mi_closing;
static struct mi_writer *writer;
static struct poptOption long_options[] = {
/* longName, shortName, argInfo, argPtr, value, descrip, argDesc */
- { "help", 'h', POPT_ARG_NONE, NULL, OPT_HELP, NULL, NULL },
- { "output", 'o', POPT_ARG_STRING, &opt_output_path, 0, NULL, NULL },
- { "list-options", 0, POPT_ARG_NONE, NULL, OPT_LIST_OPTIONS, NULL, NULL },
- { "set-url", 'U', POPT_ARG_STRING, &opt_url, 0, 0, 0 },
- { "ctrl-url", 'C', POPT_ARG_STRING, &opt_ctrl_url, 0, 0, 0 },
- { "data-url", 'D', POPT_ARG_STRING, &opt_data_url, 0, 0, 0 },
- { "no-output", 0, POPT_ARG_VAL, &opt_no_output, 1, 0, 0 },
- { "no-consumer", 0, POPT_ARG_VAL, &opt_no_consumer, 1, 0, 0 },
- { "snapshot", 0, POPT_ARG_VAL, &opt_snapshot, 1, 0, 0 },
- { "live", 0, POPT_ARG_INT | POPT_ARGFLAG_OPTIONAL, 0, OPT_LIVE_TIMER, 0, 0 },
- { "shm-path", 0, POPT_ARG_STRING, &opt_shm_path, 0, 0, 0 },
- { 0, 0, 0, 0, 0, 0, 0 }
+ { "help", 'h', POPT_ARG_NONE, nullptr, OPT_HELP, nullptr, nullptr },
+ { "output", 'o', POPT_ARG_STRING, &opt_output_path, 0, nullptr, nullptr },
+ { "list-options", 0, POPT_ARG_NONE, nullptr, OPT_LIST_OPTIONS, nullptr, nullptr },
+ { "set-url", 'U', POPT_ARG_STRING, &opt_url, 0, nullptr, nullptr },
+ { "ctrl-url", 'C', POPT_ARG_STRING, &opt_ctrl_url, 0, nullptr, nullptr },
+ { "data-url", 'D', POPT_ARG_STRING, &opt_data_url, 0, nullptr, nullptr },
+ { "no-output", 0, POPT_ARG_VAL, &opt_no_output, 1, nullptr, nullptr },
+ { "no-consumer", 0, POPT_ARG_VAL, &opt_no_consumer, 1, nullptr, nullptr },
+ { "snapshot", 0, POPT_ARG_VAL, &opt_snapshot, 1, nullptr, nullptr },
+ { "live",
+ 0,
+ POPT_ARG_INT | POPT_ARGFLAG_OPTIONAL,
+ nullptr,
+ OPT_LIVE_TIMER,
+ nullptr,
+ nullptr },
+ { "shm-path", 0, POPT_ARG_STRING, &opt_shm_path, 0, nullptr, nullptr },
+ { nullptr, 0, 0, nullptr, 0, nullptr, nullptr }
};
/*
{
ssize_t uri_count;
enum output_type output_type;
- struct lttng_uri *uris = NULL;
- struct lttng_session_descriptor *descriptor = NULL;
- const char *uri_str1 = NULL, *uri_str2 = NULL;
+ struct lttng_uri *uris = nullptr;
+ struct lttng_session_descriptor *descriptor = nullptr;
+ const char *uri_str1 = nullptr, *uri_str2 = nullptr;
char local_output_path[LTTNG_PATH_MAX] = {};
if (opt_no_output) {
case OUTPUT_LOCAL:
descriptor = lttng_session_descriptor_snapshot_local_create(
session_name,
- output_type == OUTPUT_LOCAL ? local_output_path : NULL);
+ output_type == OUTPUT_LOCAL ? local_output_path : nullptr);
break;
case OUTPUT_NONE:
descriptor = lttng_session_descriptor_snapshot_create(session_name);
case OUTPUT_LOCAL:
descriptor = lttng_session_descriptor_local_create(
session_name,
- output_type == OUTPUT_LOCAL ? local_output_path : NULL);
+ output_type == OUTPUT_LOCAL ? local_output_path : nullptr);
break;
case OUTPUT_NONE:
descriptor = lttng_session_descriptor_create(session_name);
ret = spawn_relayd(pathname, 0);
if (ret < 0) {
lttng_session_descriptor_destroy(descriptor);
- descriptor = NULL;
+ descriptor = nullptr;
}
}
}
{
int ret, i;
char shm_path[LTTNG_PATH_MAX] = {};
- struct lttng_session_descriptor *session_descriptor = NULL;
+ struct lttng_session_descriptor *session_descriptor = nullptr;
enum lttng_session_descriptor_status descriptor_status;
enum lttng_error_code ret_code;
- struct lttng_session *sessions = NULL;
- const struct lttng_session *created_session = NULL;
+ struct lttng_session *sessions = nullptr;
+ const struct lttng_session *created_session = nullptr;
const char *created_session_name;
/* Validate options. */
}
while ((iter = lttng_snapshot_output_list_get_next(list))) {
- const char *url = NULL;
+ const char *url = nullptr;
url = lttng_snapshot_output_get_ctrl_url(iter);
ret = lttng_strncpy(snapshot_url, url, sizeof(snapshot_url));
* the liblttngctl API for the check. If not, try to
* spawn a daemon.
*/
-static int launch_sessiond(void)
+static int launch_sessiond()
{
int ret;
- const char *pathname = NULL;
+ const char *pathname = nullptr;
ret = lttng_session_daemon_alive();
if (ret) {
pathname = opt_sessiond_path;
/* Try LTTNG_SESSIOND_PATH env variable */
- if (pathname == NULL) {
+ if (pathname == nullptr) {
pathname = getenv(DEFAULT_SESSIOND_PATH_ENV);
}
/* Try with configured path */
- if (pathname == NULL) {
+ if (pathname == nullptr) {
if (CONFIG_SESSIOND_BIN[0] != '\0') {
pathname = CONFIG_SESSIOND_BIN;
}
}
/* Try the default path */
- if (pathname == NULL) {
+ if (pathname == nullptr) {
pathname = INSTALL_BIN_PATH "/lttng-sessiond";
}
return ret;
}
-static int validate_url_option_combination(void)
+static int validate_url_option_combination()
{
int ret = 0;
int used_count = 0;
int cmd_create(int argc, const char **argv)
{
int opt, ret = CMD_SUCCESS, command_ret = CMD_SUCCESS, success = 1;
- char *opt_arg = NULL;
- const char *arg_session_name = NULL;
- const char *leftover = NULL;
+ char *opt_arg = nullptr;
+ const char *arg_session_name = nullptr;
+ const char *leftover = nullptr;
static poptContext pc;
- pc = poptGetContext(NULL, argc, argv, long_options, 0);
+ pc = poptGetContext(nullptr, argc, argv, long_options, 0);
poptReadDefaultConfig(pc, 0);
while ((opt = poptGetNextOpt(pc)) != -1) {
static struct poptOption long_options[] = {
/* longName, shortName, argInfo, argPtr, value, descrip, argDesc */
- { "help", 'h', POPT_ARG_NONE, 0, OPT_HELP, 0, 0 },
- { "all", 'a', POPT_ARG_VAL, &opt_destroy_all, 1, 0, 0 },
- { "list-options", 0, POPT_ARG_NONE, NULL, OPT_LIST_OPTIONS, NULL, NULL },
- { "no-wait", 'n', POPT_ARG_VAL, &opt_no_wait, 1, 0, 0 },
- { 0, 0, 0, 0, 0, 0, 0 }
+ { "help", 'h', POPT_ARG_NONE, nullptr, OPT_HELP, nullptr, nullptr },
+ { "all", 'a', POPT_ARG_VAL, &opt_destroy_all, 1, nullptr, nullptr },
+ { "list-options", 0, POPT_ARG_NONE, nullptr, OPT_LIST_OPTIONS, nullptr, nullptr },
+ { "no-wait", 'n', POPT_ARG_VAL, &opt_no_wait, 1, nullptr, nullptr },
+ { nullptr, 0, 0, nullptr, 0, nullptr, nullptr }
};
/*
static int destroy_session(struct lttng_session *session)
{
int ret;
- char *session_name = NULL;
+ char *session_name = nullptr;
bool session_was_already_stopped;
enum lttng_error_code ret_code;
- struct lttng_destruction_handle *handle = NULL;
+ struct lttng_destruction_handle *handle = nullptr;
enum lttng_destruction_handle_status status;
bool newline_needed = false, printed_destroy_msg = false;
enum lttng_rotation_state rotation_state;
- char *stats_str = NULL;
+ char *stats_str = nullptr;
ret = lttng_stop_tracing_no_wait(session->name);
if (ret < 0 && ret != -LTTNG_ERR_TRACE_ALREADY_STOPPED) {
int opt;
int ret = CMD_SUCCESS, i, command_ret = CMD_SUCCESS, success = 1;
static poptContext pc;
- char *session_name = NULL;
- const char *arg_session_name = NULL;
- const char *leftover = NULL;
+ char *session_name = nullptr;
+ const char *arg_session_name = nullptr;
+ const char *leftover = nullptr;
- struct lttng_session *sessions = NULL;
+ struct lttng_session *sessions = nullptr;
int count;
int found;
- pc = poptGetContext(NULL, argc, argv, long_options, 0);
+ pc = poptGetContext(nullptr, argc, argv, long_options, 0);
poptReadDefaultConfig(pc, 0);
while ((opt = poptGetNextOpt(pc)) != -1) {
session_name = get_session_name();
} else {
session_name = strdup(arg_session_name);
- if (session_name == NULL) {
+ if (session_name == nullptr) {
PERROR("Failed to copy session name");
}
}
- if (session_name == NULL) {
+ if (session_name == nullptr) {
command_ret = CMD_ERROR;
success = 0;
goto mi_closing;
static struct poptOption long_options[] = {
/* longName, shortName, argInfo, argPtr, value, descrip, argDesc */
- { "help", 'h', POPT_ARG_NONE, 0, OPT_HELP, 0, 0 },
- { "session", 's', POPT_ARG_STRING, &opt_session_name, 0, 0, 0 },
- { "kernel", 'k', POPT_ARG_VAL, &opt_kernel, 1, 0, 0 },
- { "userspace", 'u', POPT_ARG_NONE, 0, OPT_USERSPACE, 0, 0 },
- { "list-options", 0, POPT_ARG_NONE, NULL, OPT_LIST_OPTIONS, NULL, NULL },
- { 0, 0, 0, 0, 0, 0, 0 }
+ { "help", 'h', POPT_ARG_NONE, nullptr, OPT_HELP, nullptr, nullptr },
+ { "session", 's', POPT_ARG_STRING, &opt_session_name, 0, nullptr, nullptr },
+ { "kernel", 'k', POPT_ARG_VAL, &opt_kernel, 1, nullptr, nullptr },
+ { "userspace", 'u', POPT_ARG_NONE, nullptr, OPT_USERSPACE, nullptr, nullptr },
+ { "list-options", 0, POPT_ARG_NONE, nullptr, OPT_LIST_OPTIONS, nullptr, nullptr },
+ { nullptr, 0, 0, nullptr, 0, nullptr, nullptr }
};
static int mi_partial_channel_print(char *channel_name, unsigned int enabled, int success)
}
handle = lttng_create_handle(session_name, &dom);
- if (handle == NULL) {
+ if (handle == nullptr) {
ret = -1;
goto error;
}
/* Strip channel list */
channel_name = strtok(channel_list, ",");
- while (channel_name != NULL) {
+ while (channel_name != nullptr) {
DBG("Disabling channel %s", channel_name);
ret = lttng_disable_channel(handle, channel_name);
}
/* Next channel */
- channel_name = strtok(NULL, ",");
+ channel_name = strtok(nullptr, ",");
}
ret = CMD_SUCCESS;
{
int opt, ret = CMD_SUCCESS, command_ret = CMD_SUCCESS, success = 1;
static poptContext pc;
- char *session_name = NULL;
- char *channel_list = NULL;
- const char *arg_channel_list = NULL;
- const char *leftover = NULL;
+ char *session_name = nullptr;
+ char *channel_list = nullptr;
+ const char *arg_channel_list = nullptr;
+ const char *leftover = nullptr;
- pc = poptGetContext(NULL, argc, argv, long_options, 0);
+ pc = poptGetContext(nullptr, argc, argv, long_options, 0);
poptReadDefaultConfig(pc, 0);
while ((opt = poptGetNextOpt(pc)) != -1) {
}
arg_channel_list = poptGetArg(pc);
- if (arg_channel_list == NULL) {
+ if (arg_channel_list == nullptr) {
ERR("Missing channel name(s).");
ret = CMD_ERROR;
goto end;
}
channel_list = strdup(arg_channel_list);
- if (channel_list == NULL) {
+ if (channel_list == nullptr) {
PERROR("Failed to copy channel name");
ret = CMD_ERROR;
goto end;
if (!opt_session_name) {
session_name = get_session_name();
- if (session_name == NULL) {
+ if (session_name == nullptr) {
ret = CMD_ERROR;
goto end;
}
static struct poptOption long_options[] = {
/* longName, shortName, argInfo, argPtr, value, descrip, argDesc */
- { "help", 'h', POPT_ARG_NONE, 0, OPT_HELP, 0, 0 },
- { "session", 's', POPT_ARG_STRING, &opt_session_name, 0, 0, 0 },
- { "all-events", 'a', POPT_ARG_VAL, &opt_disable_all, 1, 0, 0 },
- { "channel", 'c', POPT_ARG_STRING, &opt_channel_name, 0, 0, 0 },
- { "jul", 'j', POPT_ARG_VAL, &opt_jul, 1, 0, 0 },
- { "log4j", 'l', POPT_ARG_VAL, &opt_log4j, 1, 0, 0 },
- { "python", 'p', POPT_ARG_VAL, &opt_python, 1, 0, 0 },
- { "kernel", 'k', POPT_ARG_VAL, &opt_kernel, 1, 0, 0 },
- { "userspace", 'u', POPT_ARG_VAL, &opt_userspace, 1, 0, 0 },
- { "syscall", 0, POPT_ARG_NONE, 0, OPT_TYPE_SYSCALL, 0, 0 },
- { "probe", 0, POPT_ARG_NONE, 0, OPT_TYPE_PROBE, 0, 0 },
- { "tracepoint", 0, POPT_ARG_NONE, 0, OPT_TYPE_TRACEPOINT, 0, 0 },
- { "function", 0, POPT_ARG_NONE, 0, OPT_TYPE_FUNCTION, 0, 0 },
- { "all", 0, POPT_ARG_NONE, 0, OPT_TYPE_ALL, 0, 0 },
- { "list-options", 0, POPT_ARG_NONE, NULL, OPT_LIST_OPTIONS, NULL, NULL },
- { 0, 0, 0, 0, 0, 0, 0 }
+ { "help", 'h', POPT_ARG_NONE, nullptr, OPT_HELP, nullptr, nullptr },
+ { "session", 's', POPT_ARG_STRING, &opt_session_name, 0, nullptr, nullptr },
+ { "all-events", 'a', POPT_ARG_VAL, &opt_disable_all, 1, nullptr, nullptr },
+ { "channel", 'c', POPT_ARG_STRING, &opt_channel_name, 0, nullptr, nullptr },
+ { "jul", 'j', POPT_ARG_VAL, &opt_jul, 1, nullptr, nullptr },
+ { "log4j", 'l', POPT_ARG_VAL, &opt_log4j, 1, nullptr, nullptr },
+ { "python", 'p', POPT_ARG_VAL, &opt_python, 1, nullptr, nullptr },
+ { "kernel", 'k', POPT_ARG_VAL, &opt_kernel, 1, nullptr, nullptr },
+ { "userspace", 'u', POPT_ARG_VAL, &opt_userspace, 1, nullptr, nullptr },
+ { "syscall", 0, POPT_ARG_NONE, nullptr, OPT_TYPE_SYSCALL, nullptr, nullptr },
+ { "probe", 0, POPT_ARG_NONE, nullptr, OPT_TYPE_PROBE, nullptr, nullptr },
+ { "tracepoint", 0, POPT_ARG_NONE, nullptr, OPT_TYPE_TRACEPOINT, nullptr, nullptr },
+ { "function", 0, POPT_ARG_NONE, nullptr, OPT_TYPE_FUNCTION, nullptr, nullptr },
+ { "all", 0, POPT_ARG_NONE, nullptr, OPT_TYPE_ALL, nullptr, nullptr },
+ { "list-options", 0, POPT_ARG_NONE, nullptr, OPT_LIST_OPTIONS, nullptr, nullptr },
+ { nullptr, 0, 0, nullptr, 0, nullptr, nullptr }
};
static const char *print_channel_name(const char *name)
{
int ret = CMD_SUCCESS, warn = 0, command_ret = CMD_SUCCESS;
int enabled = 1, success = 1;
- char *event_name, *channel_name = NULL;
+ char *event_name, *channel_name = nullptr;
struct lttng_domain dom;
struct lttng_event event;
channel_name = opt_channel_name;
handle = lttng_create_handle(session_name, &dom);
- if (handle == NULL) {
+ if (handle == nullptr) {
ret = -1;
goto error;
}
event.type = (lttng_event_type) opt_event_type;
if (opt_disable_all) {
- command_ret = lttng_disable_event_ext(handle, &event, channel_name, NULL);
+ command_ret = lttng_disable_event_ext(handle, &event, channel_name, nullptr);
if (command_ret < 0) {
ERR("%s", lttng_strerror(command_ret));
enabled = 1;
} else {
/* Strip event list */
event_name = strtok(event_list, ",");
- while (event_name != NULL) {
+ while (event_name != nullptr) {
DBG("Disabling event %s", event_name);
strncpy(event.name, event_name, sizeof(event.name));
event.name[sizeof(event.name) - 1] = '\0';
- command_ret = lttng_disable_event_ext(handle, &event, channel_name, NULL);
+ command_ret =
+ lttng_disable_event_ext(handle, &event, channel_name, nullptr);
if (command_ret < 0) {
ERR("%s of type %s : %s (channel %s, session %s)",
event_name,
}
/* Next event */
- event_name = strtok(NULL, ",");
+ event_name = strtok(nullptr, ",");
}
}
{
int opt, ret = CMD_SUCCESS, command_ret = CMD_SUCCESS, success = 1;
static poptContext pc;
- char *session_name = NULL;
- char *event_list = NULL;
- const char *arg_event_list = NULL;
- const char *leftover = NULL;
+ char *session_name = nullptr;
+ char *event_list = nullptr;
+ const char *arg_event_list = nullptr;
+ const char *leftover = nullptr;
int event_type = -1;
- pc = poptGetContext(NULL, argc, argv, long_options, 0);
+ pc = poptGetContext(nullptr, argc, argv, long_options, 0);
poptReadDefaultConfig(pc, 0);
/* Default event type */
}
arg_event_list = poptGetArg(pc);
- if (arg_event_list == NULL && opt_disable_all == 0) {
+ if (arg_event_list == nullptr && opt_disable_all == 0) {
ERR("Missing event name(s).\n");
ret = CMD_ERROR;
goto end;
if (opt_disable_all == 0) {
event_list = strdup(arg_event_list);
- if (event_list == NULL) {
+ if (event_list == nullptr) {
PERROR("Failed to copy event name(s)");
ret = CMD_ERROR;
goto end;
if (!opt_session_name) {
session_name = get_session_name();
- if (session_name == NULL) {
+ if (session_name == nullptr) {
ret = CMD_ERROR;
goto end;
}
static struct poptOption long_options[] = {
/* longName, shortName, argInfo, argPtr, value, descrip, argDesc */
- { "help", 'h', POPT_ARG_NONE, 0, OPT_HELP, 0, 0 },
- { "list-options", 0, POPT_ARG_NONE, NULL, OPT_LIST_OPTIONS, NULL, NULL },
- { "session", 's', POPT_ARG_STRING, &opt_session_name, 0, 0, 0 },
- { "timer", 0, POPT_ARG_NONE, 0, OPT_TIMER, 0, 0 },
- { "size", 0, POPT_ARG_NONE, 0, OPT_SIZE, 0, 0 },
- { 0, 0, 0, 0, 0, 0, 0 }
+ { "help", 'h', POPT_ARG_NONE, nullptr, OPT_HELP, nullptr, nullptr },
+ { "list-options", 0, POPT_ARG_NONE, nullptr, OPT_LIST_OPTIONS, nullptr, nullptr },
+ { "session", 's', POPT_ARG_STRING, &opt_session_name, 0, nullptr, nullptr },
+ { "timer", 0, POPT_ARG_NONE, nullptr, OPT_TIMER, nullptr, nullptr },
+ { "size", 0, POPT_ARG_NONE, nullptr, OPT_SIZE, nullptr, nullptr },
+ { nullptr, 0, 0, nullptr, 0, nullptr, nullptr }
};
static const char *schedule_type_str[] = {
{
unsigned int count, i;
enum lttng_rotation_status status;
- const struct lttng_rotation_schedule *ret = NULL;
+ const struct lttng_rotation_schedule *ret = nullptr;
status = lttng_rotation_schedules_get_count(schedules, &count);
if (status != LTTNG_ROTATION_STATUS_OK) {
}
for (i = 0; i < count; i++) {
- const struct lttng_rotation_schedule *schedule = NULL;
+ const struct lttng_rotation_schedule *schedule = nullptr;
schedule = lttng_rotation_schedules_get_at_index(schedules, i);
if (!schedule) {
static struct lttng_rotation_schedule *create_empty_schedule(enum lttng_rotation_schedule_type type)
{
- struct lttng_rotation_schedule *schedule = NULL;
+ struct lttng_rotation_schedule *schedule = nullptr;
switch (type) {
case LTTNG_ROTATION_SCHEDULE_TYPE_PERIODIC:
{
enum cmd_error_code cmd_ret;
int ret;
- const struct lttng_rotation_schedule *schedule = NULL;
- struct lttng_rotation_schedules *schedules = NULL;
+ const struct lttng_rotation_schedule *schedule = nullptr;
+ struct lttng_rotation_schedules *schedules = nullptr;
enum lttng_rotation_status status;
const char *schedule_type_name;
- struct lttng_rotation_schedule *empty_schedule = NULL;
+ struct lttng_rotation_schedule *empty_schedule = nullptr;
switch (schedule_type) {
case LTTNG_ROTATION_SCHEDULE_TYPE_PERIODIC:
int popt_ret, opt, ret = 0;
enum cmd_error_code cmd_ret = CMD_SUCCESS;
static poptContext pc;
- char *session_name = NULL;
+ char *session_name = nullptr;
bool free_session_name = false;
bool periodic_rotation = false, size_rotation = false;
- pc = poptGetContext(NULL, argc, argv, long_options, 0);
+ pc = poptGetContext(nullptr, argc, argv, long_options, 0);
popt_ret = poptReadDefaultConfig(pc, 0);
if (popt_ret) {
cmd_ret = CMD_ERROR;
}
}
- if (opt_session_name == NULL) {
+ if (opt_session_name == nullptr) {
session_name = get_session_name();
- if (session_name == NULL) {
+ if (session_name == nullptr) {
goto error;
}
free_session_name = true;
static struct poptOption long_options[] = {
/* longName, shortName, argInfo, argPtr, value, descrip, argDesc */
- { "help", 'h', POPT_ARG_NONE, 0, OPT_HELP, 0, 0 },
- { "session", 's', POPT_ARG_STRING, &opt_session_name, 0, 0, 0 },
- { "kernel", 'k', POPT_ARG_VAL, &opt_kernel, 1, 0, 0 },
- { "userspace", 'u', POPT_ARG_NONE, 0, OPT_USERSPACE, 0, 0 },
- { "discard", 0, POPT_ARG_NONE, 0, OPT_DISCARD, 0, 0 },
- { "overwrite", 0, POPT_ARG_NONE, 0, OPT_OVERWRITE, 0, 0 },
- { "subbuf-size", 0, POPT_ARG_STRING, 0, OPT_SUBBUF_SIZE, 0, 0 },
- { "num-subbuf", 0, POPT_ARG_INT, 0, OPT_NUM_SUBBUF, 0, 0 },
- { "switch-timer", 0, POPT_ARG_INT, 0, OPT_SWITCH_TIMER, 0, 0 },
- { "monitor-timer", 0, POPT_ARG_INT, 0, OPT_MONITOR_TIMER, 0, 0 },
- { "read-timer", 0, POPT_ARG_INT, 0, OPT_READ_TIMER, 0, 0 },
- { "list-options", 0, POPT_ARG_NONE, NULL, OPT_LIST_OPTIONS, NULL, NULL },
- { "output", 0, POPT_ARG_STRING, &opt_output, 0, 0, 0 },
- { "buffers-uid", 0, POPT_ARG_VAL, &opt_buffer_uid, 1, 0, 0 },
- { "buffers-pid", 0, POPT_ARG_VAL, &opt_buffer_pid, 1, 0, 0 },
- { "buffers-global", 0, POPT_ARG_VAL, &opt_buffer_global, 1, 0, 0 },
- { "tracefile-size", 'C', POPT_ARG_INT, 0, OPT_TRACEFILE_SIZE, 0, 0 },
- { "tracefile-count", 'W', POPT_ARG_INT, 0, OPT_TRACEFILE_COUNT, 0, 0 },
- { "blocking-timeout", 0, POPT_ARG_INT, 0, OPT_BLOCKING_TIMEOUT, 0, 0 },
- { 0, 0, 0, 0, 0, 0, 0 }
+ { "help", 'h', POPT_ARG_NONE, nullptr, OPT_HELP, nullptr, nullptr },
+ { "session", 's', POPT_ARG_STRING, &opt_session_name, 0, nullptr, nullptr },
+ { "kernel", 'k', POPT_ARG_VAL, &opt_kernel, 1, nullptr, nullptr },
+ { "userspace", 'u', POPT_ARG_NONE, nullptr, OPT_USERSPACE, nullptr, nullptr },
+ { "discard", 0, POPT_ARG_NONE, nullptr, OPT_DISCARD, nullptr, nullptr },
+ { "overwrite", 0, POPT_ARG_NONE, nullptr, OPT_OVERWRITE, nullptr, nullptr },
+ { "subbuf-size", 0, POPT_ARG_STRING, nullptr, OPT_SUBBUF_SIZE, nullptr, nullptr },
+ { "num-subbuf", 0, POPT_ARG_INT, nullptr, OPT_NUM_SUBBUF, nullptr, nullptr },
+ { "switch-timer", 0, POPT_ARG_INT, nullptr, OPT_SWITCH_TIMER, nullptr, nullptr },
+ { "monitor-timer", 0, POPT_ARG_INT, nullptr, OPT_MONITOR_TIMER, nullptr, nullptr },
+ { "read-timer", 0, POPT_ARG_INT, nullptr, OPT_READ_TIMER, nullptr, nullptr },
+ { "list-options", 0, POPT_ARG_NONE, nullptr, OPT_LIST_OPTIONS, nullptr, nullptr },
+ { "output", 0, POPT_ARG_STRING, &opt_output, 0, nullptr, nullptr },
+ { "buffers-uid", 0, POPT_ARG_VAL, &opt_buffer_uid, 1, nullptr, nullptr },
+ { "buffers-pid", 0, POPT_ARG_VAL, &opt_buffer_pid, 1, nullptr, nullptr },
+ { "buffers-global", 0, POPT_ARG_VAL, &opt_buffer_global, 1, nullptr, nullptr },
+ { "tracefile-size", 'C', POPT_ARG_INT, nullptr, OPT_TRACEFILE_SIZE, nullptr, nullptr },
+ { "tracefile-count", 'W', POPT_ARG_INT, nullptr, OPT_TRACEFILE_COUNT, nullptr, nullptr },
+ { "blocking-timeout", 0, POPT_ARG_INT, nullptr, OPT_BLOCKING_TIMEOUT, nullptr, nullptr },
+ { nullptr, 0, 0, nullptr, 0, nullptr, nullptr }
};
/*
*/
static int enable_channel(char *session_name, char *channel_list)
{
- struct lttng_channel *channel = NULL;
+ struct lttng_channel *channel = nullptr;
int ret = CMD_SUCCESS, warn = 0, error = 0, success = 0;
char *channel_name;
struct lttng_domain dom;
}
handle = lttng_create_handle(session_name, &dom);
- if (handle == NULL) {
+ if (handle == nullptr) {
ret = -1;
goto error;
}
/* Strip channel list (format: chan1,chan2,...) */
channel_name = strtok(channel_list, ",");
- while (channel_name != NULL) {
+ while (channel_name != nullptr) {
void *extended_ptr;
/* Validate channel name's length */
}
/* Next channel */
- channel_name = strtok(NULL, ",");
+ channel_name = strtok(nullptr, ",");
lttng_channel_destroy(channel);
- channel = NULL;
+ channel = nullptr;
}
if (lttng_opt_mi) {
/*
* Default value for channel configuration.
*/
-static void init_channel_config(void)
+static void init_channel_config()
{
/*
* Put -1 everywhere so we can identify those set by the command line and
* those needed to be set by the default values.
*/
memset(&chan_opts.attr, -1, sizeof(chan_opts.attr));
- chan_opts.attr.extended.ptr = NULL;
+ chan_opts.attr.extended.ptr = nullptr;
}
/*
{
int opt, ret = CMD_SUCCESS, command_ret = CMD_SUCCESS, success = 1;
static poptContext pc;
- char *session_name = NULL;
- char *channel_list = NULL;
- char *opt_arg = NULL;
- const char *arg_channel_list = NULL;
- const char *leftover = NULL;
+ char *session_name = nullptr;
+ char *channel_list = nullptr;
+ char *opt_arg = nullptr;
+ const char *arg_channel_list = nullptr;
+ const char *leftover = nullptr;
init_channel_config();
- pc = poptGetContext(NULL, argc, argv, long_options, 0);
+ pc = poptGetContext(nullptr, argc, argv, long_options, 0);
poptReadDefaultConfig(pc, 0);
while ((opt = poptGetNextOpt(pc)) != -1) {
errno = 0;
opt_arg = poptGetOptArg(pc);
- chan_opts.attr.num_subbuf = strtoull(opt_arg, NULL, 0);
+ chan_opts.attr.num_subbuf = strtoull(opt_arg, nullptr, 0);
if (errno != 0 || !chan_opts.attr.num_subbuf || !isdigit(opt_arg[0])) {
ERR("Wrong value in --num-subbuf parameter: %s", opt_arg);
ret = CMD_ERROR;
errno = 0;
opt_arg = poptGetOptArg(pc);
- v = strtoul(opt_arg, NULL, 0);
+ v = strtoul(opt_arg, nullptr, 0);
if (errno != 0 || !isdigit(opt_arg[0])) {
ERR("Wrong value in --tracefile-count parameter: %s", opt_arg);
ret = CMD_ERROR;
}
arg_channel_list = poptGetArg(pc);
- if (arg_channel_list == NULL) {
+ if (arg_channel_list == nullptr) {
ERR("Missing channel name.");
ret = CMD_ERROR;
success = 0;
}
channel_list = strdup(arg_channel_list);
- if (channel_list == NULL) {
+ if (channel_list == nullptr) {
PERROR("Failed to copy channel name");
ret = CMD_ERROR;
success = 0;
if (!opt_session_name) {
session_name = get_session_name();
- if (session_name == NULL) {
+ if (session_name == nullptr) {
command_ret = CMD_ERROR;
success = 0;
goto mi_closing;
static struct poptOption long_options[] = {
/* longName, shortName, argInfo, argPtr, value, descrip, argDesc */
- { "help", 'h', POPT_ARG_NONE, 0, OPT_HELP, 0, 0 },
- { "session", 's', POPT_ARG_STRING, &opt_session_name, 0, 0, 0 },
- { "all", 'a', POPT_ARG_VAL, &opt_enable_all, 1, 0, 0 },
- { "channel", 'c', POPT_ARG_STRING, &opt_channel_name, 0, 0, 0 },
- { "kernel", 'k', POPT_ARG_VAL, &opt_kernel, 1, 0, 0 },
- { "userspace", 'u', POPT_ARG_NONE, 0, OPT_USERSPACE, 0, 0 },
- { "jul", 'j', POPT_ARG_VAL, &opt_jul, 1, 0, 0 },
- { "log4j", 'l', POPT_ARG_VAL, &opt_log4j, 1, 0, 0 },
- { "python", 'p', POPT_ARG_VAL, &opt_python, 1, 0, 0 },
- { "tracepoint", 0, POPT_ARG_NONE, 0, OPT_TRACEPOINT, 0, 0 },
- { "probe", 0, POPT_ARG_STRING, &opt_probe, OPT_PROBE, 0, 0 },
- { "userspace-probe", 0, POPT_ARG_STRING, &opt_userspace_probe, OPT_USERSPACE_PROBE, 0, 0 },
- { "function", 0, POPT_ARG_STRING, &opt_function, OPT_FUNCTION, 0, 0 },
- { "syscall", 0, POPT_ARG_NONE, 0, OPT_SYSCALL, 0, 0 },
- { "loglevel", 0, POPT_ARG_STRING, 0, OPT_LOGLEVEL, 0, 0 },
- { "loglevel-only", 0, POPT_ARG_STRING, 0, OPT_LOGLEVEL_ONLY, 0, 0 },
- { "list-options", 0, POPT_ARG_NONE, NULL, OPT_LIST_OPTIONS, NULL, NULL },
- { "filter", 'f', POPT_ARG_STRING, &opt_filter, OPT_FILTER, 0, 0 },
- { "exclude", 'x', POPT_ARG_STRING, &opt_exclude, OPT_EXCLUDE, 0, 0 },
- { 0, 0, 0, 0, 0, 0, 0 }
+ { "help", 'h', POPT_ARG_NONE, nullptr, OPT_HELP, nullptr, nullptr },
+ { "session", 's', POPT_ARG_STRING, &opt_session_name, 0, nullptr, nullptr },
+ { "all", 'a', POPT_ARG_VAL, &opt_enable_all, 1, nullptr, nullptr },
+ { "channel", 'c', POPT_ARG_STRING, &opt_channel_name, 0, nullptr, nullptr },
+ { "kernel", 'k', POPT_ARG_VAL, &opt_kernel, 1, nullptr, nullptr },
+ { "userspace", 'u', POPT_ARG_NONE, nullptr, OPT_USERSPACE, nullptr, nullptr },
+ { "jul", 'j', POPT_ARG_VAL, &opt_jul, 1, nullptr, nullptr },
+ { "log4j", 'l', POPT_ARG_VAL, &opt_log4j, 1, nullptr, nullptr },
+ { "python", 'p', POPT_ARG_VAL, &opt_python, 1, nullptr, nullptr },
+ { "tracepoint", 0, POPT_ARG_NONE, nullptr, OPT_TRACEPOINT, nullptr, nullptr },
+ { "probe", 0, POPT_ARG_STRING, &opt_probe, OPT_PROBE, nullptr, nullptr },
+ { "userspace-probe",
+ 0,
+ POPT_ARG_STRING,
+ &opt_userspace_probe,
+ OPT_USERSPACE_PROBE,
+ nullptr,
+ nullptr },
+ { "function", 0, POPT_ARG_STRING, &opt_function, OPT_FUNCTION, nullptr, nullptr },
+ { "syscall", 0, POPT_ARG_NONE, nullptr, OPT_SYSCALL, nullptr, nullptr },
+ { "loglevel", 0, POPT_ARG_STRING, nullptr, OPT_LOGLEVEL, nullptr, nullptr },
+ { "loglevel-only", 0, POPT_ARG_STRING, nullptr, OPT_LOGLEVEL_ONLY, nullptr, nullptr },
+ { "list-options", 0, POPT_ARG_NONE, nullptr, OPT_LIST_OPTIONS, nullptr, nullptr },
+ { "filter", 'f', POPT_ARG_STRING, &opt_filter, OPT_FILTER, nullptr, nullptr },
+ { "exclude", 'x', POPT_ARG_STRING, &opt_exclude, OPT_EXCLUDE, nullptr, nullptr },
+ { nullptr, 0, 0, nullptr, 0, nullptr, nullptr }
};
/*
#define S_HEX_LEN_SCANF_IS_A_BROKEN_API "18" /* 18 is (19 - 1) (\0 is extra) */
char name[LTTNG_SYMBOL_NAME_LEN];
- if (opt == NULL) {
+ if (opt == nullptr) {
ret = CMD_ERROR;
goto end;
}
ret = CMD_ERROR;
goto end;
}
- ev->attr.probe.offset = strtoull(s_hex, NULL, 0);
+ ev->attr.probe.offset = strtoull(s_hex, nullptr, 0);
DBG("probe offset %" PRIu64, ev->attr.probe.offset);
ev->attr.probe.addr = 0;
goto end;
ret = CMD_ERROR;
goto end;
}
- ev->attr.probe.addr = strtoull(s_hex, NULL, 0);
+ ev->attr.probe.addr = strtoull(s_hex, nullptr, 0);
DBG("probe addr %" PRIu64, ev->attr.probe.addr);
ev->attr.probe.offset = 0;
memset(ev->attr.probe.symbol_name, 0, LTTNG_SYMBOL_NAME_LEN);
length += sizeof(preamble);
ret = calloc<char>(length);
if (!ret) {
- return NULL;
+ return nullptr;
}
strncpy(ret, preamble, length);
{
int ret = CMD_SUCCESS, command_ret = CMD_SUCCESS;
int error_holder = CMD_SUCCESS, warn = 0, error = 0, success = 1;
- char *event_name, *channel_name = NULL;
+ char *event_name, *channel_name = nullptr;
struct lttng_event *ev;
struct lttng_domain dom = {};
struct lttng_dynamic_pointer_array exclusions;
- struct lttng_userspace_probe_location *uprobe_loc = NULL;
+ struct lttng_userspace_probe_location *uprobe_loc = nullptr;
- lttng_dynamic_pointer_array_init(&exclusions, NULL);
+ lttng_dynamic_pointer_array_init(&exclusions, nullptr);
ev = lttng_event_create();
if (!ev) {
channel_name = opt_channel_name;
handle = lttng_create_handle(session_name, &dom);
- if (handle == NULL) {
+ if (handle == nullptr) {
ret = -1;
goto error;
}
handle,
ev,
channel_name,
- NULL,
+ nullptr,
lttng_dynamic_pointer_array_get_count(&exclusions),
(char **) exclusions.array.buffer.data);
if (ret < 0) {
/* Strip event list */
event_name = strtok(event_list, ",");
- while (event_name != NULL) {
+ while (event_name != nullptr) {
/* Copy name and type of the event */
strncpy(ev->name, event_name, LTTNG_SYMBOL_NAME_LEN);
ev->name[LTTNG_SYMBOL_NAME_LEN - 1] = '\0';
}
/* Ownership of the uprobe location was transferred to the event. */
- uprobe_loc = NULL;
+ uprobe_loc = nullptr;
break;
case LTTNG_EVENT_FUNCTION:
ret = parse_probe_opts(ev, opt_function);
handle,
ev,
channel_name,
- NULL,
+ nullptr,
lttng_dynamic_pointer_array_get_count(&exclusions),
(char **) exclusions.array.buffer.data);
exclusion_string = print_exclusions(&exclusions);
}
/* Next event */
- event_name = strtok(NULL, ",");
+ event_name = strtok(nullptr, ",");
/* Reset warn, error and success */
success = 1;
}
{
int opt, ret = CMD_SUCCESS, command_ret = CMD_SUCCESS, success = 1;
static poptContext pc;
- char *session_name = NULL;
- char *event_list = NULL;
- const char *arg_event_list = NULL;
- const char *leftover = NULL;
+ char *session_name = nullptr;
+ char *event_list = nullptr;
+ const char *arg_event_list = nullptr;
+ const char *leftover = nullptr;
int event_type = -1;
- pc = poptGetContext(NULL, argc, argv, long_options, 0);
+ pc = poptGetContext(nullptr, argc, argv, long_options, 0);
poptReadDefaultConfig(pc, 0);
/* Default event type */
}
arg_event_list = poptGetArg(pc);
- if (arg_event_list == NULL && opt_enable_all == 0) {
+ if (arg_event_list == nullptr && opt_enable_all == 0) {
ERR("Missing event name(s).");
ret = CMD_ERROR;
goto end;
if (opt_enable_all == 0) {
event_list = strdup(arg_event_list);
- if (event_list == NULL) {
+ if (event_list == nullptr) {
PERROR("Failed to copy event name(s)");
ret = CMD_ERROR;
goto end;
if (!opt_session_name) {
session_name = get_session_name();
- if (session_name == NULL) {
+ if (session_name == nullptr) {
command_ret = CMD_ERROR;
success = 0;
goto mi_closing;
ret = ret ? ret : LTTNG_ERR_MI_IO_FAIL;
}
- if (opt_session_name == NULL) {
+ if (opt_session_name == nullptr) {
free(session_name);
}
static struct poptOption long_options[] = {
/* longName, shortName, argInfo, argPtr, value, descrip, argDesc */
- { "help", 'h', POPT_ARG_NONE, 0, OPT_HELP, 0, 0 },
- { "list-options", 0, POPT_ARG_NONE, NULL, OPT_LIST_OPTIONS, NULL, NULL },
- { "session", 's', POPT_ARG_STRING, &opt_session_name, 0, 0, 0 },
- { "timer", 0, POPT_ARG_INT, 0, OPT_TIMER, 0, 0 },
- { "size", 0, POPT_ARG_INT, 0, OPT_SIZE, 0, 0 },
- { 0, 0, 0, 0, 0, 0, 0 }
+ { "help", 'h', POPT_ARG_NONE, nullptr, OPT_HELP, nullptr, nullptr },
+ { "list-options", 0, POPT_ARG_NONE, nullptr, OPT_LIST_OPTIONS, nullptr, nullptr },
+ { "session", 's', POPT_ARG_STRING, &opt_session_name, 0, nullptr, nullptr },
+ { "timer", 0, POPT_ARG_INT, nullptr, OPT_TIMER, nullptr, nullptr },
+ { "size", 0, POPT_ARG_INT, nullptr, OPT_SIZE, nullptr, nullptr },
+ { nullptr, 0, 0, nullptr, 0, nullptr, nullptr }
};
static const char *schedule_type_str[] = {
uint64_t value)
{
enum cmd_error_code ret = CMD_SUCCESS;
- struct lttng_rotation_schedule *schedule = NULL;
+ struct lttng_rotation_schedule *schedule = nullptr;
enum lttng_rotation_status status;
const char *schedule_type_name;
int popt_ret, opt, ret = 0;
enum cmd_error_code cmd_ret = CMD_SUCCESS;
static poptContext pc;
- char *session_name = NULL;
- char *opt_arg = NULL;
+ char *session_name = nullptr;
+ char *opt_arg = nullptr;
bool free_session_name = false;
uint64_t timer_us = 0, size_bytes = 0;
bool periodic_rotation = false, size_rotation = false;
- pc = poptGetContext(NULL, argc, argv, long_options, 0);
+ pc = poptGetContext(nullptr, argc, argv, long_options, 0);
popt_ret = poptReadDefaultConfig(pc, 0);
if (popt_ret) {
ERR("poptReadDefaultConfig");
}
}
- if (opt_session_name == NULL) {
+ if (opt_session_name == nullptr) {
session_name = get_session_name();
- if (session_name == NULL) {
+ if (session_name == nullptr) {
goto error;
}
free_session_name = true;
#ifdef LTTNG_EMBED_HELP
#include <lttng.1.h>
#else
- NULL
+ nullptr
#endif
;
static struct poptOption long_options[] = {
/* longName, shortName, argInfo, argPtr, value, descrip, argDesc */
- { "help", 'h', POPT_ARG_NONE, 0, OPT_HELP, 0, 0 },
- { "list-options", 0, POPT_ARG_NONE, NULL, OPT_LIST_OPTIONS, NULL, NULL },
- { 0, 0, 0, 0, 0, 0, 0 }
+ { "help", 'h', POPT_ARG_NONE, nullptr, OPT_HELP, nullptr, nullptr },
+ { "list-options", 0, POPT_ARG_NONE, nullptr, OPT_LIST_OPTIONS, nullptr, nullptr },
+ { nullptr, 0, 0, nullptr, 0, nullptr, nullptr }
};
/*
int found = 0;
const char *cmd_argv[2];
- pc = poptGetContext(NULL, argc, argv, long_options, 0);
+ pc = poptGetContext(nullptr, argc, argv, long_options, 0);
poptReadDefaultConfig(pc, 0);
while ((opt = poptGetNextOpt(pc)) != -1) {
/* Get command name */
arg_cmd_name = poptGetArg(pc);
- if (arg_cmd_name == NULL) {
+ if (arg_cmd_name == nullptr) {
/* Fall back to lttng(1) */
ret = utils_show_help(1, "lttng", lttng_help_msg);
if (ret) {
/* Make sure command name exists */
cmd = &commands[0];
- while (cmd->name != NULL) {
+ while (cmd->name != nullptr) {
if (strcmp(cmd->name, arg_cmd_name) == 0) {
found = 1;
break;
static struct poptOption long_options[] = {
/* longName, shortName, argInfo, argPtr, value, descrip, argDesc */
- { "help", 'h', POPT_ARG_NONE, 0, OPT_HELP, 0, 0 },
- { "kernel", 'k', POPT_ARG_VAL, &opt_kernel, 1, 0, 0 },
- { "jul", 'j', POPT_ARG_VAL, &opt_jul, 1, 0, 0 },
- { "log4j", 'l', POPT_ARG_VAL, &opt_log4j, 1, 0, 0 },
- { "python", 'p', POPT_ARG_VAL, &opt_python, 1, 0, 0 },
- { "userspace", 'u', POPT_ARG_NONE, 0, OPT_USERSPACE, 0, 0 },
- { "channel", 'c', POPT_ARG_STRING, &opt_channel, 0, 0, 0 },
- { "domain", 'd', POPT_ARG_VAL, &opt_domain, 1, 0, 0 },
- { "fields", 'f', POPT_ARG_VAL, &opt_fields, 1, 0, 0 },
- { "syscall", 'S', POPT_ARG_VAL, &opt_syscall, 1, 0, 0 },
- { "list-options", 0, POPT_ARG_NONE, NULL, OPT_LIST_OPTIONS, NULL, NULL },
- { 0, 0, 0, 0, 0, 0, 0 }
+ { "help", 'h', POPT_ARG_NONE, nullptr, OPT_HELP, nullptr, nullptr },
+ { "kernel", 'k', POPT_ARG_VAL, &opt_kernel, 1, nullptr, nullptr },
+ { "jul", 'j', POPT_ARG_VAL, &opt_jul, 1, nullptr, nullptr },
+ { "log4j", 'l', POPT_ARG_VAL, &opt_log4j, 1, nullptr, nullptr },
+ { "python", 'p', POPT_ARG_VAL, &opt_python, 1, nullptr, nullptr },
+ { "userspace", 'u', POPT_ARG_NONE, nullptr, OPT_USERSPACE, nullptr, nullptr },
+ { "channel", 'c', POPT_ARG_STRING, &opt_channel, 0, nullptr, nullptr },
+ { "domain", 'd', POPT_ARG_VAL, &opt_domain, 1, nullptr, nullptr },
+ { "fields", 'f', POPT_ARG_VAL, &opt_fields, 1, nullptr, nullptr },
+ { "syscall", 'S', POPT_ARG_VAL, &opt_syscall, 1, nullptr, nullptr },
+ { "list-options", 0, POPT_ARG_NONE, nullptr, OPT_LIST_OPTIONS, nullptr, nullptr },
+ { nullptr, 0, 0, nullptr, 0, nullptr, nullptr }
};
/*
static char *get_cmdline_by_pid(pid_t pid)
{
int ret;
- FILE *fp = NULL;
- char *cmdline = NULL;
+ FILE *fp = nullptr;
+ char *cmdline = nullptr;
/* Can't go bigger than /proc/LTTNG_MAX_PID/cmdline */
char path[sizeof("/proc//cmdline") + sizeof(LTTNG_MAX_PID_STR) - 1];
snprintf(path, sizeof(path), "/proc/%d/cmdline", pid);
fp = fopen(path, "r");
- if (fp == NULL) {
+ if (fp == nullptr) {
goto end;
}
case -1:
return "";
default:
- return NULL;
+ return nullptr;
}
}
case -1:
return "";
default:
- return NULL;
+ return nullptr;
}
}
{
int ret;
int exclusion_count;
- char *exclusion_msg = NULL;
+ char *exclusion_msg = nullptr;
char *at;
size_t i;
const char *const exclusion_fmt = " [exclusions: ";
MSG("%sType: Function", indent8);
function_name = lttng_userspace_probe_location_function_get_function_name(location);
binary_path = realpath(
- lttng_userspace_probe_location_function_get_binary_path(location), NULL);
+ lttng_userspace_probe_location_function_get_binary_path(location), nullptr);
MSG("%sBinary path: %s", indent8, binary_path ? binary_path : "NULL");
MSG("%sFunction: %s()", indent8, function_name ? function_name : "NULL");
provider_name =
lttng_userspace_probe_location_tracepoint_get_provider_name(location);
binary_path = realpath(
- lttng_userspace_probe_location_tracepoint_get_binary_path(location), NULL);
+ lttng_userspace_probe_location_tracepoint_get_binary_path(location),
+ nullptr);
MSG("%sBinary path: %s", indent8, binary_path ? binary_path : "NULL");
MSG("%sTracepoint: %s:%s",
indent8,
{
int ret;
const char *filter_str;
- char *filter_msg = NULL;
- char *exclusion_msg = NULL;
+ char *filter_msg = nullptr;
+ char *exclusion_msg = nullptr;
ret = lttng_event_get_filter_expression(event, &filter_str);
filter_msg = strdup(" [failed to retrieve filter]");
} else if (filter_str) {
if (asprintf(&filter_msg, " [filter: '%s']", filter_str) == -1) {
- filter_msg = NULL;
+ filter_msg = nullptr;
}
}
{
int ret, i;
pid_t cur_pid = 0;
- char *cmdline = NULL;
+ char *cmdline = nullptr;
int pid_element_open = 0;
/* Open domains element */
return ret;
}
-static int list_agent_events(void)
+static int list_agent_events()
{
int i, size, ret = CMD_SUCCESS;
struct lttng_domain domain;
- struct lttng_handle *handle = NULL;
- struct lttng_event *event_list = NULL;
+ struct lttng_handle *handle = nullptr;
+ struct lttng_event *event_list = nullptr;
pid_t cur_pid = 0;
- char *cmdline = NULL;
+ char *cmdline = nullptr;
const char *agent_domain_str;
memset(&domain, 0, sizeof(domain));
DBG("Getting %s tracing events", agent_domain_str);
- handle = lttng_create_handle(NULL, &domain);
- if (handle == NULL) {
+ handle = lttng_create_handle(nullptr, &domain);
+ if (handle == nullptr) {
ret = CMD_ERROR;
goto end;
}
if (cur_pid != event_list[i].pid) {
cur_pid = event_list[i].pid;
cmdline = get_cmdline_by_pid(cur_pid);
- if (cmdline == NULL) {
+ if (cmdline == nullptr) {
ret = CMD_ERROR;
goto error;
}
/*
* Ask session daemon for all user space tracepoints available.
*/
-static int list_ust_events(void)
+static int list_ust_events()
{
int i, size, ret = CMD_SUCCESS;
struct lttng_domain domain;
struct lttng_handle *handle;
- struct lttng_event *event_list = NULL;
+ struct lttng_event *event_list = nullptr;
pid_t cur_pid = 0;
- char *cmdline = NULL;
+ char *cmdline = nullptr;
memset(&domain, 0, sizeof(domain));
domain.type = LTTNG_DOMAIN_UST;
- handle = lttng_create_handle(NULL, &domain);
- if (handle == NULL) {
+ handle = lttng_create_handle(nullptr, &domain);
+ if (handle == nullptr) {
ret = CMD_ERROR;
goto end;
}
if (cur_pid != event_list[i].pid) {
cur_pid = event_list[i].pid;
cmdline = get_cmdline_by_pid(cur_pid);
- if (cmdline == NULL) {
+ if (cmdline == nullptr) {
ret = CMD_ERROR;
goto error;
}
{
int ret, i;
pid_t cur_pid = 0;
- char *cmdline = NULL;
+ char *cmdline = nullptr;
int pid_element_open = 0;
int event_element_open = 0;
struct lttng_event cur_event;
/*
* Ask session daemon for all user space tracepoint fields available.
*/
-static int list_ust_event_fields(void)
+static int list_ust_event_fields()
{
int i, size, ret = CMD_SUCCESS;
struct lttng_domain domain;
struct lttng_handle *handle;
struct lttng_event_field *event_field_list;
pid_t cur_pid = 0;
- char *cmdline = NULL;
+ char *cmdline = nullptr;
struct lttng_event cur_event;
domain.type = LTTNG_DOMAIN_UST;
- handle = lttng_create_handle(NULL, &domain);
- if (handle == NULL) {
+ handle = lttng_create_handle(nullptr, &domain);
+ if (handle == nullptr) {
ret = CMD_ERROR;
goto end;
}
if (cur_pid != event_field_list[i].event.pid) {
cur_pid = event_field_list[i].event.pid;
cmdline = get_cmdline_by_pid(cur_pid);
- if (cmdline == NULL) {
+ if (cmdline == nullptr) {
ret = CMD_ERROR;
goto error;
}
/*
* Ask for all trace events in the kernel
*/
-static int list_kernel_events(void)
+static int list_kernel_events()
{
int i, size, ret = CMD_SUCCESS;
struct lttng_domain domain;
domain.type = LTTNG_DOMAIN_KERNEL;
- handle = lttng_create_handle(NULL, &domain);
- if (handle == NULL) {
+ handle = lttng_create_handle(nullptr, &domain);
+ if (handle == nullptr) {
ret = CMD_ERROR;
goto error;
}
/*
* Ask for kernel system calls.
*/
-static int list_syscalls(void)
+static int list_syscalls()
{
int i, size, ret = CMD_SUCCESS;
struct lttng_event *event_list;
*
* Return CMD_SUCCESS on success else a negative value.
*/
-static int list_session_agent_events(void)
+static int list_session_agent_events()
{
int ret = CMD_SUCCESS, count, i;
- struct lttng_event *events = NULL;
+ struct lttng_event *events = nullptr;
count = lttng_list_events(the_handle, "", &events);
if (count < 0) {
for (i = 0; i < count; i++) {
const char *filter_str;
- char *filter_msg = NULL;
+ char *filter_msg = nullptr;
struct lttng_event *event = &events[i];
ret = lttng_event_get_filter_expression(event, &filter_str);
filter_msg = strdup(" [failed to retrieve filter]");
} else if (filter_str) {
if (asprintf(&filter_msg, " [filter: '%s']", filter_str) == -1) {
- filter_msg = NULL;
+ filter_msg = nullptr;
}
}
static int list_events(const char *channel_name)
{
int ret = CMD_SUCCESS, count, i;
- struct lttng_event *events = NULL;
+ struct lttng_event *events = nullptr;
count = lttng_list_events(the_handle, channel_name, &events);
if (count < 0) {
}
for (i = 0; i < count; i++) {
- if (channel_name != NULL) {
+ if (channel_name != nullptr) {
if (strncmp(channels[i].name, channel_name, NAME_MAX) == 0) {
chan_found = 1;
} else {
{
int count, i, ret = CMD_SUCCESS;
unsigned int chan_found = 0;
- struct lttng_channel *channels = NULL;
+ struct lttng_channel *channels = nullptr;
DBG("Listing channel(s) (%s)", channel_name ?: "<all>");
}
for (i = 0; i < count; i++) {
- if (channel_name != NULL) {
+ if (channel_name != nullptr) {
if (strncmp(channels[i].name, channel_name, NAME_MAX) == 0) {
chan_found = 1;
} else {
}
}
- if (!chan_found && channel_name != NULL) {
+ if (!chan_found && channel_name != nullptr) {
ret = CMD_ERROR;
ERR("Channel %s not found", channel_name);
goto error;
default:
return "Unknown";
}
- return NULL;
+ return nullptr;
}
static int handle_process_attr_status(enum lttng_process_attr process_attr,
enum lttng_process_attr_tracker_handle_status handle_status;
enum lttng_process_attr_values_status values_status;
const struct lttng_process_attr_values *values;
- struct lttng_process_attr_tracker_handle *tracker_handle = NULL;
+ struct lttng_process_attr_tracker_handle *tracker_handle = nullptr;
ret_code = lttng_session_get_tracker_handle(
the_handle->session_name, the_handle->domain.type, process_attr, &tracker_handle);
int ret;
enum cmd_error_code cmd_ret = CMD_SUCCESS;
unsigned int count, i;
- struct lttng_rotation_schedules *schedules = NULL;
+ struct lttng_rotation_schedules *schedules = nullptr;
enum lttng_rotation_status status;
ret = lttng_session_list_rotation_schedules(session_name, &schedules);
int ret, i;
unsigned int session_found = 0;
- if (session_name == NULL) {
+ if (session_name == nullptr) {
ret = -LTTNG_ERR_SESS_NOT_FOUND;
goto end;
}
int ret = CMD_SUCCESS;
int count, i;
unsigned int session_found = 0;
- struct lttng_session *sessions = NULL;
+ struct lttng_session *sessions = nullptr;
count = lttng_list_sessions(&sessions);
DBG("Session count %d", count);
if (lttng_opt_mi) {
/* Mi */
- if (session_name == NULL) {
+ if (session_name == nullptr) {
/* List all sessions */
ret = mi_list_sessions(sessions, count);
} else {
goto end;
}
- if (session_name == NULL) {
+ if (session_name == nullptr) {
MSG("Available recording sessions:");
}
for (i = 0; i < count; i++) {
- if (session_name != NULL) {
+ if (session_name != nullptr) {
if (strncmp(sessions[i].name, session_name, NAME_MAX) == 0) {
session_found = 1;
MSG("Recording session %s: [%s%s]",
}
}
- if (!session_found && session_name != NULL) {
+ if (!session_found && session_name != nullptr) {
ERR("Session '%s' not found", session_name);
ret = CMD_ERROR;
goto end;
}
- if (session_name == NULL) {
+ if (session_name == nullptr) {
MSG("\nUse lttng list <session_name> for more details");
}
}
static int list_domains(const char *session_name)
{
int i, count, ret = CMD_SUCCESS;
- struct lttng_domain *domains = NULL;
+ struct lttng_domain *domains = nullptr;
count = lttng_list_domains(session_name, &domains);
if (count < 0) {
int cmd_list(int argc, const char **argv)
{
int opt, ret = CMD_SUCCESS;
- const char *arg_session_name, *leftover = NULL;
+ const char *arg_session_name, *leftover = nullptr;
static poptContext pc;
struct lttng_domain domain;
- struct lttng_domain *domains = NULL;
+ struct lttng_domain *domains = nullptr;
memset(&domain, 0, sizeof(domain));
goto end;
}
- pc = poptGetContext(NULL, argc, argv, long_options, 0);
+ pc = poptGetContext(nullptr, argc, argv, long_options, 0);
poptReadDefaultConfig(pc, 0);
while ((opt = poptGetNextOpt(pc)) != -1) {
if (opt_kernel || opt_userspace || opt_jul || opt_log4j || opt_python) {
the_handle = lttng_create_handle(arg_session_name, &domain);
- if (the_handle == NULL) {
+ if (the_handle == nullptr) {
ret = CMD_FATAL;
goto end;
}
}
- if (arg_session_name == NULL) {
+ if (arg_session_name == nullptr) {
if (!opt_kernel && !opt_userspace && !opt_jul && !opt_log4j && !opt_python) {
- ret = list_sessions(NULL);
+ ret = list_sessions(nullptr);
if (ret) {
goto end;
}
}
the_handle = lttng_create_handle(arg_session_name, &domains[i]);
- if (the_handle == NULL) {
+ if (the_handle == nullptr) {
ret = CMD_FATAL;
goto end;
}
static const char *get_pretty_loglevel_name(enum lttng_event_rule_type event_rule_type,
int loglevel)
{
- const char *name = NULL;
+ const char *name = nullptr;
switch (event_rule_type) {
case LTTNG_EVENT_RULE_TYPE_USER_TRACEPOINT:
const char *pattern;
const char *filter;
int log_level;
- const struct lttng_log_level_rule *log_level_rule = NULL;
+ const struct lttng_log_level_rule *log_level_rule = nullptr;
unsigned int exclusions_count;
int i;
const char *pattern;
const char *filter;
int log_level;
- const struct lttng_log_level_rule *log_level_rule = NULL;
- const char *type_str = NULL;
+ const struct lttng_log_level_rule *log_level_rule = nullptr;
+ const char *type_str = nullptr;
event_rule_logging_get_name_pattern logging_get_name_pattern;
event_rule_logging_get_filter logging_get_filter;
enum lttng_event_expr_status status;
parent_expr = lttng_event_expr_array_field_element_get_parent_expr(event_expr);
- LTTNG_ASSERT(parent_expr != NULL);
+ LTTNG_ASSERT(parent_expr != nullptr);
print_one_event_expr(parent_expr);
size_t action_path_length)
{
enum lttng_error_code error_query_ret;
- struct lttng_error_query_results *results = NULL;
+ struct lttng_error_query_results *results = nullptr;
const char *trigger_name;
uid_t trigger_uid;
enum lttng_trigger_status trigger_status;
{
enum lttng_action_type action_type;
enum lttng_action_status action_status;
- const struct lttng_rate_policy *policy = NULL;
+ const struct lttng_rate_policy *policy = nullptr;
const char *value;
action_type = lttng_action_get_type(action);
static void print_trigger_errors(const struct lttng_trigger *trigger)
{
enum lttng_error_code error_query_ret;
- struct lttng_error_query_results *results = NULL;
+ struct lttng_error_query_results *results = nullptr;
enum lttng_trigger_status trigger_status;
const char *trigger_name;
uid_t trigger_uid;
static void print_condition_errors(const struct lttng_trigger *trigger)
{
enum lttng_error_code error_query_ret;
- struct lttng_error_query_results *results = NULL;
+ struct lttng_error_query_results *results = nullptr;
enum lttng_trigger_status trigger_status;
const char *trigger_name;
uid_t trigger_uid;
}
} else {
_MSG(" action:");
- print_one_action(trigger, action, NULL, 0);
+ print_one_action(trigger, action, nullptr, 0);
}
print_trigger_errors(trigger);
enum lttng_trigger_status trigger_status;
unsigned int num_triggers;
- lttng_dynamic_pointer_array_init(&sorted_triggers, NULL);
+ lttng_dynamic_pointer_array_init(&sorted_triggers, nullptr);
trigger_status = lttng_triggers_get_count(triggers, &num_triggers);
if (trigger_status != LTTNG_TRIGGER_STATUS_OK) {
int cmd_list_triggers(int argc, const char **argv)
{
int ret;
- struct argpar_iter *argpar_iter = NULL;
- const struct argpar_item *argpar_item = NULL;
- struct lttng_triggers *triggers = NULL;
- struct mi_writer *mi_writer = NULL;
+ struct argpar_iter *argpar_iter = nullptr;
+ const struct argpar_item *argpar_item = nullptr;
+ struct lttng_triggers *triggers = nullptr;
+ struct mi_writer *mi_writer = nullptr;
argc--;
argv++;
while (true) {
enum parse_next_item_status status;
- status = parse_next_item(argpar_iter, &argpar_item, 1, argv, true, NULL, NULL);
+ status =
+ parse_next_item(argpar_iter, &argpar_item, 1, argv, true, nullptr, nullptr);
if (status == PARSE_NEXT_ITEM_STATUS_ERROR ||
status == PARSE_NEXT_ITEM_STATUS_ERROR_MEMORY) {
goto error;
static struct poptOption the_load_opts[] = {
/* longName, shortName, argInfo, argPtr, value, descrip, argDesc */
- { "help", 'h', POPT_ARG_NONE, 0, OPT_HELP, 0, 0 },
- { "all", 'a', POPT_ARG_NONE, 0, OPT_ALL, 0, 0 },
- { "input-path", 'i', POPT_ARG_STRING, &the_opt_input_path, 0, 0, 0 },
- { "force", 'f', POPT_ARG_NONE, 0, OPT_FORCE, 0, 0 },
- { "override-url", 0, POPT_ARG_STRING, &the_opt_override_url, 0, 0, 0 },
- { "override-name", 0, POPT_ARG_STRING, &the_opt_override_session_name, 0, 0, 0 },
- { "list-options", 0, POPT_ARG_NONE, NULL, OPT_LIST_OPTIONS, NULL, NULL },
- { 0, 0, 0, 0, 0, 0, 0 }
+ { "help", 'h', POPT_ARG_NONE, nullptr, OPT_HELP, nullptr, nullptr },
+ { "all", 'a', POPT_ARG_NONE, nullptr, OPT_ALL, nullptr, nullptr },
+ { "input-path", 'i', POPT_ARG_STRING, &the_opt_input_path, 0, nullptr, nullptr },
+ { "force", 'f', POPT_ARG_NONE, nullptr, OPT_FORCE, nullptr, nullptr },
+ { "override-url", 0, POPT_ARG_STRING, &the_opt_override_url, 0, nullptr, nullptr },
+ { "override-name", 0, POPT_ARG_STRING, &the_opt_override_session_name, 0, nullptr, nullptr },
+ { "list-options", 0, POPT_ARG_NONE, nullptr, OPT_LIST_OPTIONS, nullptr, nullptr },
+ { nullptr, 0, 0, nullptr, 0, nullptr, nullptr }
};
static int mi_partial_session(const char *session_name)
int ret, success;
int opt;
poptContext pc;
- struct lttng_load_session_attr *session_attr = NULL;
- char *input_path = NULL;
- const char *leftover = NULL;
+ struct lttng_load_session_attr *session_attr = nullptr;
+ char *input_path = nullptr;
+ const char *leftover = nullptr;
- pc = poptGetContext(NULL, argc, argv, the_load_opts, 0);
+ pc = poptGetContext(nullptr, argc, argv, the_load_opts, 0);
poptReadDefaultConfig(pc, 0);
while ((opt = poptGetNextOpt(pc)) != -1) {
* Use realpath to resolve any relative path.
* */
if (the_opt_input_path) {
- input_path = realpath(the_opt_input_path, NULL);
+ input_path = realpath(the_opt_input_path, nullptr);
if (!input_path) {
PERROR("Invalid input path");
ret = CMD_ERROR;
goto end;
}
} else {
- input_path = NULL;
+ input_path = nullptr;
}
ret = lttng_load_session_attr_set_input_url(session_attr, input_path);
#include <unistd.h>
static char *opt_session_name;
-static char *session_name = NULL;
+static char *session_name = nullptr;
static int metadata_regenerate(int argc, const char **argv);
"help",
'h',
POPT_ARG_NONE,
- 0,
+ nullptr,
OPT_HELP,
- 0,
- 0,
+ nullptr,
+ nullptr,
},
- { "session", 's', POPT_ARG_STRING, &opt_session_name, 0, 0, 0 },
+ { "session", 's', POPT_ARG_STRING, &opt_session_name, 0, nullptr, nullptr },
{
"list-options",
0,
POPT_ARG_NONE,
- NULL,
+ nullptr,
OPT_LIST_OPTIONS,
- 0,
- 0,
+ nullptr,
+ nullptr,
},
- { "list-commands", 0, POPT_ARG_NONE, NULL, OPT_LIST_COMMANDS, NULL, NULL },
+ { "list-commands", 0, POPT_ARG_NONE, nullptr, OPT_LIST_COMMANDS, nullptr, nullptr },
{
+ nullptr,
0,
0,
+ nullptr,
0,
- 0,
- 0,
- 0,
- 0,
+ nullptr,
+ nullptr,
},
};
static struct cmd_struct actions[] = {
- { "regenerate", metadata_regenerate }, { NULL, NULL } /* Array closure */
+ { "regenerate", metadata_regenerate }, { nullptr, nullptr } /* Array closure */
};
/*
LTTNG_ASSERT(argv);
- while (argv[i] != NULL) {
+ while (argv[i] != nullptr) {
i++;
}
struct cmd_struct *cmd;
int ret = CMD_SUCCESS, i = 0, argc, command_ret = CMD_SUCCESS;
- if (argv == NULL) {
+ if (argv == nullptr) {
ERR("No action specified for metadata command.");
ret = CMD_ERROR;
goto end;
LTTNG_ASSERT(argc >= 1);
cmd = &actions[i];
- while (cmd->func != NULL) {
+ while (cmd->func != nullptr) {
/* Find command */
if (strcmp(argv[0], cmd->name) == 0) {
if (lttng_opt_mi) {
goto end;
}
- pc = poptGetContext(NULL, argc, argv, long_options, 0);
+ pc = poptGetContext(nullptr, argc, argv, long_options, 0);
poptReadDefaultConfig(pc, 0);
if (lttng_opt_mi) {
if (!opt_session_name) {
session_name = get_session_name();
- if (session_name == NULL) {
+ if (session_name == nullptr) {
ret = CMD_ERROR;
goto end;
}
#include <unistd.h>
static char *opt_session_name;
-static char *session_name = NULL;
+static char *session_name = nullptr;
static int regenerate_metadata(int argc, const char **argv);
static int regenerate_statedump(int argc, const char **argv);
"help",
'h',
POPT_ARG_NONE,
- 0,
+ nullptr,
OPT_HELP,
- 0,
- 0,
+ nullptr,
+ nullptr,
},
- { "session", 's', POPT_ARG_STRING, &opt_session_name, 0, 0, 0 },
+ { "session", 's', POPT_ARG_STRING, &opt_session_name, 0, nullptr, nullptr },
{
"list-options",
0,
POPT_ARG_NONE,
- NULL,
+ nullptr,
OPT_LIST_OPTIONS,
- 0,
- 0,
+ nullptr,
+ nullptr,
},
- { "list-commands", 0, POPT_ARG_NONE, NULL, OPT_LIST_COMMANDS, NULL, NULL },
+ { "list-commands", 0, POPT_ARG_NONE, nullptr, OPT_LIST_COMMANDS, nullptr, nullptr },
{
+ nullptr,
0,
0,
+ nullptr,
0,
- 0,
- 0,
- 0,
- 0,
+ nullptr,
+ nullptr,
},
};
static struct cmd_struct actions[] = {
{ "metadata", regenerate_metadata },
{ "statedump", regenerate_statedump },
- { NULL, NULL } /* Array closure */
+ { nullptr, nullptr } /* Array closure */
};
/*
LTTNG_ASSERT(argv);
- while (argv[i] != NULL) {
+ while (argv[i] != nullptr) {
i++;
}
struct cmd_struct *cmd;
int ret = CMD_SUCCESS, i = 0, argc, command_ret = CMD_SUCCESS;
- if (argv == NULL) {
+ if (argv == nullptr) {
ERR("No object specified for regenerate command.");
command_ret = CMD_ERROR;
goto end;
LTTNG_ASSERT(argc >= 1);
cmd = &actions[i];
- while (cmd->func != NULL) {
+ while (cmd->func != nullptr) {
/* Find command */
if (strcmp(argv[0], cmd->name) == 0) {
if (lttng_opt_mi) {
goto end;
}
- pc = poptGetContext(NULL, argc, argv, long_options, 0);
+ pc = poptGetContext(nullptr, argc, argv, long_options, 0);
poptReadDefaultConfig(pc, 0);
if (lttng_opt_mi) {
if (!opt_session_name) {
session_name = get_session_name();
- if (session_name == NULL) {
+ if (session_name == nullptr) {
ret = CMD_ERROR;
goto end;
}
{
enum lttng_error_code ret_code;
int ret;
- struct argpar_iter *argpar_iter = NULL;
- const struct argpar_item *argpar_item = NULL;
- const char *name = NULL;
+ struct argpar_iter *argpar_iter = nullptr;
+ const struct argpar_item *argpar_item = nullptr;
+ const char *name = nullptr;
int i;
- struct lttng_triggers *triggers = NULL;
+ struct lttng_triggers *triggers = nullptr;
unsigned int triggers_count;
enum lttng_trigger_status trigger_status;
- const struct lttng_trigger *trigger_to_remove = NULL;
- char *owner_uid = NULL;
+ const struct lttng_trigger *trigger_to_remove = nullptr;
+ char *owner_uid = nullptr;
long long uid;
- struct mi_writer *mi_writer = NULL;
+ struct mi_writer *mi_writer = nullptr;
if (lttng_opt_mi) {
mi_writer = mi_lttng_writer_create(fileno(stdout), lttng_opt_mi);
while (true) {
enum parse_next_item_status status;
- status = parse_next_item(argpar_iter, &argpar_item, 1, argv, true, NULL, NULL);
+ status =
+ parse_next_item(argpar_iter, &argpar_item, 1, argv, true, nullptr, nullptr);
if (status == PARSE_NEXT_ITEM_STATUS_ERROR ||
status == PARSE_NEXT_ITEM_STATUS_ERROR_MEMORY) {
goto error;
}
if (lttng_opt_mi) {
- ret_code = lttng_trigger_mi_serialize(trigger_to_remove, mi_writer, NULL);
+ ret_code = lttng_trigger_mi_serialize(trigger_to_remove, mi_writer, nullptr);
if (ret_code != LTTNG_OK) {
goto error;
}
static struct poptOption long_options[] = {
/* longName, shortName, argInfo, argPtr, value, descrip, argDesc */
- { "help", 'h', POPT_ARG_NONE, 0, OPT_HELP, 0, 0 },
- { "list-options", 0, POPT_ARG_NONE, NULL, OPT_LIST_OPTIONS, NULL, NULL },
- { "no-wait", 'n', POPT_ARG_VAL, &opt_no_wait, 1, 0, 0 },
- { 0, 0, 0, 0, 0, 0, 0 }
+ { "help", 'h', POPT_ARG_NONE, nullptr, OPT_HELP, nullptr, nullptr },
+ { "list-options", 0, POPT_ARG_NONE, nullptr, OPT_LIST_OPTIONS, nullptr, nullptr },
+ { "no-wait", 'n', POPT_ARG_VAL, &opt_no_wait, 1, nullptr, nullptr },
+ { nullptr, 0, 0, nullptr, 0, nullptr, nullptr }
};
static int rotate_tracing(char *session_name)
{
int ret;
enum cmd_error_code cmd_ret = CMD_SUCCESS;
- struct lttng_rotation_handle *handle = NULL;
+ struct lttng_rotation_handle *handle = nullptr;
enum lttng_rotation_status rotation_status;
enum lttng_rotation_state rotation_state = LTTNG_ROTATION_STATE_ONGOING;
- const struct lttng_trace_archive_location *location = NULL;
+ const struct lttng_trace_archive_location *location = nullptr;
bool print_location = true;
DBG("Rotating the output files of session %s", session_name);
- ret = lttng_rotate_session(session_name, NULL, &handle);
+ ret = lttng_rotate_session(session_name, nullptr, &handle);
if (ret < 0) {
switch (-ret) {
case LTTNG_ERR_SESSION_NOT_STARTED:
enum cmd_error_code cmd_ret = CMD_SUCCESS;
int popt_ret;
static poptContext pc;
- const char *arg_session_name = NULL;
- char *session_name = NULL;
+ const char *arg_session_name = nullptr;
+ char *session_name = nullptr;
- pc = poptGetContext(NULL, argc, argv, long_options, 0);
+ pc = poptGetContext(nullptr, argc, argv, long_options, 0);
popt_ret = poptReadDefaultConfig(pc, 0);
if (popt_ret) {
ERR("poptReadDefaultConfig");
}
arg_session_name = poptGetArg(pc);
- if (arg_session_name == NULL) {
+ if (arg_session_name == nullptr) {
session_name = get_session_name();
} else {
session_name = strdup(arg_session_name);
- if (session_name == NULL) {
+ if (session_name == nullptr) {
PERROR("Failed to copy session name");
}
}
- if (session_name == NULL) {
+ if (session_name == nullptr) {
cmd_ret = CMD_ERROR;
goto end;
}
static struct poptOption save_opts[] = {
/* longName, shortName, argInfo, argPtr, value, descrip, argDesc */
- { "help", 'h', POPT_ARG_NONE, NULL, OPT_HELP, NULL, NULL },
- { "all", 'a', POPT_ARG_NONE, NULL, OPT_ALL, NULL, NULL },
- { "output-path", 'o', POPT_ARG_STRING, &opt_output_path, 0, NULL, NULL },
- { "force", 'f', POPT_ARG_NONE, NULL, OPT_FORCE, NULL, NULL },
- { "list-options", 0, POPT_ARG_NONE, NULL, OPT_LIST_OPTIONS, NULL, NULL },
- { 0, 0, 0, 0, 0, 0, 0 }
+ { "help", 'h', POPT_ARG_NONE, nullptr, OPT_HELP, nullptr, nullptr },
+ { "all", 'a', POPT_ARG_NONE, nullptr, OPT_ALL, nullptr, nullptr },
+ { "output-path", 'o', POPT_ARG_STRING, &opt_output_path, 0, nullptr, nullptr },
+ { "force", 'f', POPT_ARG_NONE, nullptr, OPT_FORCE, nullptr, nullptr },
+ { "list-options", 0, POPT_ARG_NONE, nullptr, OPT_LIST_OPTIONS, nullptr, nullptr },
+ { nullptr, 0, 0, nullptr, 0, nullptr, nullptr }
};
static int mi_partial_session(const char *session_name)
{
int ret = CMD_SUCCESS, command_ret = CMD_SUCCESS, success;
int opt;
- const char *arg_session_name = NULL, *leftover = NULL;
+ const char *arg_session_name = nullptr, *leftover = nullptr;
poptContext pc;
struct lttng_save_session_attr *attr;
- pc = poptGetContext(NULL, argc, argv, save_opts, 0);
+ pc = poptGetContext(nullptr, argc, argv, save_opts, 0);
poptReadDefaultConfig(pc, 0);
while ((opt = poptGetNextOpt(pc)) != -1) {
static struct poptOption long_options[] = {
/* longName, shortName, argInfo, argPtr, value, descrip, argDesc */
- { "help", 'h', POPT_ARG_NONE, 0, OPT_HELP, 0, 0 },
- { "list-options", 0, POPT_ARG_NONE, NULL, OPT_LIST_OPTIONS, NULL, NULL },
- { 0, 0, 0, 0, 0, 0, 0 }
+ { "help", 'h', POPT_ARG_NONE, nullptr, OPT_HELP, nullptr, nullptr },
+ { "list-options", 0, POPT_ARG_NONE, nullptr, OPT_LIST_OPTIONS, nullptr, nullptr },
+ { nullptr, 0, 0, nullptr, 0, nullptr, nullptr }
};
/*
{
int opt, ret = CMD_SUCCESS, command_ret = CMD_SUCCESS, success = 1;
static poptContext pc;
- const char *arg_session_name = NULL;
+ const char *arg_session_name = nullptr;
- pc = poptGetContext(NULL, argc, argv, long_options, 0);
+ pc = poptGetContext(nullptr, argc, argv, long_options, 0);
poptReadDefaultConfig(pc, 0);
while ((opt = poptGetNextOpt(pc)) != -1) {
}
arg_session_name = poptGetArg(pc);
- if (arg_session_name == NULL) {
+ if (arg_session_name == nullptr) {
ERR("Missing session name");
ret = CMD_ERROR;
goto end;
static struct poptOption snapshot_opts[] = {
/* longName, shortName, argInfo, argPtr, value, descrip, argDesc */
- { "help", 'h', POPT_ARG_NONE, 0, OPT_HELP, 0, 0 },
- { "session", 's', POPT_ARG_STRING, &opt_session_name, 0, 0, 0 },
- { "ctrl-url", 'C', POPT_ARG_STRING, &opt_ctrl_url, 0, 0, 0 },
- { "data-url", 'D', POPT_ARG_STRING, &opt_data_url, 0, 0, 0 },
- { "name", 'n', POPT_ARG_STRING, &opt_output_name, 0, 0, 0 },
- { "max-size", 'm', POPT_ARG_STRING, 0, OPT_MAX_SIZE, 0, 0 },
- { "list-options", 0, POPT_ARG_NONE, NULL, OPT_LIST_OPTIONS, NULL, NULL },
- { "list-commands", 0, POPT_ARG_NONE, NULL, OPT_LIST_COMMANDS, NULL, NULL },
- { 0, 0, 0, 0, 0, 0, 0 }
+ { "help", 'h', POPT_ARG_NONE, nullptr, OPT_HELP, nullptr, nullptr },
+ { "session", 's', POPT_ARG_STRING, &opt_session_name, 0, nullptr, nullptr },
+ { "ctrl-url", 'C', POPT_ARG_STRING, &opt_ctrl_url, 0, nullptr, nullptr },
+ { "data-url", 'D', POPT_ARG_STRING, &opt_data_url, 0, nullptr, nullptr },
+ { "name", 'n', POPT_ARG_STRING, &opt_output_name, 0, nullptr, nullptr },
+ { "max-size", 'm', POPT_ARG_STRING, nullptr, OPT_MAX_SIZE, nullptr, nullptr },
+ { "list-options", 0, POPT_ARG_NONE, nullptr, OPT_LIST_OPTIONS, nullptr, nullptr },
+ { "list-commands", 0, POPT_ARG_NONE, nullptr, OPT_LIST_COMMANDS, nullptr, nullptr },
+ { nullptr, 0, 0, nullptr, 0, nullptr, nullptr }
};
static struct cmd_struct actions[] = {
{ "del-output", cmd_del_output },
{ "list-output", cmd_list_output },
{ "record", cmd_record },
- { NULL, NULL } /* Array closure */
+ { nullptr, nullptr } /* Array closure */
};
/*
LTTNG_ASSERT(argv);
- while (argv[i] != NULL) {
+ while (argv[i] != nullptr) {
i++;
}
static struct lttng_snapshot_output *create_output_from_args(const char *url)
{
int ret = 0;
- struct lttng_snapshot_output *output = NULL;
+ struct lttng_snapshot_output *output = nullptr;
output = lttng_snapshot_output_create();
if (!output) {
error:
lttng_snapshot_output_destroy(output);
error_create:
- return NULL;
+ return nullptr;
}
-static int list_output(void)
+static int list_output()
{
int ret, output_seen = 0;
struct lttng_snapshot_output *s_iter;
}
}
- while ((s_iter = lttng_snapshot_output_list_get_next(list)) != NULL) {
+ while ((s_iter = lttng_snapshot_output_list_get_next(list)) != nullptr) {
if (lttng_snapshot_output_get_maxsize(s_iter)) {
MSG("%s[%" PRIu32 "] %s: %s (max size: %" PRIu64 " bytes)",
indent4,
static int del_output(uint32_t id, const char *name)
{
int ret;
- struct lttng_snapshot_output *output = NULL;
+ struct lttng_snapshot_output *output = nullptr;
output = lttng_snapshot_output_create();
if (!output) {
static int add_output(const char *url)
{
int ret;
- struct lttng_snapshot_output *output = NULL;
+ struct lttng_snapshot_output *output = nullptr;
char name[NAME_MAX];
const char *n_ptr;
if (id == 0 && (errno == 0 || errno == EINVAL)) {
ret = del_output(UINT32_MAX, name);
} else if (errno == 0 && *name == '\0') {
- ret = del_output(id, NULL);
+ ret = del_output(id, nullptr);
} else {
ERR("Argument %s not recognized", argv[1]);
ret = -1;
static int record(const char *url)
{
int ret;
- struct lttng_snapshot_output *output = NULL;
+ struct lttng_snapshot_output *output = nullptr;
output = create_output_from_args(url);
if (!output) {
if (argc == 2) {
ret = record(argv[1]);
} else {
- ret = record(NULL);
+ ret = record(nullptr);
}
return ret;
LTTNG_ASSERT(argc > 0);
cmd = &actions[i];
- while (cmd->func != NULL) {
+ while (cmd->func != nullptr) {
/* Find command */
if (strcmp(argv[0], cmd->name) == 0) {
int result;
int opt;
int mi_ret;
enum cmd_error_code cmd_ret = CMD_SUCCESS;
- char *session_name = NULL;
+ char *session_name = nullptr;
static poptContext pc;
- pc = poptGetContext(NULL, argc, argv, snapshot_opts, 0);
+ pc = poptGetContext(nullptr, argc, argv, snapshot_opts, 0);
poptReadDefaultConfig(pc, 0);
/* Mi check */
if (!opt_session_name) {
session_name = get_session_name();
- if (session_name == NULL) {
+ if (session_name == nullptr) {
cmd_ret = CMD_ERROR;
goto end;
}
static struct poptOption long_options[] = {
/* longName, shortName, argInfo, argPtr, value, descrip, argDesc */
- { "help", 'h', POPT_ARG_NONE, 0, OPT_HELP, 0, 0 },
- { "list-options", 0, POPT_ARG_NONE, NULL, OPT_LIST_OPTIONS, NULL, NULL },
- { 0, 0, 0, 0, 0, 0, 0 }
+ { "help", 'h', POPT_ARG_NONE, nullptr, OPT_HELP, nullptr, nullptr },
+ { "list-options", 0, POPT_ARG_NONE, nullptr, OPT_LIST_OPTIONS, nullptr, nullptr },
+ { nullptr, 0, 0, nullptr, 0, nullptr, nullptr }
};
static int mi_print_session(char *session_name, int enabled)
int ret;
char *session_name;
- if (arg_session_name == NULL) {
+ if (arg_session_name == nullptr) {
session_name = get_session_name();
} else {
session_name = strdup(arg_session_name);
- if (session_name == NULL) {
+ if (session_name == nullptr) {
PERROR("Failed to copy session name");
}
}
- if (session_name == NULL) {
+ if (session_name == nullptr) {
ret = CMD_ERROR;
goto error;
}
{
int opt, ret = CMD_SUCCESS, command_ret = CMD_SUCCESS, success = 1;
static poptContext pc;
- const char *arg_session_name = NULL;
- const char *leftover = NULL;
+ const char *arg_session_name = nullptr;
+ const char *leftover = nullptr;
- pc = poptGetContext(NULL, argc, argv, long_options, 0);
+ pc = poptGetContext(nullptr, argc, argv, long_options, 0);
poptReadDefaultConfig(pc, 0);
while ((opt = poptGetNextOpt(pc)) != -1) {
static struct poptOption long_options[] = {
/* longName, shortName, argInfo, argPtr, value, descrip, argDesc */
- { "help", 'h', POPT_ARG_NONE, NULL, OPT_HELP, NULL, NULL },
- { "list-options", 0, POPT_ARG_NONE, NULL, OPT_LIST_OPTIONS, NULL, NULL },
- { 0, 0, 0, 0, 0, 0, 0 }
+ { "help", 'h', POPT_ARG_NONE, nullptr, OPT_HELP, nullptr, nullptr },
+ { "list-options", 0, POPT_ARG_NONE, nullptr, OPT_LIST_OPTIONS, nullptr, nullptr },
+ { nullptr, 0, 0, nullptr, 0, nullptr, nullptr }
};
-static int status(void)
+static int status()
{
const char *argv[2];
int ret = CMD_SUCCESS;
- char *session_name = NULL;
+ char *session_name = nullptr;
session_name = get_session_name();
if (!session_name) {
int opt, ret = CMD_SUCCESS;
static poptContext pc;
- pc = poptGetContext(NULL, argc, argv, long_options, 0);
+ pc = poptGetContext(nullptr, argc, argv, long_options, 0);
poptReadDefaultConfig(pc, 0);
while ((opt = poptGetNextOpt(pc)) != -1) {
}
}
- if (poptPeekArg(pc) != NULL) {
+ if (poptPeekArg(pc) != nullptr) {
ERR("This command does not accept positional arguments.\n");
ret = CMD_UNDEFINED;
goto end;
static struct poptOption long_options[] = {
/* longName, shortName, argInfo, argPtr, value, descrip, argDesc */
- { "help", 'h', POPT_ARG_NONE, 0, OPT_HELP, 0, 0 },
- { "list-options", 0, POPT_ARG_NONE, NULL, OPT_LIST_OPTIONS, NULL, NULL },
- { "no-wait", 'n', POPT_ARG_VAL, &opt_no_wait, 1, 0, 0 },
- { 0, 0, 0, 0, 0, 0, 0 }
+ { "help", 'h', POPT_ARG_NONE, nullptr, OPT_HELP, nullptr, nullptr },
+ { "list-options", 0, POPT_ARG_NONE, nullptr, OPT_LIST_OPTIONS, nullptr, nullptr },
+ { "no-wait", 'n', POPT_ARG_VAL, &opt_no_wait, 1, nullptr, nullptr },
+ { nullptr, 0, 0, nullptr, 0, nullptr, nullptr }
};
/*
int ret;
char *session_name;
- if (arg_session_name == NULL) {
+ if (arg_session_name == nullptr) {
session_name = get_session_name();
} else {
session_name = strdup(arg_session_name);
- if (session_name == NULL) {
+ if (session_name == nullptr) {
PERROR("Failed to copy session name");
}
}
- if (session_name == NULL) {
+ if (session_name == nullptr) {
ret = CMD_ERROR;
goto error;
}
{
int opt, ret = CMD_SUCCESS, command_ret = CMD_SUCCESS, success = 1;
static poptContext pc;
- const char *arg_session_name = NULL;
- const char *leftover = NULL;
+ const char *arg_session_name = nullptr;
+ const char *leftover = nullptr;
- pc = poptGetContext(NULL, argc, argv, long_options, 0);
+ pc = poptGetContext(nullptr, argc, argv, long_options, 0);
poptReadDefaultConfig(pc, 0);
while ((opt = poptGetNextOpt(pc)) != -1) {
"help",
'h',
POPT_ARG_NONE,
- 0,
+ nullptr,
OPT_HELP,
- 0,
- 0,
+ nullptr,
+ nullptr,
},
{
"session",
POPT_ARG_STRING,
&opt_session_name,
OPT_SESSION,
- 0,
- 0,
+ nullptr,
+ nullptr,
},
{
"kernel",
POPT_ARG_VAL,
&opt_kernel,
1,
- 0,
- 0,
+ nullptr,
+ nullptr,
},
{
"userspace",
POPT_ARG_VAL,
&opt_userspace,
1,
- 0,
- 0,
+ nullptr,
+ nullptr,
},
{
"pid",
POPT_ARG_STRING | POPT_ARGFLAG_OPTIONAL,
&opt_str_arg,
OPT_PID,
- 0,
- 0,
+ nullptr,
+ nullptr,
},
{
"vpid",
POPT_ARG_STRING | POPT_ARGFLAG_OPTIONAL,
&opt_str_arg,
OPT_VPID,
- 0,
- 0,
+ nullptr,
+ nullptr,
},
{
"uid",
POPT_ARG_STRING | POPT_ARGFLAG_OPTIONAL,
&opt_str_arg,
OPT_UID,
- 0,
- 0,
+ nullptr,
+ nullptr,
},
{
"vuid",
POPT_ARG_STRING | POPT_ARGFLAG_OPTIONAL,
&opt_str_arg,
OPT_VUID,
- 0,
- 0,
+ nullptr,
+ nullptr,
},
{
"gid",
POPT_ARG_STRING | POPT_ARGFLAG_OPTIONAL,
&opt_str_arg,
OPT_GID,
- 0,
- 0,
+ nullptr,
+ nullptr,
},
{
"vgid",
POPT_ARG_STRING | POPT_ARGFLAG_OPTIONAL,
&opt_str_arg,
OPT_VGID,
- 0,
- 0,
+ nullptr,
+ nullptr,
},
{
"all",
'a',
POPT_ARG_NONE,
- 0,
+ nullptr,
OPT_ALL,
- 0,
- 0,
+ nullptr,
+ nullptr,
},
{
"list-options",
0,
POPT_ARG_NONE,
- NULL,
+ nullptr,
OPT_LIST_OPTIONS,
- 0,
- 0,
+ nullptr,
+ nullptr,
},
{
+ nullptr,
0,
0,
+ nullptr,
0,
- 0,
- 0,
- 0,
- 0,
+ nullptr,
+ nullptr,
},
};
default:
return "Unknown";
}
- return NULL;
+ return nullptr;
}
static bool ust_process_attr_supported(enum lttng_process_attr *process_attr)
enum lttng_process_attr process_attr,
struct mi_writer *writer)
{
- struct lttng_process_attr_tracker_handle *tracker_handle = NULL;
+ struct lttng_process_attr_tracker_handle *tracker_handle = nullptr;
const enum lttng_error_code handle_ret_code = lttng_session_get_tracker_handle(
session_name, domain_type, process_attr, &tracker_handle);
enum cmd_error_code cmd_ret = CMD_SUCCESS;
const char *_args,
struct mi_writer *writer)
{
- struct lttng_process_attr_tracker_handle *tracker_handle = NULL;
+ struct lttng_process_attr_tracker_handle *tracker_handle = nullptr;
const enum lttng_error_code handle_ret_code = lttng_session_get_tracker_handle(
session_name, domain_type, process_attr, &tracker_handle);
enum cmd_error_code cmd_ret = CMD_SUCCESS;
goto end;
}
- while ((one_value_str = strtok_r(iter, ",", &iter)) != NULL) {
+ while ((one_value_str = strtok_r(iter, ",", &iter)) != nullptr) {
const bool is_numerical_argument = isdigit(one_value_str[0]);
enum lttng_process_attr_tracker_handle_status status;
enum lttng_tracking_policy policy;
}
if (is_numerical_argument) {
- const unsigned long one_value_int = strtoul(one_value_str, NULL, 10);
+ const unsigned long one_value_int = strtoul(one_value_str, nullptr, 10);
if (writer) {
ret = mi_lttng_integral_process_attribute_value(
sizeof(process_attr_commands) / sizeof(struct process_attr_command_args);
enum cmd_error_code command_ret = CMD_SUCCESS;
static poptContext pc;
- char *session_name = NULL;
- const char *leftover = NULL;
- struct mi_writer *writer = NULL;
+ char *session_name = nullptr;
+ const char *leftover = nullptr;
+ struct mi_writer *writer = nullptr;
size_t i;
for (i = 0; i < command_count; i++) {
goto end;
}
- pc = poptGetContext(NULL, argc, argv, long_options, 0);
+ pc = poptGetContext(nullptr, argc, argv, long_options, 0);
poptReadDefaultConfig(pc, 0);
while ((opt = poptGetNextOpt(pc)) != -1) {
if (!opt_session_name) {
session_name = get_session_name();
- if (session_name == NULL) {
+ if (session_name == nullptr) {
command_ret = CMD_ERROR;
goto end;
}
#ifdef LTTNG_EMBED_HELP
#include <lttng-track.1.h>
#else
- NULL
+ nullptr
#endif
;
#ifdef LTTNG_EMBED_HELP
#include <lttng-untrack.1.h>
#else
- NULL
+ nullptr
#endif
;
static struct poptOption long_options[] = {
/* longName, shortName, argInfo, argPtr, value, descrip, argDesc */
- { "help", 'h', POPT_ARG_NONE, 0, OPT_HELP, 0, 0 },
- { "list-options", 0, POPT_ARG_NONE, NULL, OPT_LIST_OPTIONS, NULL, NULL },
- { 0, 0, 0, 0, 0, 0, 0 }
+ { "help", 'h', POPT_ARG_NONE, nullptr, OPT_HELP, nullptr, nullptr },
+ { "list-options", 0, POPT_ARG_NONE, nullptr, OPT_LIST_OPTIONS, nullptr, nullptr },
+ { nullptr, 0, 0, nullptr, 0, nullptr, nullptr }
};
/*
/*
* Print the machine interface output of this command.
*/
-static int print_mi(void)
+static int print_mi()
{
int ret = CMD_SUCCESS;
- struct mi_writer *writer = NULL;
+ struct mi_writer *writer = nullptr;
struct mi_lttng_version_data version;
create_version(&version);
int opt, ret = CMD_SUCCESS;
static poptContext pc;
- pc = poptGetContext(NULL, argc, argv, long_options, 0);
+ pc = poptGetContext(nullptr, argc, argv, long_options, 0);
poptReadDefaultConfig(pc, 0);
while ((opt = poptGetNextOpt(pc)) != -1) {
static struct poptOption long_options[] = {
/* longName, shortName, argInfo, argPtr, value, descrip, argDesc */
- { "help", 'h', POPT_ARG_NONE, 0, OPT_HELP, 0, 0 },
- { "list-options", 0, POPT_ARG_NONE, NULL, OPT_LIST_OPTIONS, NULL, NULL },
- { "viewer", 'e', POPT_ARG_STRING, &opt_viewer, 0, 0, 0 },
- { "trace-path", 't', POPT_ARG_STRING, &opt_trace_path, 0, 0, 0 },
- { 0, 0, 0, 0, 0, 0, 0 }
+ { "help", 'h', POPT_ARG_NONE, nullptr, OPT_HELP, nullptr, nullptr },
+ { "list-options", 0, POPT_ARG_NONE, nullptr, OPT_LIST_OPTIONS, nullptr, nullptr },
+ { "viewer", 'e', POPT_ARG_STRING, &opt_viewer, 0, nullptr, nullptr },
+ { "trace-path", 't', POPT_ARG_STRING, &opt_trace_path, 0, nullptr, nullptr },
+ { nullptr, 0, 0, nullptr, 0, nullptr, nullptr }
};
/* Is the session we are trying to view is in live mode. */
static char *build_live_path(char *session_name)
{
int ret;
- char *path = NULL;
+ char *path = nullptr;
char hostname[LTTNG_HOST_NAME_MAX];
ret = gethostname(hostname, sizeof(hostname));
static int view_trace(const char *arg_session_name)
{
int ret;
- char *session_name, *trace_path = NULL;
- struct lttng_session *sessions = NULL;
+ char *session_name, *trace_path = nullptr;
+ struct lttng_session *sessions = nullptr;
bool free_trace_path = false;
/*
/* User define trace path override the session name */
if (opt_trace_path) {
- session_name = NULL;
+ session_name = nullptr;
} else {
- if (arg_session_name == NULL) {
+ if (arg_session_name == nullptr) {
session_name = get_session_name();
} else {
session_name = strdup(arg_session_name);
- if (session_name == NULL) {
+ if (session_name == nullptr) {
PERROR("Failed to copy session name");
}
}
- if (session_name == NULL) {
+ if (session_name == nullptr) {
ret = CMD_ERROR;
goto error;
}
{
int opt, ret = CMD_SUCCESS;
static poptContext pc;
- const char *arg_session_name = NULL;
- const char *leftover = NULL;
+ const char *arg_session_name = nullptr;
+ const char *leftover = nullptr;
- pc = poptGetContext(NULL, argc, argv, long_options, 0);
+ pc = poptGetContext(nullptr, argc, argv, long_options, 0);
poptReadDefaultConfig(pc, 0);
if (lttng_opt_mi) {
ret = asprintf(&file_path, "%s/%s", path, CONFIG_FILENAME);
if (ret < 0) {
ERR("Fail allocating config file path");
- file_path = NULL;
+ file_path = nullptr;
}
return file_path;
*/
static FILE *open_config(const char *path, const char *mode)
{
- FILE *fp = NULL;
+ FILE *fp = nullptr;
char *file_path;
file_path = config_get_file_path(path);
- if (file_path == NULL) {
+ if (file_path == nullptr) {
goto error;
}
fp = fopen(file_path, mode);
- if (fp == NULL) {
+ if (fp == nullptr) {
goto error;
}
FILE *fp;
fp = open_config(path, "w+");
- if (fp == NULL) {
+ if (fp == nullptr) {
ERR("Unable to create config file");
ret = -1;
goto error;
int ret = 0;
fp = open_config(file_path, "a");
- if (fp == NULL) {
+ if (fp == nullptr) {
ret = -1;
goto end;
}
char *config_path;
config_path = config_get_file_path(path);
- if (config_path == NULL) {
+ if (config_path == nullptr) {
return;
}
/*
* Destroys the default config
*/
-void config_destroy_default(void)
+void config_destroy_default()
{
const char *path = utils_get_home_dir();
- if (path == NULL) {
+ if (path == nullptr) {
return;
}
config_destroy(path);
#endif
session_name = calloc<char>(NAME_MAX);
- if (session_name == NULL) {
+ if (session_name == nullptr) {
ret = -ENOMEM;
ERR("Out of memory");
goto error;
}
fp = open_config(path, "r");
- if (fp == NULL) {
+ if (fp == nullptr) {
ret = -ENOENT;
goto error;
}
char *config_read_session_name(const char *path)
{
int ret;
- char *name = NULL;
+ char *name = nullptr;
ret = _config_read_session_name(path, &name);
if (ret == -ENOENT) {
*/
char *config_read_session_name_quiet(const char *path)
{
- char *name = NULL;
+ char *name = nullptr;
(void) _config_read_session_name(path, &name);
return name;
const char *path;
path = utils_get_home_dir();
- if (path == NULL) {
+ if (path == nullptr) {
ret = -1;
goto error;
}
lookup_name_from_value(const struct loglevel_name_value values[], size_t values_count, int loglevel)
{
size_t i;
- const char *name = NULL;
+ const char *name = nullptr;
for (i = 0; i < values_count; i++) {
if (values[i].value == loglevel) {
#ifdef LTTNG_EMBED_HELP
#include <lttng.1.h>
#else
- NULL
+ nullptr
#endif
;
};
/* Getopt options. No first level command. */
-static struct option long_options[] = { { "version", 0, NULL, 'V' },
- { "help", 0, NULL, 'h' },
- { "group", 1, NULL, 'g' },
- { "verbose", 0, NULL, 'v' },
- { "quiet", 0, NULL, 'q' },
- { "mi", 1, NULL, 'm' },
- { "no-sessiond", 0, NULL, 'n' },
- { "sessiond-path", 1, NULL, OPT_SESSION_PATH },
- { "relayd-path", 1, NULL, OPT_RELAYD_PATH },
- { "list-options", 0, NULL, OPT_DUMP_OPTIONS },
- { "list-commands", 0, NULL, OPT_DUMP_COMMANDS },
- { NULL, 0, NULL, 0 } };
+static struct option long_options[] = { { "version", 0, nullptr, 'V' },
+ { "help", 0, nullptr, 'h' },
+ { "group", 1, nullptr, 'g' },
+ { "verbose", 0, nullptr, 'v' },
+ { "quiet", 0, nullptr, 'q' },
+ { "mi", 1, nullptr, 'm' },
+ { "no-sessiond", 0, nullptr, 'n' },
+ { "sessiond-path", 1, nullptr, OPT_SESSION_PATH },
+ { "relayd-path", 1, nullptr, OPT_RELAYD_PATH },
+ { "list-options", 0, nullptr, OPT_DUMP_OPTIONS },
+ { "list-commands", 0, nullptr, OPT_DUMP_COMMANDS },
+ { nullptr, 0, nullptr, 0 } };
/* First level command */
static struct cmd_struct commands[] = {
{ "disable-event", cmd_disable_events },
{ "enable-channel", cmd_enable_channels },
{ "enable-event", cmd_enable_events },
- { "help", NULL },
+ { "help", nullptr },
{ "list", cmd_list },
{ "list-triggers", cmd_list_triggers },
{ "load", cmd_load },
{ "untrack", cmd_untrack },
{ "version", cmd_version },
{ "view", cmd_view },
- { NULL, NULL } /* Array closure */
+ { nullptr, nullptr } /* Array closure */
};
static void version(FILE *ofp)
static void list_options(FILE *ofp)
{
int i = 0;
- struct option *option = NULL;
+ struct option *option = nullptr;
option = &long_options[i];
- while (option->name != NULL) {
+ while (option->name != nullptr) {
fprintf(ofp, "--%s\n", option->name);
if (isprint(option->val)) {
*
* Setup signal handler for SIGCHLD and SIGTERM.
*/
-static int set_signal_handler(void)
+static int set_signal_handler()
{
int ret = 0;
struct sigaction sa;
sa.sa_mask = sigset;
sa.sa_flags = 0;
- if ((ret = sigaction(SIGTERM, &sa, NULL)) < 0) {
+ if ((ret = sigaction(SIGTERM, &sa, nullptr)) < 0) {
PERROR("sigaction");
goto end;
}
int i = 0, ret;
struct cmd_struct *cmd;
- if (*argv == NULL) {
+ if (*argv == nullptr) {
ret = CMD_SUCCESS;
goto end;
}
}
cmd = &commands[i];
- while (cmd->name != NULL) {
+ while (cmd->name != nullptr) {
/* Find command */
if (strcmp(argv[0], cmd->name) == 0) {
ret = cmd->func(argc, (const char **) argv);
const struct cmd_struct *cmd = commands;
bool exists = false;
- while (cmd->name != NULL) {
+ while (cmd->name != nullptr) {
if (!strcmp(command, cmd->name)) {
exists = true;
goto end;
return exists;
}
-static void show_basic_help(void)
+static void show_basic_help()
{
puts("Usage: lttng [--group=GROUP] [--mi=TYPE] [--no-sessiond | --sessiond-path=PATH]");
puts(" [--quiet | -v | -vv | -vvv] COMMAND [COMMAND OPTIONS]");
clean_exit(EXIT_FAILURE);
}
- while ((opt = getopt_long(argc, argv, "+Vhnvqg:m:", long_options, NULL)) != -1) {
+ while ((opt = getopt_long(argc, argv, "+Vhnvqg:m:", long_options, nullptr)) != -1) {
switch (opt) {
case 'V':
version(stdout);
*/
static int walk_command_search_path(const char *binary, char *binary_full_path)
{
- char *tentative_binary_path = NULL;
- char *command_search_path = NULL;
- char *curr_search_dir_end = NULL;
- char *curr_search_dir = NULL;
+ char *tentative_binary_path = nullptr;
+ char *command_search_path = nullptr;
+ char *curr_search_dir_end = nullptr;
+ char *curr_search_dir = nullptr;
struct stat stat_output;
int ret = 0;
* matching character.
*/
curr_search_dir_end = strchr(curr_search_dir, ':');
- if (curr_search_dir_end != NULL) {
+ if (curr_search_dir_end != nullptr) {
/*
* Add a NULL byte to the end of the first token so it
* can be used as a string.
}
/* Go to the next entry in the $PATH variable. */
curr_search_dir = curr_search_dir_end + 1;
- } while (curr_search_dir_end != NULL);
+ } while (curr_search_dir_end != nullptr);
free_binary_path:
free(tentative_binary_path);
{
int ret = CMD_SUCCESS;
size_t num_token = 0;
- char *target_path = NULL;
- char *unescaped_target_path = NULL;
- char *real_target_path = NULL;
- char *symbol_name = NULL, *probe_name = NULL, *provider_name = NULL;
- struct lttng_userspace_probe_location *probe_location_local = NULL;
- struct lttng_userspace_probe_location_lookup_method *lookup_method = NULL;
+ char *target_path = nullptr;
+ char *unescaped_target_path = nullptr;
+ char *real_target_path = nullptr;
+ char *symbol_name = nullptr, *probe_name = nullptr, *provider_name = nullptr;
+ struct lttng_userspace_probe_location *probe_location_local = nullptr;
+ struct lttng_userspace_probe_location_lookup_method *lookup_method = nullptr;
struct lttng_dynamic_pointer_array tokens;
LTTNG_ASSERT(opt);
* If there is not forward slash in the path. Walk the $PATH else
* expand.
*/
- if (strchr(unescaped_target_path, '/') == NULL) {
+ if (strchr(unescaped_target_path, '/') == nullptr) {
/* Walk the $PATH variable to find the targeted binary. */
real_target_path = calloc<char>(LTTNG_PATH_MAX);
if (!real_target_path) {
}
/* Ownership transferred to probe_location. */
- lookup_method = NULL;
+ lookup_method = nullptr;
break;
case LTTNG_USERSPACE_PROBE_LOCATION_LOOKUP_METHOD_TYPE_TRACEPOINT_SDT:
probe_location_local = lttng_userspace_probe_location_tracepoint_create(
}
/* Ownership transferred to probe_location. */
- lookup_method = NULL;
+ lookup_method = nullptr;
break;
default:
ret = CMD_ERROR;
* caller.
*/
*probe_location = probe_location_local;
- probe_location_local = NULL;
+ probe_location_local = nullptr;
end:
lttng_userspace_probe_location_destroy(probe_location_local);
static char *_get_session_name(int quiet)
{
const char *path;
- char *session_name = NULL;
+ char *session_name = nullptr;
/* Get path to config file */
path = utils_get_home_dir();
- if (path == NULL) {
+ if (path == nullptr) {
goto error;
}
/* Get session name from config */
session_name = quiet ? config_read_session_name_quiet(path) :
config_read_session_name(path);
- if (session_name == NULL) {
+ if (session_name == nullptr) {
goto error;
}
return session_name;
error:
- return NULL;
+ return nullptr;
}
/*
* Return allocated string with the session name found in the config
* directory.
*/
-char *get_session_name(void)
+char *get_session_name()
{
return _get_session_name(0);
}
* Return allocated string with the session name found in the config
* directory.
*/
-char *get_session_name_quiet(void)
+char *get_session_name_quiet()
{
return _get_session_name(1);
}
void list_commands(struct cmd_struct *commands, FILE *ofp)
{
int i = 0;
- struct cmd_struct *cmd = NULL;
+ struct cmd_struct *cmd = nullptr;
cmd = &commands[i];
- while (cmd->name != NULL) {
+ while (cmd->name != nullptr) {
fprintf(ofp, "%s\n", cmd->name);
i++;
cmd = &commands[i];
void list_cmd_options(FILE *ofp, struct poptOption *options)
{
int i;
- struct poptOption *option = NULL;
+ struct poptOption *option = nullptr;
- for (i = 0; options[i].longName != NULL; i++) {
+ for (i = 0; options[i].longName != nullptr; i++) {
option = &options[i];
fprintf(ofp, "--%s\n", option->longName);
{
int i;
- for (i = 0; options[i].long_name != NULL; i++) {
+ for (i = 0; options[i].long_name != nullptr; i++) {
const struct argpar_opt_descr *option = &options[i];
fprintf(ofp, "--%s\n", option->long_name);
*
* Return 1 if found else 0 if NOT found. Negative value on error.
*/
-int check_relayd(void)
+int check_relayd()
{
int ret, fd;
struct sockaddr_in sin;
int get_session_stats_str(const char *session_name, char **out_str)
{
int count, nb_domains, domain_idx, channel_idx, session_idx, ret;
- struct lttng_domain *domains = NULL;
- struct lttng_channel *channels = NULL;
+ struct lttng_domain *domains = nullptr;
+ struct lttng_channel *channels = nullptr;
uint64_t discarded_events_total = 0, lost_packets_total = 0;
- struct lttng_session *sessions = NULL;
- const struct lttng_session *selected_session = NULL;
- char *stats_str = NULL;
+ struct lttng_session *sessions = nullptr;
+ const struct lttng_session *selected_session = nullptr;
+ char *stats_str = nullptr;
bool print_discarded_events = false, print_lost_packets = false;
count = lttng_list_sessions(&sessions);
}
free(channels);
- channels = NULL;
+ channels = nullptr;
count = lttng_list_channels(handle, &channels);
for (channel_idx = 0; channel_idx < count; channel_idx++) {
uint64_t discarded_events = 0, lost_packets = 0;
bool lttng_action_should_execute(const struct lttng_action *action)
{
- const struct lttng_rate_policy *policy = NULL;
+ const struct lttng_rate_policy *policy = nullptr;
bool execute = false;
- if (action->get_rate_policy == NULL) {
+ if (action->get_rate_policy == nullptr) {
execute = true;
goto end;
}
policy = action->get_rate_policy(action);
- if (policy == NULL) {
+ if (policy == nullptr) {
execute = true;
goto end;
}
struct lttng_error_query_results *results)
{
enum lttng_action_status action_status;
- struct lttng_error_query_result *error_counter = NULL;
+ struct lttng_error_query_result *error_counter = nullptr;
const uint64_t execution_failure_counter = uatomic_read(&action->execution_failure_counter);
error_counter = lttng_error_query_result_counter_create(
}
/* Ownership transferred to the results. */
- error_counter = NULL;
+ error_counter = nullptr;
action_status = LTTNG_ACTION_STATUS_OK;
end:
lttng_error_query_result_destroy(error_counter);
{
int ret;
enum lttng_error_code ret_code;
- struct lttng_action_path *action_path = NULL;
- struct lttng_error_query_results *error_query_results = NULL;
+ struct lttng_action_path *action_path = nullptr;
+ struct lttng_error_query_results *error_query_results = nullptr;
LTTNG_ASSERT(action);
LTTNG_ASSERT(writer);
/* Error query for the action. */
if (error_query_callbacks && error_query_callbacks->action_cb) {
- const uint64_t *action_path_indexes_raw_pointer = NULL;
+ const uint64_t *action_path_indexes_raw_pointer = nullptr;
const size_t action_path_indexes_size =
lttng_dynamic_array_get_count(action_path_indexes);
ssize_t consumed_len;
const struct lttng_action_list_comm *comm;
struct lttng_action *list;
- struct lttng_action *child_action = NULL;
+ struct lttng_action *child_action = nullptr;
enum lttng_action_status status;
size_t i;
/* Transfer ownership to the action list. */
lttng_action_put(child_action);
- child_action = NULL;
+ child_action = nullptr;
consumed_len += consumed_len_child;
}
*p_action = list;
- list = NULL;
+ list = nullptr;
end:
lttng_action_list_destroy(list);
action_list = zmalloc<lttng_action_list>();
if (!action_list) {
- action = NULL;
+ action = nullptr;
goto end;
}
lttng_action_list_serialize,
lttng_action_list_is_equal,
lttng_action_list_destroy,
- NULL,
+ nullptr,
lttng_action_list_add_error_query_results,
- NULL);
+ nullptr);
lttng_dynamic_pointer_array_init(&action_list->actions, destroy_lttng_action_list_element);
{
unsigned int count;
const struct lttng_action_list *action_list;
- struct lttng_action *action = NULL;
+ struct lttng_action *action = nullptr;
if (lttng_action_list_get_count(list, &count) != LTTNG_ACTION_STATUS_OK) {
goto end;
int ret;
enum lttng_action_status status;
enum lttng_error_code ret_code;
- const struct lttng_rate_policy *policy = NULL;
+ const struct lttng_rate_policy *policy = nullptr;
LTTNG_ASSERT(action);
LTTNG_ASSERT(IS_NOTIFY_ACTION(action));
status = lttng_action_notify_get_rate_policy(action, &policy);
LTTNG_ASSERT(status == LTTNG_ACTION_STATUS_OK);
- LTTNG_ASSERT(policy != NULL);
+ LTTNG_ASSERT(policy != nullptr);
/* Open action notify. */
ret = mi_lttng_writer_open_element(writer, mi_lttng_element_action_notify);
struct lttng_action *lttng_action_notify_create(void)
{
- struct lttng_rate_policy *policy = NULL;
- struct lttng_action_notify *notify = NULL;
- struct lttng_action *action = NULL;
+ struct lttng_rate_policy *policy = nullptr;
+ struct lttng_action_notify *notify = nullptr;
+ struct lttng_action *action = nullptr;
notify = zmalloc<lttng_action_notify>();
if (!notify) {
lttng_action_init(¬ify->parent,
LTTNG_ACTION_TYPE_NOTIFY,
- NULL,
+ nullptr,
lttng_action_notify_serialize,
lttng_action_notify_is_equal,
lttng_action_notify_destroy,
lttng_action_notify_mi_serialize);
notify->policy = policy;
- policy = NULL;
+ policy = nullptr;
action = ¬ify->parent;
- notify = NULL;
+ notify = nullptr;
end:
free(notify);
{
enum lttng_action_status status;
ssize_t consumed_length;
- struct lttng_rate_policy *rate_policy = NULL;
- struct lttng_action *_action = NULL;
+ struct lttng_rate_policy *rate_policy = nullptr;
+ struct lttng_action *_action = nullptr;
consumed_length = lttng_rate_policy_create_from_payload(view, &rate_policy);
if (!rate_policy) {
}
*action = _action;
- _action = NULL;
+ _action = nullptr;
end:
lttng_rate_policy_destroy(rate_policy);
{
enum lttng_action_status status;
struct lttng_action_notify *notify_action;
- struct lttng_rate_policy *copy = NULL;
+ struct lttng_rate_policy *copy = nullptr;
if (!action || !policy || !IS_NOTIFY_ACTION(action)) {
status = LTTNG_ACTION_STATUS_INVALID;
/* Assign the policy. */
notify_action->policy = copy;
status = LTTNG_ACTION_STATUS_OK;
- copy = NULL;
+ copy = nullptr;
end:
lttng_rate_policy_destroy(copy);
{
int ret;
size_t i;
- struct lttng_action_path *path = NULL;
+ struct lttng_action_path *path = nullptr;
if (!indexes && index_count > 0) {
goto error;
goto error;
}
- lttng_dynamic_array_init(&path->indexes, sizeof(uint64_t), NULL);
+ lttng_dynamic_array_init(&path->indexes, sizeof(uint64_t), nullptr);
for (i = 0; i < index_count; i++) {
ret = lttng_dynamic_array_add_element(&path->indexes, &indexes[i]);
goto end;
error:
lttng_action_path_destroy(path);
- path = NULL;
+ path = nullptr;
end:
return path;
}
{
ssize_t consumed_size = 0, ret = -1;
const struct lttng_action_path_comm *header;
- struct lttng_action_path *action_path = NULL;
+ struct lttng_action_path *action_path = nullptr;
const struct lttng_payload_view header_view =
lttng_payload_view_from_view(view, 0, sizeof(*header));
goto end;
}
} else {
- action_path = lttng_action_path_create(NULL, 0);
+ action_path = lttng_action_path_create(nullptr, 0);
if (!action_path) {
goto end;
}
struct lttng_rate_policy **rate_policy)
{
ssize_t consumed_len = -1;
- struct lttng_rate_policy *policy = NULL;
+ struct lttng_rate_policy *policy = nullptr;
const struct lttng_rate_policy_once_after_n_comm *comm;
const struct lttng_payload_view comm_view =
lttng_payload_view_from_view(view, 0, sizeof(*comm));
comm = (const struct lttng_rate_policy_once_after_n_comm *) comm_view.buffer.data;
policy = lttng_rate_policy_once_after_n_create(comm->threshold);
- if (policy == NULL) {
+ if (policy == nullptr) {
consumed_len = -1;
goto end;
}
struct lttng_rate_policy **rate_policy)
{
ssize_t consumed_len = -1;
- struct lttng_rate_policy *policy = NULL;
+ struct lttng_rate_policy *policy = nullptr;
const struct lttng_rate_policy_every_n_comm *comm;
const struct lttng_payload_view comm_view =
lttng_payload_view_from_view(view, 0, sizeof(*comm));
comm = (const struct lttng_rate_policy_every_n_comm *) comm_view.buffer.data;
policy = lttng_rate_policy_every_n_create(comm->interval);
- if (policy == NULL) {
+ if (policy == nullptr) {
consumed_len = -1;
goto end;
}
static struct lttng_rate_policy *
lttng_rate_policy_every_n_copy(const struct lttng_rate_policy *source)
{
- struct lttng_rate_policy *copy = NULL;
+ struct lttng_rate_policy *copy = nullptr;
const struct lttng_rate_policy_every_n *every_n_policy;
if (!source) {
{
int ret;
enum lttng_error_code ret_code;
- const struct lttng_rate_policy_every_n *every_n_policy = NULL;
+ const struct lttng_rate_policy_every_n *every_n_policy = nullptr;
LTTNG_ASSERT(rate_policy);
LTTNG_ASSERT(IS_EVERY_N_RATE_POLICY(rate_policy));
struct lttng_rate_policy *lttng_rate_policy_every_n_create(uint64_t interval)
{
- struct lttng_rate_policy_every_n *policy = NULL;
- struct lttng_rate_policy *_policy = NULL;
+ struct lttng_rate_policy_every_n *policy = nullptr;
+ struct lttng_rate_policy *_policy = nullptr;
if (interval == 0) {
/*
policy->interval = interval;
_policy = &policy->parent;
- policy = NULL;
+ policy = nullptr;
end:
free(policy);
static struct lttng_rate_policy *
lttng_rate_policy_once_after_n_copy(const struct lttng_rate_policy *source)
{
- struct lttng_rate_policy *copy = NULL;
+ struct lttng_rate_policy *copy = nullptr;
const struct lttng_rate_policy_once_after_n *once_after_n_policy;
if (!source) {
{
int ret;
enum lttng_error_code ret_code;
- const struct lttng_rate_policy_once_after_n *once_after_n_policy = NULL;
+ const struct lttng_rate_policy_once_after_n *once_after_n_policy = nullptr;
LTTNG_ASSERT(rate_policy);
LTTNG_ASSERT(IS_ONCE_AFTER_N_RATE_POLICY(rate_policy));
struct lttng_rate_policy *lttng_rate_policy_once_after_n_create(uint64_t threshold)
{
- struct lttng_rate_policy_once_after_n *policy = NULL;
- struct lttng_rate_policy *_policy = NULL;
+ struct lttng_rate_policy_once_after_n *policy = nullptr;
+ struct lttng_rate_policy *_policy = nullptr;
if (threshold == 0) {
/* threshold is expected to be > 0 */
policy->threshold = threshold;
_policy = &policy->parent;
- policy = NULL;
+ policy = nullptr;
end:
free(policy);
const char *session_name;
struct lttng_action *action;
enum lttng_action_status status;
- struct lttng_rate_policy *policy = NULL;
+ struct lttng_rate_policy *policy = nullptr;
action = lttng_action_rotate_session_create();
if (!action) {
}
*p_action = action;
- action = NULL;
+ action = nullptr;
end:
lttng_rate_policy_destroy(policy);
int ret;
enum lttng_error_code ret_code;
enum lttng_action_status status;
- const char *session_name = NULL;
- const struct lttng_rate_policy *policy = NULL;
+ const char *session_name = nullptr;
+ const struct lttng_rate_policy *policy = nullptr;
LTTNG_ASSERT(action);
LTTNG_ASSERT(IS_ROTATE_SESSION_ACTION(action));
status = lttng_action_rotate_session_get_session_name(action, &session_name);
LTTNG_ASSERT(status == LTTNG_ACTION_STATUS_OK);
- LTTNG_ASSERT(session_name != NULL);
+ LTTNG_ASSERT(session_name != nullptr);
status = lttng_action_notify_get_rate_policy(action, &policy);
LTTNG_ASSERT(status == LTTNG_ACTION_STATUS_OK);
- LTTNG_ASSERT(policy != NULL);
+ LTTNG_ASSERT(policy != nullptr);
/* Open action rotate session element. */
ret = mi_lttng_writer_open_element(writer, mi_lttng_element_action_rotate_session);
struct lttng_action *lttng_action_rotate_session_create(void)
{
- struct lttng_action_rotate_session *action_rotate = NULL;
- struct lttng_rate_policy *policy = NULL;
+ struct lttng_action_rotate_session *action_rotate = nullptr;
+ struct lttng_rate_policy *policy = nullptr;
enum lttng_action_status status;
/* Create a every N = 1 rate policy. */
status = lttng_action_rotate_session_set_rate_policy(&action_rotate->parent, policy);
if (status != LTTNG_ACTION_STATUS_OK) {
lttng_action_destroy(&action_rotate->parent);
- action_rotate = NULL;
+ action_rotate = nullptr;
goto end;
}
{
enum lttng_action_status status;
struct lttng_action_rotate_session *rotate_session_action;
- struct lttng_rate_policy *copy = NULL;
+ struct lttng_rate_policy *copy = nullptr;
if (!action || !policy || !IS_ROTATE_SESSION_ACTION(action)) {
status = LTTNG_ACTION_STATUS_INVALID;
/* Assign the policy. */
rotate_session_action->policy = copy;
status = LTTNG_ACTION_STATUS_OK;
- copy = NULL;
+ copy = nullptr;
end:
lttng_rate_policy_destroy(copy);
const char *variable_data;
struct lttng_action *action;
enum lttng_action_status status;
- struct lttng_snapshot_output *snapshot_output = NULL;
- struct lttng_rate_policy *policy = NULL;
+ struct lttng_snapshot_output *snapshot_output = nullptr;
+ struct lttng_rate_policy *policy = nullptr;
const struct lttng_action_snapshot_session_comm *comm;
const struct lttng_payload_view snapshot_session_comm_view =
lttng_payload_view_from_view(view, 0, sizeof(*comm));
}
/* Ownership has been transferred to the action. */
- snapshot_output = NULL;
+ snapshot_output = nullptr;
}
variable_data += comm->snapshot_output_len;
consumed_len += comm->rate_policy_len;
*p_action = action;
- action = NULL;
+ action = nullptr;
goto end;
int ret;
enum lttng_error_code ret_code;
enum lttng_action_status status;
- const char *session_name = NULL;
- const struct lttng_snapshot_output *output = NULL;
- const struct lttng_rate_policy *policy = NULL;
+ const char *session_name = nullptr;
+ const struct lttng_snapshot_output *output = nullptr;
+ const struct lttng_rate_policy *policy = nullptr;
LTTNG_ASSERT(action);
LTTNG_ASSERT(IS_SNAPSHOT_SESSION_ACTION(action));
status = lttng_action_snapshot_session_get_session_name(action, &session_name);
LTTNG_ASSERT(status == LTTNG_ACTION_STATUS_OK);
- LTTNG_ASSERT(session_name != NULL);
+ LTTNG_ASSERT(session_name != nullptr);
status = lttng_action_snapshot_session_get_rate_policy(action, &policy);
LTTNG_ASSERT(status == LTTNG_ACTION_STATUS_OK);
- LTTNG_ASSERT(policy != NULL);
+ LTTNG_ASSERT(policy != nullptr);
/* Open action snapshot session element. */
ret = mi_lttng_writer_open_element(writer, mi_lttng_element_action_snapshot_session);
/* Output if any. */
status = lttng_action_snapshot_session_get_output(action, &output);
if (status == LTTNG_ACTION_STATUS_OK) {
- LTTNG_ASSERT(output != NULL);
+ LTTNG_ASSERT(output != nullptr);
ret_code = lttng_snapshot_output_mi_serialize(output, writer);
if (ret_code != LTTNG_OK) {
goto end;
struct lttng_action *lttng_action_snapshot_session_create(void)
{
- struct lttng_action_snapshot_session *action_snapshot = NULL;
- struct lttng_rate_policy *policy = NULL;
+ struct lttng_action_snapshot_session *action_snapshot = nullptr;
+ struct lttng_rate_policy *policy = nullptr;
enum lttng_action_status status;
/* Create a every N = 1 rate policy. */
status = lttng_action_snapshot_session_set_rate_policy(&action_snapshot->parent, policy);
if (status != LTTNG_ACTION_STATUS_OK) {
lttng_action_destroy(&action_snapshot->parent);
- action_snapshot = NULL;
+ action_snapshot = nullptr;
goto end;
}
{
enum lttng_action_status status;
struct lttng_action_snapshot_session *snapshot_session_action;
- struct lttng_rate_policy *copy = NULL;
+ struct lttng_rate_policy *copy = nullptr;
if (!action || !policy || !IS_SNAPSHOT_SESSION_ACTION(action)) {
status = LTTNG_ACTION_STATUS_INVALID;
/* Assign the policy. */
snapshot_session_action->policy = copy;
status = LTTNG_ACTION_STATUS_OK;
- copy = NULL;
+ copy = nullptr;
end:
lttng_rate_policy_destroy(copy);
ssize_t consumed_len, ret;
const struct lttng_action_start_session_comm *comm;
const char *session_name;
- struct lttng_action *action = NULL;
+ struct lttng_action *action = nullptr;
enum lttng_action_status status;
- struct lttng_rate_policy *policy = NULL;
+ struct lttng_rate_policy *policy = nullptr;
comm = (typeof(comm)) view->buffer.data;
session_name = (const char *) &comm->data;
}
*p_action = action;
- action = NULL;
+ action = nullptr;
end:
lttng_rate_policy_destroy(policy);
int ret;
enum lttng_error_code ret_code;
enum lttng_action_status status;
- const char *session_name = NULL;
- const struct lttng_rate_policy *policy = NULL;
+ const char *session_name = nullptr;
+ const struct lttng_rate_policy *policy = nullptr;
LTTNG_ASSERT(action);
LTTNG_ASSERT(IS_START_SESSION_ACTION(action));
status = lttng_action_start_session_get_session_name(action, &session_name);
LTTNG_ASSERT(status == LTTNG_ACTION_STATUS_OK);
- LTTNG_ASSERT(session_name != NULL);
+ LTTNG_ASSERT(session_name != nullptr);
status = lttng_action_start_session_get_rate_policy(action, &policy);
LTTNG_ASSERT(status == LTTNG_ACTION_STATUS_OK);
- LTTNG_ASSERT(policy != NULL);
+ LTTNG_ASSERT(policy != nullptr);
/* Open action start session element. */
ret = mi_lttng_writer_open_element(writer, mi_lttng_element_action_start_session);
struct lttng_action *lttng_action_start_session_create(void)
{
- struct lttng_action_start_session *action_start = NULL;
- struct lttng_rate_policy *policy = NULL;
+ struct lttng_action_start_session *action_start = nullptr;
+ struct lttng_rate_policy *policy = nullptr;
enum lttng_action_status status;
/* Create a every N = 1 rate policy. */
status = lttng_action_start_session_set_rate_policy(&action_start->parent, policy);
if (status != LTTNG_ACTION_STATUS_OK) {
lttng_action_destroy(&action_start->parent);
- action_start = NULL;
+ action_start = nullptr;
goto end;
}
{
enum lttng_action_status status;
struct lttng_action_start_session *start_session_action;
- struct lttng_rate_policy *copy = NULL;
+ struct lttng_rate_policy *copy = nullptr;
if (!action || !policy || !IS_START_SESSION_ACTION(action)) {
status = LTTNG_ACTION_STATUS_INVALID;
/* Assign the policy. */
start_session_action->policy = copy;
status = LTTNG_ACTION_STATUS_OK;
- copy = NULL;
+ copy = nullptr;
end:
lttng_rate_policy_destroy(copy);
ssize_t consumed_len, ret;
const struct lttng_action_stop_session_comm *comm;
const char *session_name;
- struct lttng_action *action = NULL;
+ struct lttng_action *action = nullptr;
enum lttng_action_status status;
- struct lttng_rate_policy *policy = NULL;
+ struct lttng_rate_policy *policy = nullptr;
comm = (typeof(comm)) view->buffer.data;
session_name = (const char *) &comm->data;
}
*p_action = action;
- action = NULL;
+ action = nullptr;
end:
lttng_rate_policy_destroy(policy);
int ret;
enum lttng_error_code ret_code;
enum lttng_action_status status;
- const char *session_name = NULL;
- const struct lttng_rate_policy *policy = NULL;
+ const char *session_name = nullptr;
+ const struct lttng_rate_policy *policy = nullptr;
LTTNG_ASSERT(action);
LTTNG_ASSERT(IS_STOP_SESSION_ACTION(action));
status = lttng_action_stop_session_get_session_name(action, &session_name);
LTTNG_ASSERT(status == LTTNG_ACTION_STATUS_OK);
- LTTNG_ASSERT(session_name != NULL);
+ LTTNG_ASSERT(session_name != nullptr);
status = lttng_action_stop_session_get_rate_policy(action, &policy);
LTTNG_ASSERT(status == LTTNG_ACTION_STATUS_OK);
- LTTNG_ASSERT(policy != NULL);
+ LTTNG_ASSERT(policy != nullptr);
/* Open action stop session. */
ret = mi_lttng_writer_open_element(writer, mi_lttng_element_action_start_session);
struct lttng_action *lttng_action_stop_session_create(void)
{
- struct lttng_action_stop_session *action_stop = NULL;
- struct lttng_rate_policy *policy = NULL;
+ struct lttng_action_stop_session *action_stop = nullptr;
+ struct lttng_rate_policy *policy = nullptr;
enum lttng_action_status status;
/* Create a every N = 1 rate policy. */
status = lttng_action_stop_session_set_rate_policy(&action_stop->parent, policy);
if (status != LTTNG_ACTION_STATUS_OK) {
lttng_action_destroy(&action_stop->parent);
- action_stop = NULL;
+ action_stop = nullptr;
goto end;
}
{
enum lttng_action_status status;
struct lttng_action_stop_session *stop_session_action;
- struct lttng_rate_policy *copy = NULL;
+ struct lttng_rate_policy *copy = nullptr;
if (!action || !policy || !IS_STOP_SESSION_ACTION(action)) {
status = LTTNG_ACTION_STATUS_INVALID;
stop_session_action->policy = copy;
status = LTTNG_ACTION_STATUS_OK;
- copy = NULL;
+ copy = nullptr;
end:
lttng_rate_policy_destroy(copy);
const char *context_fmt,
va_list args)
{
- char *str = NULL;
- char *str_ret = NULL;
+ char *str = nullptr;
+ char *str_ret = nullptr;
int ret;
if (context_fmt) {
* If vasprintf fails, the content of str is undefined,
* and we shouldn't try to free it.
*/
- str = NULL;
+ str = nullptr;
goto end;
}
}
str_ret = str;
- str = NULL;
+ str = nullptr;
end:
free(str);
...)
{
enum argpar_iter_next_status status;
- const struct argpar_error *error = NULL;
+ const struct argpar_error *error = nullptr;
enum parse_next_item_status ret;
ARGPAR_ITEM_DESTROY_AND_RESET(*item);
if (error_out) {
argpar_error_destroy(*error_out);
*error_out = error;
- error = NULL;
+ error = nullptr;
}
argpar_error_destroy(error);
struct lttng_buffer_view
lttng_buffer_view_from_view(const struct lttng_buffer_view *src, size_t offset, ptrdiff_t len)
{
- struct lttng_buffer_view view = { .data = NULL, .size = 0 };
+ struct lttng_buffer_view view = { .data = nullptr, .size = 0 };
LTTNG_ASSERT(src);
struct lttng_buffer_view lttng_buffer_view_from_dynamic_buffer(
const struct lttng_dynamic_buffer *src, size_t offset, ptrdiff_t len)
{
- struct lttng_buffer_view view = { .data = NULL, .size = 0 };
+ struct lttng_buffer_view view = { .data = nullptr, .size = 0 };
LTTNG_ASSERT(src);
/*
* The channel object is NOT populated.
*/
-struct lttng_channel *lttng_channel_create_internal(void)
+struct lttng_channel *lttng_channel_create_internal()
{
struct lttng_channel *local_channel = nullptr, *ret = nullptr;
struct lttng_channel_extended *extended = nullptr;
const struct lttng_directory_handle *ref_handle)
{
int dirfd;
- struct lttng_directory_handle *handle = NULL;
+ struct lttng_directory_handle *handle = nullptr;
if (!path) {
handle = lttng_directory_handle_copy(ref_handle);
if (close(dirfd)) {
PERROR("Failed to close directory file descriptor");
}
- return NULL;
+ return nullptr;
}
struct lttng_directory_handle *lttng_directory_handle_create_from_dirfd(int dirfd)
if (ret) {
PERROR("Failed to fstat directory file descriptor %i", dirfd);
lttng_directory_handle_release(&handle->ref);
- handle = NULL;
+ handle = nullptr;
goto end;
}
} else {
struct lttng_directory_handle *
lttng_directory_handle_copy(const struct lttng_directory_handle *handle)
{
- struct lttng_directory_handle *new_handle = NULL;
+ struct lttng_directory_handle *new_handle = nullptr;
if (handle->dirfd == AT_FDCWD) {
new_handle = lttng_directory_handle_create_from_dirfd(AT_FDCWD);
static DIR *lttng_directory_handle_opendir(const struct lttng_directory_handle *handle,
const char *path)
{
- DIR *dir_stream = NULL;
+ DIR *dir_stream = nullptr;
int fd = openat(handle->dirfd, path, O_RDONLY);
if (fd < 0) {
const char *subdirectory,
mode_t mode)
{
- return lttng_directory_handle_create_subdirectory_as_user(handle, subdirectory, mode, NULL);
+ return lttng_directory_handle_create_subdirectory_as_user(
+ handle, subdirectory, mode, nullptr);
}
int lttng_directory_handle_create_subdirectory_recursive(
const struct lttng_directory_handle *handle, const char *subdirectory_path, mode_t mode)
{
return lttng_directory_handle_create_subdirectory_recursive_as_user(
- handle, subdirectory_path, mode, NULL);
+ handle, subdirectory_path, mode, nullptr);
}
int lttng_directory_handle_open_file_as_user(const struct lttng_directory_handle *handle,
int flags,
mode_t mode)
{
- return lttng_directory_handle_open_file_as_user(handle, filename, flags, mode, NULL);
+ return lttng_directory_handle_open_file_as_user(handle, filename, flags, mode, nullptr);
}
int lttng_directory_handle_unlink_file_as_user(const struct lttng_directory_handle *handle,
int lttng_directory_handle_unlink_file(const struct lttng_directory_handle *handle,
const char *filename)
{
- return lttng_directory_handle_unlink_file_as_user(handle, filename, NULL);
+ return lttng_directory_handle_unlink_file_as_user(handle, filename, nullptr);
}
int lttng_directory_handle_rename(const struct lttng_directory_handle *old_handle,
const char *new_name)
{
return lttng_directory_handle_rename_as_user(
- old_handle, old_name, new_handle, new_name, NULL);
+ old_handle, old_name, new_handle, new_name, nullptr);
}
int lttng_directory_handle_rename_as_user(const struct lttng_directory_handle *old_handle,
int lttng_directory_handle_remove_subdirectory(const struct lttng_directory_handle *handle,
const char *name)
{
- return lttng_directory_handle_remove_subdirectory_as_user(handle, name, NULL);
+ return lttng_directory_handle_remove_subdirectory_as_user(handle, name, nullptr);
}
int lttng_directory_handle_remove_subdirectory_as_user(const struct lttng_directory_handle *handle,
const struct lttng_directory_handle *handle, const char *name, int flags)
{
return lttng_directory_handle_remove_subdirectory_recursive_as_user(
- handle, name, NULL, flags);
+ handle, name, nullptr, flags);
}
int lttng_directory_handle_remove_subdirectory_recursive_as_user(
#include <common/error.hpp>
static inline
-int lttng_is_setuid_setgid(void)
+int lttng_is_setuid_setgid()
{
return geteuid() != getuid() || getegid() != getgid();
}
if (lttng_is_setuid_setgid()) {
WARN("Getting environment variable '%s' from setuid/setgid binary refused for security reasons.",
name);
- return NULL;
+ return nullptr;
}
return getenv(name);
}
LTTNG_ASSERT(events);
ptr = (epoll_event *) realloc(events->events, new_size * sizeof(*ptr));
- if (ptr == NULL) {
+ if (ptr == nullptr) {
PERROR("realloc epoll add");
goto error;
}
{
int ret;
- if (events == NULL || count <= 0) {
+ if (events == nullptr || count <= 0) {
goto error;
}
/* This *must* be freed by using lttng_poll_free() */
events->events = calloc<epoll_event>(count);
- if (events->events == NULL) {
+ if (events->events == nullptr) {
PERROR("zmalloc epoll set");
goto error_close;
}
int ret;
struct epoll_event ev;
- if (events == NULL || events->events == NULL || fd < 0) {
+ if (events == nullptr || events->events == nullptr || fd < 0) {
ERR("Bad compat epoll add arguments");
goto error;
}
{
int ret;
- if (events == NULL || fd < 0 || events->nb_fd == 0) {
+ if (events == nullptr || fd < 0 || events->nb_fd == 0) {
goto error;
}
- ret = epoll_ctl(events->epfd, EPOLL_CTL_DEL, fd, NULL);
+ ret = epoll_ctl(events->epfd, EPOLL_CTL_DEL, fd, nullptr);
if (ret < 0) {
switch (errno) {
case ENOENT:
int ret;
struct epoll_event ev;
- if (events == NULL || fd < 0 || events->nb_fd == 0) {
+ if (events == nullptr || fd < 0 || events->nb_fd == 0) {
goto error;
}
int ret;
uint32_t new_size;
- if (events == NULL || events->events == NULL) {
+ if (events == nullptr || events->events == nullptr) {
ERR("Wrong arguments in compat_epoll_wait");
goto error;
}
/*
* Setup poll set maximum size.
*/
-int compat_epoll_set_max_size(void)
+int compat_epoll_set_max_size()
{
int ret, fd, retval = 0;
ssize_t size_ret;
/*
* Set up the poll set limits variable poll_max_size
*/
-extern int compat_epoll_set_max_size(void);
+extern int compat_epoll_set_max_size();
#define lttng_poll_set_max_size() \
compat_epoll_set_max_size()
#if defined(__NR_gettid)
#include <unistd.h>
-static inline pid_t lttng_gettid(void)
+static inline pid_t lttng_gettid()
{
return syscall(__NR_gettid);
}
int ret;
enum lttng_error_code ret_code;
enum lttng_condition_status status;
- const char *session_name = NULL, *channel_name = NULL;
+ const char *session_name = nullptr, *channel_name = nullptr;
enum lttng_domain_type domain_type;
bool is_threshold_bytes = false;
double threshold_ratio;
uint64_t threshold_bytes;
- const char *condition_type_str = NULL;
+ const char *condition_type_str = nullptr;
LTTNG_ASSERT(condition);
LTTNG_ASSERT(IS_USAGE_CONDITION(condition));
condition = zmalloc<lttng_condition_buffer_usage>();
if (!condition) {
- return NULL;
+ return nullptr;
}
lttng_condition_init(&condition->parent, type);
struct lttng_payload_view *view)
{
const struct lttng_evaluation_buffer_usage_comm *comm = (typeof(comm)) view->buffer.data;
- struct lttng_evaluation *evaluation = NULL;
+ struct lttng_evaluation *evaluation = nullptr;
if (view->buffer.size < sizeof(*comm)) {
goto end;
struct lttng_evaluation **_evaluation)
{
ssize_t ret;
- struct lttng_evaluation *evaluation = NULL;
+ struct lttng_evaluation *evaluation = nullptr;
if (!_evaluation) {
ret = -1;
struct lttng_evaluation **_evaluation)
{
ssize_t ret;
- struct lttng_evaluation *evaluation = NULL;
+ struct lttng_evaluation *evaluation = nullptr;
if (!_evaluation) {
ret = -1;
struct lttng_condition **condition)
{
ssize_t ret, condition_size = 0;
- condition_create_from_payload_cb create_from_payload = NULL;
+ condition_create_from_payload_cb create_from_payload = nullptr;
const struct lttng_condition_comm *condition_comm;
const struct lttng_payload_view condition_comm_view =
lttng_payload_view_from_view(view, 0, sizeof(*condition_comm));
{
int ret;
enum lttng_error_code ret_code;
- struct lttng_error_query_results *error_query_results = NULL;
+ struct lttng_error_query_results *error_query_results = nullptr;
LTTNG_ASSERT(condition);
LTTNG_ASSERT(writer);
{
const struct lttng_condition_event_rule_matches *event_rule_matches_cond =
lttng::utils::container_of(condition, <tng_condition_event_rule_matches::parent);
- struct lttng_capture_descriptor *desc = NULL;
+ struct lttng_capture_descriptor *desc = nullptr;
unsigned int count;
enum lttng_condition_status status;
int ret;
enum lttng_error_code ret_code;
enum lttng_condition_status status;
- const struct lttng_event_rule *rule = NULL;
+ const struct lttng_event_rule *rule = nullptr;
unsigned int capture_descriptor_count, i;
LTTNG_ASSERT(condition);
status = lttng_condition_event_rule_matches_get_rule(condition, &rule);
LTTNG_ASSERT(status == LTTNG_CONDITION_STATUS_OK);
- LTTNG_ASSERT(rule != NULL);
+ LTTNG_ASSERT(rule != nullptr);
status = lttng_condition_event_rule_matches_get_capture_descriptor_count(
condition, &capture_descriptor_count);
}
for (i = 0; i < capture_descriptor_count; i++) {
- const struct lttng_event_expr *descriptor = NULL;
+ const struct lttng_event_expr *descriptor = nullptr;
descriptor = lttng_condition_event_rule_matches_get_capture_descriptor_at_index(
condition, i);
struct lttng_condition *lttng_condition_event_rule_matches_create(struct lttng_event_rule *rule)
{
- struct lttng_condition *parent = NULL;
- struct lttng_condition_event_rule_matches *condition = NULL;
+ struct lttng_condition *parent = nullptr;
+ struct lttng_condition_event_rule_matches *condition = nullptr;
if (!rule) {
goto end;
condition = zmalloc<lttng_condition_event_rule_matches>();
if (!condition) {
- return NULL;
+ return nullptr;
}
lttng_condition_init(&condition->parent, LTTNG_CONDITION_TYPE_EVENT_RULE_MATCHES);
lttng_event_rule_get(rule);
condition->rule = rule;
- rule = NULL;
+ rule = nullptr;
lttng_dynamic_pointer_array_init(&condition->capture_descriptors,
destroy_capture_descriptor);
goto end;
error:
- ret = NULL;
+ ret = nullptr;
end:
return ret;
static struct lttng_event_expr *event_expr_from_payload(struct lttng_payload_view *view,
size_t *offset)
{
- struct lttng_event_expr *expr = NULL;
+ struct lttng_event_expr *expr = nullptr;
const char *str;
uint64_t type;
error:
lttng_event_expr_destroy(expr);
- expr = NULL;
+ expr = nullptr;
end:
return expr;
size_t offset = 0;
ssize_t event_rule_length;
uint32_t i, capture_descr_count;
- struct lttng_condition *condition = NULL;
- struct lttng_event_rule *event_rule = NULL;
+ struct lttng_condition *condition = nullptr;
+ struct lttng_event_rule *event_rule = nullptr;
if (!view || !_condition) {
goto error;
consumed_length = (ssize_t) offset;
*_condition = condition;
- condition = NULL;
+ condition = nullptr;
goto end;
error:
lttng_condition_event_rule_matches_get_rule(const struct lttng_condition *condition,
const struct lttng_event_rule **rule)
{
- struct lttng_event_rule *mutable_rule = NULL;
+ struct lttng_event_rule *mutable_rule = nullptr;
const enum lttng_condition_status status =
lttng_condition_event_rule_matches_borrow_rule_mutable(condition, &mutable_rule);
enum lttng_condition_status status = LTTNG_CONDITION_STATUS_OK;
struct lttng_condition_event_rule_matches *event_rule_matches_cond =
lttng::utils::container_of(condition, <tng_condition_event_rule_matches::parent);
- struct lttng_capture_descriptor *descriptor = NULL;
- const struct lttng_event_rule *rule = NULL;
+ struct lttng_capture_descriptor *descriptor = nullptr;
+ const struct lttng_event_rule *rule = nullptr;
/* Only accept l-values. */
if (!condition || !IS_EVENT_RULE_MATCHES_CONDITION(condition) || !expr ||
}
descriptor = malloc<lttng_capture_descriptor>();
- if (descriptor == NULL) {
+ if (descriptor == nullptr) {
status = LTTNG_CONDITION_STATUS_ERROR;
goto end;
}
descriptor->event_expression = expr;
- descriptor->bytecode = NULL;
+ descriptor->bytecode = nullptr;
ret = lttng_dynamic_pointer_array_add_pointer(&event_rule_matches_cond->capture_descriptors,
descriptor);
}
/* Ownership is transfered to the internal capture_descriptors array */
- descriptor = NULL;
+ descriptor = nullptr;
end:
free(descriptor);
return status;
const struct lttng_event_expr *lttng_condition_event_rule_matches_get_capture_descriptor_at_index(
const struct lttng_condition *condition, unsigned int index)
{
- const struct lttng_event_expr *expr = NULL;
- const struct lttng_capture_descriptor *desc = NULL;
+ const struct lttng_event_expr *expr = nullptr;
+ const struct lttng_capture_descriptor *desc = nullptr;
desc = lttng_condition_event_rule_matches_get_internal_capture_descriptor_at_index(
condition, index);
- if (desc == NULL) {
+ if (desc == nullptr) {
goto end;
}
expr = desc->event_expression;
struct lttng_evaluation **_evaluation)
{
ssize_t ret, offset = 0;
- struct lttng_evaluation *evaluation = NULL;
+ struct lttng_evaluation *evaluation = nullptr;
uint32_t capture_payload_size;
- const char *capture_payload = NULL;
+ const char *capture_payload = nullptr;
if (!_evaluation) {
ret = -1;
offset += capture_payload_size;
*_evaluation = evaluation;
- evaluation = NULL;
+ evaluation = nullptr;
ret = offset;
error:
static const msgpack_object *get_msgpack_map_obj(const struct msgpack_object *map_obj,
const char *name)
{
- const msgpack_object *ret = NULL;
+ const msgpack_object *ret = nullptr;
size_t i;
LTTNG_ASSERT(map_obj->type == MSGPACK_OBJECT_MAP);
switch (obj->type) {
case MSGPACK_OBJECT_NIL:
/* Unavailable. */
- *field_val = NULL;
+ *field_val = nullptr;
goto end;
case MSGPACK_OBJECT_POSITIVE_INTEGER:
*field_val = lttng_event_field_value_uint_create(obj->via.u64);
error:
lttng_event_field_value_destroy(*field_val);
- *field_val = NULL;
+ *field_val = nullptr;
ret = -1;
end:
const char *capture_payload,
size_t capture_payload_size)
{
- struct lttng_event_field_value *ret = NULL;
+ struct lttng_event_field_value *ret = nullptr;
msgpack_unpacked unpacked;
msgpack_unpack_return unpack_return;
const msgpack_object *root_obj;
msgpack_unpacked_init(&unpacked);
/* Decode. */
- unpack_return = msgpack_unpack_next(&unpacked, capture_payload, capture_payload_size, NULL);
+ unpack_return =
+ msgpack_unpack_next(&unpacked, capture_payload, capture_payload_size, nullptr);
if (unpack_return != MSGPACK_UNPACK_SUCCESS) {
ERR("msgpack_unpack_next() failed to decode the "
"MessagePack-encoded capture payload: "
error:
lttng_event_field_value_destroy(ret);
- ret = NULL;
+ ret = nullptr;
end:
msgpack_unpacked_destroy(&unpacked);
bool decode_capture_payload)
{
struct lttng_evaluation_event_rule_matches *hit;
- struct lttng_evaluation *evaluation = NULL;
+ struct lttng_evaluation *evaluation = nullptr;
hit = zmalloc<lttng_evaluation_event_rule_matches>();
if (!hit) {
hit->parent.destroy = lttng_evaluation_event_rule_matches_destroy;
evaluation = &hit->parent;
- hit = NULL;
+ hit = nullptr;
error:
if (hit) {
condition, i);
int bytecode_ret;
- if (local_capture_desc == NULL) {
+ if (local_capture_desc == nullptr) {
ret = LTTNG_ERR_FATAL;
goto end;
}
/* Generate the bytecode. */
bytecode_ret = lttng_event_expr_to_bytecode(local_capture_desc->event_expression,
&local_capture_desc->bytecode);
- if (bytecode_ret < 0 || local_capture_desc->bytecode == NULL) {
+ if (bytecode_ret < 0 || local_capture_desc->bytecode == nullptr) {
ret = LTTNG_ERR_INVALID_CAPTURE_EXPRESSION;
goto end;
}
{
const struct lttng_condition_event_rule_matches *event_rule_matches_cond =
lttng::utils::container_of(condition, <tng_condition_event_rule_matches::parent);
- struct lttng_capture_descriptor *desc = NULL;
- struct lttng_bytecode *bytecode = NULL;
+ struct lttng_capture_descriptor *desc = nullptr;
+ struct lttng_bytecode *bytecode = nullptr;
unsigned int count;
enum lttng_condition_status status;
desc = (lttng_capture_descriptor *) lttng_dynamic_pointer_array_get_pointer(
&event_rule_matches_cond->capture_descriptors, index);
- if (desc == NULL) {
+ if (desc == nullptr) {
goto end;
}
int ret;
enum lttng_error_code ret_code;
enum lttng_condition_status status;
- const char *session_name = NULL;
+ const char *session_name = nullptr;
uint64_t threshold_bytes;
LTTNG_ASSERT(condition);
condition = zmalloc<lttng_condition_session_consumed_size>();
if (!condition) {
- return NULL;
+ return nullptr;
}
lttng_condition_init(&condition->parent, LTTNG_CONDITION_TYPE_SESSION_CONSUMED_SIZE);
{
const struct lttng_evaluation_session_consumed_size_comm *comm =
(typeof(comm)) view->buffer.data;
- struct lttng_evaluation *evaluation = NULL;
+ struct lttng_evaluation *evaluation = nullptr;
if (view->buffer.size < sizeof(*comm)) {
goto end;
struct lttng_evaluation **_evaluation)
{
ssize_t ret;
- struct lttng_evaluation *evaluation = NULL;
+ struct lttng_evaluation *evaluation = nullptr;
if (!_evaluation) {
ret = -1;
condition = zmalloc<lttng_condition_session_rotation>();
if (!condition) {
- return NULL;
+ return nullptr;
}
memcpy(&condition->parent, &rotation_condition_template, sizeof(condition->parent));
enum lttng_condition_type type)
{
ssize_t ret;
- struct lttng_condition *condition = NULL;
+ struct lttng_condition *condition = nullptr;
switch (type) {
case LTTNG_CONDITION_TYPE_SESSION_ROTATION_ONGOING:
evaluation = zmalloc<lttng_evaluation_session_rotation>();
if (!evaluation) {
- return NULL;
+ return nullptr;
}
memcpy(&evaluation->parent, &rotation_evaluation_template, sizeof(evaluation->parent));
struct lttng_evaluation **_evaluation)
{
ssize_t ret, size;
- struct lttng_evaluation *evaluation = NULL;
- struct lttng_trace_archive_location *location = NULL;
+ struct lttng_evaluation *evaluation = nullptr;
+ struct lttng_trace_archive_location *location = nullptr;
const struct lttng_evaluation_session_rotation_comm *comm;
struct lttng_payload_view comm_view = lttng_payload_view_from_view(view, 0, sizeof(*comm));
return ret;
error:
lttng_trace_archive_location_put(location);
- evaluation = NULL;
+ evaluation = nullptr;
return -1;
}
struct lttng_evaluation **_evaluation)
{
ssize_t ret;
- struct lttng_evaluation *evaluation = NULL;
+ struct lttng_evaluation *evaluation = nullptr;
if (!_evaluation) {
ret = -1;
struct lttng_evaluation *lttng_evaluation_session_rotation_ongoing_create(uint64_t id)
{
return lttng_evaluation_session_rotation_create(
- LTTNG_CONDITION_TYPE_SESSION_ROTATION_ONGOING, id, NULL);
+ LTTNG_CONDITION_TYPE_SESSION_ROTATION_ONGOING, id, nullptr);
}
struct lttng_evaluation *
int ret;
enum lttng_error_code ret_code;
enum lttng_condition_status status;
- const char *session_name = NULL;
- const char *type_element_str = NULL;
+ const char *session_name = nullptr;
+ const char *type_element_str = nullptr;
LTTNG_ASSERT(condition);
LTTNG_ASSERT(writer);
*/
static xmlChar *encode_string(const char *in_str)
{
- xmlChar *out_str = NULL;
+ xmlChar *out_str = nullptr;
xmlCharEncodingHandlerPtr handler;
int out_len, ret, in_len;
ret = handler->input(out_str, &out_len, (const xmlChar *) in_str, &in_len);
if (ret < 0) {
xmlFree(out_str);
- out_str = NULL;
+ out_str = nullptr;
goto end;
}
goto end;
}
- buffer = xmlOutputBufferCreateFd(fd_output, NULL);
+ buffer = xmlOutputBufferCreateFd(fd_output, nullptr);
if (!buffer) {
goto error_destroy;
}
writer->writer = xmlNewTextWriter(buffer);
- ret = xmlTextWriterStartDocument(writer->writer, NULL, config_xml_encoding, NULL);
+ ret = xmlTextWriterStartDocument(writer->writer, nullptr, config_xml_encoding, nullptr);
if (ret < 0) {
goto error_destroy;
}
return writer;
error_destroy:
config_writer_destroy(writer);
- return NULL;
+ return nullptr;
}
int config_writer_destroy(struct config_writer *writer)
int config_writer_write_attribute(struct config_writer *writer, const char *name, const char *value)
{
int ret;
- xmlChar *encoded_name = NULL;
- xmlChar *encoded_value = NULL;
+ xmlChar *encoded_name = nullptr;
+ xmlChar *encoded_value = nullptr;
if (!writer || !writer->writer || !name || !name[0]) {
ret = -1;
const char *value)
{
int ret;
- xmlChar *encoded_element_name = NULL;
- xmlChar *encoded_value = NULL;
+ xmlChar *encoded_element_name = nullptr;
+ xmlChar *encoded_value = nullptr;
if (!writer || !writer->writer || !element_name || !element_name[0] || !value) {
ret = -1;
memset(ctx, 0, sizeof(struct session_config_validation_ctx));
}
-static char *get_session_config_xsd_path(void)
+static char *get_session_config_xsd_path()
{
char *xsd_path;
const char *base_path = lttng_secure_getenv(DEFAULT_SESSION_CONFIG_XSD_PATH_ENV);
ret = -LTTNG_ERR_LOAD_INVALID_CONFIG;
goto end;
}
- xmlSchemaSetParserErrors(ctx->parser_ctx, xml_error_handler, xml_error_handler, NULL);
+ xmlSchemaSetParserErrors(ctx->parser_ctx, xml_error_handler, xml_error_handler, nullptr);
ctx->schema = xmlSchemaParse(ctx->parser_ctx);
if (!ctx->schema) {
}
xmlSchemaSetValidErrors(
- ctx->schema_validation_ctx, xml_error_handler, xml_error_handler, NULL);
+ ctx->schema_validation_ctx, xml_error_handler, xml_error_handler, nullptr);
ret = 0;
end:
{
int ret;
enum lttng_error_code ret_code;
- xmlNodePtr node = NULL;
+ xmlNodePtr node = nullptr;
xmlNodePtr snapshot_output_list_node;
xmlNodePtr snapshot_output_node;
struct lttng_session_descriptor *session_descriptor = nullptr;
for (snapshot_output_node = xmlFirstElementChild(snapshot_output_list_node);
snapshot_output_node;
snapshot_output_node = xmlNextElementSibling(snapshot_output_node)) {
- char *name = NULL;
+ char *name = nullptr;
uint64_t max_size = UINT64_MAX;
struct consumer_output output = {};
- struct lttng_snapshot_output *snapshot_output = NULL;
- const char *control_uri = NULL;
- const char *data_uri = NULL;
- const char *path = NULL;
+ struct lttng_snapshot_output *snapshot_output = nullptr;
+ const char *control_uri = nullptr;
+ const char *data_uri = nullptr;
+ const char *path = nullptr;
for (node = xmlFirstElementChild(snapshot_output_node); node;
node = xmlNextElementSibling(node)) {
if (overrides->path_url) {
path = overrides->path_url;
/* Control/data_uri are null */
- control_uri = NULL;
- data_uri = NULL;
+ control_uri = nullptr;
+ data_uri = nullptr;
} else {
if (overrides->ctrl_url) {
control_uri = overrides->ctrl_url;
/* path is null */
- path = NULL;
+ path = nullptr;
}
if (overrides->data_url) {
data_uri = overrides->data_url;
/* path is null */
- path = NULL;
+ path = nullptr;
}
}
}
enum lttng_error_code ret_code;
struct consumer_output output = {};
xmlNodePtr consumer_output_node;
- const char *control_uri = NULL;
- const char *data_uri = NULL;
- const char *path = NULL;
+ const char *control_uri = nullptr;
+ const char *data_uri = nullptr;
+ const char *path = nullptr;
struct lttng_session_descriptor *session_descriptor = nullptr;
LTTNG_ASSERT(name);
if (overrides->path_url) {
path = overrides->path_url;
/* control/data_uri are null */;
- control_uri = NULL;
- data_uri = NULL;
+ control_uri = nullptr;
+ data_uri = nullptr;
} else {
if (overrides->ctrl_url) {
control_uri = overrides->ctrl_url;
/* path is null */
- path = NULL;
+ path = nullptr;
}
if (overrides->data_url) {
data_uri = overrides->data_url;
/* path is null */
- path = NULL;
+ path = nullptr;
}
}
}
process_userspace_probe_function_attribute_node(xmlNodePtr attribute_node)
{
xmlNodePtr function_attribute_node;
- char *function_name = NULL, *binary_path = NULL;
- struct lttng_userspace_probe_location *location = NULL;
- struct lttng_userspace_probe_location_lookup_method *lookup_method = NULL;
+ char *function_name = nullptr, *binary_path = nullptr;
+ struct lttng_userspace_probe_location *location = nullptr;
+ struct lttng_userspace_probe_location_lookup_method *lookup_method = nullptr;
/*
* Process userspace probe location function attributes. The order of
/* Ownership of lookup_method is transferred. */
location = lttng_userspace_probe_location_function_create(
binary_path, function_name, lookup_method);
- lookup_method = NULL;
+ lookup_method = nullptr;
goto error;
}
}
process_userspace_probe_tracepoint_attribute_node(xmlNodePtr attribute_node)
{
xmlNodePtr tracepoint_attribute_node;
- char *probe_name = NULL, *provider_name = NULL, *binary_path = NULL;
- struct lttng_userspace_probe_location *location = NULL;
- struct lttng_userspace_probe_location_lookup_method *lookup_method = NULL;
+ char *probe_name = nullptr, *provider_name = nullptr, *binary_path = nullptr;
+ struct lttng_userspace_probe_location *location = nullptr;
+ struct lttng_userspace_probe_location_lookup_method *lookup_method = nullptr;
/*
* Process userspace probe location tracepoint attributes. The order of
/* Ownership of lookup_method is transferred. */
location = lttng_userspace_probe_location_tracepoint_create(
binary_path, provider_name, probe_name, lookup_method);
- lookup_method = NULL;
+ lookup_method = nullptr;
goto error;
}
}
int ret = 0, i;
xmlNodePtr node;
struct lttng_event *event;
- char **exclusions = NULL;
+ char **exclusions = nullptr;
unsigned long exclusion_count = 0;
- char *filter_expression = NULL;
+ char *filter_expression = nullptr;
LTTNG_ASSERT(event_node);
LTTNG_ASSERT(handle);
memset(&event, 0, sizeof(event));
event.loglevel = -1;
event.type = LTTNG_EVENT_ALL;
- ret = lttng_disable_event_ext(handle, &event, channel_name, NULL);
+ ret = lttng_disable_event_ext(handle, &event, channel_name, nullptr);
if (ret) {
goto end;
}
goto end;
}
- ret = lttng_add_context(handle, &context, NULL, channel_name);
+ ret = lttng_add_context(handle, &context, nullptr, channel_name);
if (context.ctx == LTTNG_EVENT_CONTEXT_APP_CONTEXT) {
free(context.u.app_ctx.provider_name);
free(context.u.app_ctx.ctx_name);
*element_value_type = config_element_process_attr_pid_value;
*element_value = config_element_process_attr_id;
*element_value_alias = config_element_process_attr_id;
- *element_name = NULL;
+ *element_name = nullptr;
break;
case LTTNG_PROCESS_ATTR_VIRTUAL_PROCESS_ID:
*element_id_tracker = config_element_process_attr_tracker_vpid;
*element_value_type = config_element_process_attr_vpid_value;
*element_value = config_element_process_attr_id;
- *element_value_alias = NULL;
- *element_name = NULL;
+ *element_value_alias = nullptr;
+ *element_name = nullptr;
break;
case LTTNG_PROCESS_ATTR_USER_ID:
*element_id_tracker = config_element_process_attr_tracker_uid;
*element_value_type = config_element_process_attr_uid_value;
*element_value = config_element_process_attr_id;
- *element_value_alias = NULL;
+ *element_value_alias = nullptr;
*element_name = config_element_name;
break;
case LTTNG_PROCESS_ATTR_VIRTUAL_USER_ID:
*element_id_tracker = config_element_process_attr_tracker_vuid;
*element_value_type = config_element_process_attr_vuid_value;
*element_value = config_element_process_attr_id;
- *element_value_alias = NULL;
+ *element_value_alias = nullptr;
*element_name = config_element_name;
break;
case LTTNG_PROCESS_ATTR_GROUP_ID:
*element_id_tracker = config_element_process_attr_tracker_gid;
*element_value_type = config_element_process_attr_gid_value;
*element_value = config_element_process_attr_id;
- *element_value_alias = NULL;
+ *element_value_alias = nullptr;
*element_name = config_element_name;
break;
case LTTNG_PROCESS_ATTR_VIRTUAL_GROUP_ID:
*element_id_tracker = config_element_process_attr_tracker_vgid;
*element_value_type = config_element_process_attr_vgid_value;
*element_value = config_element_process_attr_id;
- *element_value_alias = NULL;
+ *element_value_alias = nullptr;
*element_name = config_element_name;
break;
default:
static int process_legacy_pid_tracker_node(xmlNodePtr trackers_node, struct lttng_handle *handle)
{
int ret = 0, child_count;
- xmlNodePtr targets_node = NULL;
+ xmlNodePtr targets_node = nullptr;
xmlNodePtr node;
const char *element_id_tracker;
const char *element_target_id;
const char *element_id_alias;
const char *element_name;
enum lttng_error_code tracker_handle_ret_code;
- struct lttng_process_attr_tracker_handle *tracker_handle = NULL;
+ struct lttng_process_attr_tracker_handle *tracker_handle = nullptr;
enum lttng_process_attr_tracker_handle_status status;
const enum lttng_process_attr process_attr = handle->domain.type == LTTNG_DOMAIN_UST ?
LTTNG_PROCESS_ATTR_VIRTUAL_PROCESS_ID :
enum lttng_process_attr process_attr)
{
int ret = 0, child_count;
- xmlNodePtr values_node = NULL;
+ xmlNodePtr values_node = nullptr;
xmlNodePtr node;
const char *element_id_tracker;
const char *element_target_id;
const char *element_id_alias;
const char *element_name;
enum lttng_error_code tracker_handle_ret_code;
- struct lttng_process_attr_tracker_handle *tracker_handle = NULL;
+ struct lttng_process_attr_tracker_handle *tracker_handle = nullptr;
enum lttng_process_attr_tracker_handle_status status;
LTTNG_ASSERT(handle);
{
int ret;
struct lttng_domain domain {};
- struct lttng_handle *handle = NULL;
- struct lttng_channel *channel = NULL;
- xmlNodePtr channels_node = NULL;
- xmlNodePtr trackers_node = NULL;
- xmlNodePtr pid_tracker_node = NULL;
- xmlNodePtr vpid_tracker_node = NULL;
- xmlNodePtr uid_tracker_node = NULL;
- xmlNodePtr vuid_tracker_node = NULL;
- xmlNodePtr gid_tracker_node = NULL;
- xmlNodePtr vgid_tracker_node = NULL;
+ struct lttng_handle *handle = nullptr;
+ struct lttng_channel *channel = nullptr;
+ xmlNodePtr channels_node = nullptr;
+ xmlNodePtr trackers_node = nullptr;
+ xmlNodePtr pid_tracker_node = nullptr;
+ xmlNodePtr vpid_tracker_node = nullptr;
+ xmlNodePtr uid_tracker_node = nullptr;
+ xmlNodePtr vuid_tracker_node = nullptr;
+ xmlNodePtr gid_tracker_node = nullptr;
+ xmlNodePtr vgid_tracker_node = nullptr;
xmlNodePtr node;
LTTNG_ASSERT(session_name);
/* create all channels */
for (node = xmlFirstElementChild(channels_node); node; node = xmlNextElementSibling(node)) {
const enum lttng_domain_type original_domain = domain.type;
- xmlNodePtr contexts_node = NULL;
- xmlNodePtr events_node = NULL;
+ xmlNodePtr contexts_node = nullptr;
+ xmlNodePtr events_node = nullptr;
xmlNodePtr channel_attr_node;
/*
lttng_channel_destroy(channel);
}
- channel = NULL;
+ channel = nullptr;
/* get the trackers node */
for (node = xmlFirstElementChild(domain_node); node; node = xmlNextElementSibling(node)) {
{
int ret, started = -1, snapshot_mode = -1;
uint64_t live_timer_interval = UINT64_MAX, rotation_timer_interval = 0, rotation_size = 0;
- xmlChar *name = NULL;
- xmlChar *shm_path = NULL;
- xmlNodePtr domains_node = NULL;
- xmlNodePtr output_node = NULL;
+ xmlChar *name = nullptr;
+ xmlChar *shm_path = nullptr;
+ xmlNodePtr domains_node = nullptr;
+ xmlNodePtr output_node = nullptr;
xmlNodePtr node;
xmlNodePtr attributes_child;
- struct lttng_domain *kernel_domain = NULL;
- struct lttng_domain *ust_domain = NULL;
- struct lttng_domain *jul_domain = NULL;
- struct lttng_domain *log4j_domain = NULL;
- struct lttng_domain *python_domain = NULL;
+ struct lttng_domain *kernel_domain = nullptr;
+ struct lttng_domain *ust_domain = nullptr;
+ struct lttng_domain *jul_domain = nullptr;
+ struct lttng_domain *log4j_domain = nullptr;
+ struct lttng_domain *python_domain = nullptr;
for (node = xmlFirstElementChild(session_node); node; node = xmlNextElementSibling(node)) {
if (!name && !strcmp((const char *) node->name, config_element_name)) {
const struct config_load_session_override_attr *overrides)
{
int ret, session_found = !session_name;
- xmlDocPtr doc = NULL;
+ xmlDocPtr doc = nullptr;
xmlNodePtr sessions_node;
xmlNodePtr session_node;
const struct config_load_session_override_attr *overrides)
{
int ret, session_found = !session_name;
- DIR *directory = NULL;
+ DIR *directory = nullptr;
struct lttng_dynamic_buffer file_path;
size_t path_len;
{
int ret;
bool session_loaded = false;
- const char *path_ptr = NULL;
+ const char *path_ptr = nullptr;
struct session_config_validation_ctx validation_ctx = {};
ret = init_session_config_validation_ctx(&validation_ctx);
}
/* Reset path pointer for the system wide dir. */
- path_ptr = NULL;
+ path_ptr = nullptr;
/* Try system wide configuration directory. */
if (autoload) {
return ret;
}
-static void __attribute__((destructor)) session_config_exit(void)
+static void __attribute__((destructor)) session_config_exit()
{
xmlCleanupParser();
}
ret = -1;
goto end;
}
- ret = pthread_mutex_init(&channel->metadata_cache->lock, NULL);
+ ret = pthread_mutex_init(&channel->metadata_cache->lock, nullptr);
if (ret != 0) {
PERROR("mutex init");
goto end_free_cache;
int consumer_stream_sync_metadata(struct lttng_consumer_local_data *ctx, uint64_t session_id)
{
int ret;
- struct lttng_consumer_stream *stream = NULL;
+ struct lttng_consumer_stream *stream = nullptr;
struct lttng_ht_iter iter;
struct lttng_ht *ht;
goto end;
}
- ret = consumer_stream_flush_buffer(stream, 0);
+ ret = consumer_stream_flush_buffer(stream, false);
if (ret) {
ERR("Failed to flush an empty packet at rotation point: stream id = %" PRIu64
", channel name = %s, session id = %" PRIu64,
struct lttng_consumer_stream *stream;
stream = zmalloc<lttng_consumer_stream>();
- if (stream == NULL) {
+ if (stream == nullptr) {
PERROR("malloc struct lttng_consumer_stream");
ret = -ENOMEM;
goto end;
stream->session_id = session_id;
stream->monitor = monitor;
stream->endpoint_status = CONSUMER_ENDPOINT_ACTIVE;
- stream->index_file = NULL;
+ stream->index_file = nullptr;
stream->last_sequence_number = -1ULL;
stream->rotate_position = -1ULL;
/* Buffer is created with an open packet. */
stream->opened_packet_in_current_trace_chunk = true;
- pthread_mutex_init(&stream->lock, NULL);
- pthread_mutex_init(&stream->metadata_timer_lock, NULL);
+ pthread_mutex_init(&stream->lock, nullptr);
+ pthread_mutex_init(&stream->metadata_timer_lock, nullptr);
/* If channel is the metadata, flag this stream as metadata. */
if (type == CONSUMER_CHANNEL_TYPE_METADATA) {
/* Metadata is flat out. */
strncpy(stream->name, DEFAULT_METADATA_NAME, sizeof(stream->name));
/* Live rendez-vous point. */
- pthread_cond_init(&stream->metadata_rdv, NULL);
- pthread_mutex_init(&stream->metadata_rdv_lock, NULL);
+ pthread_cond_init(&stream->metadata_rdv, nullptr);
+ pthread_mutex_init(&stream->metadata_rdv_lock, nullptr);
} else {
/* Format stream name to <channel_name>_<cpu_number> */
ret = snprintf(stream->name, sizeof(stream->name), "%s_%d", channel_name, cpu);
rcu_read_unlock();
lttng_dynamic_array_init(
- &stream->read_subbuffer_ops.post_consume_cbs, sizeof(post_consume_cb), NULL);
+ &stream->read_subbuffer_ops.post_consume_cbs, sizeof(post_consume_cb), nullptr);
if (type == CONSUMER_CHANNEL_TYPE_METADATA) {
stream->read_subbuffer_ops.lock = consumer_stream_metadata_lock_all;
if (alloc_ret) {
*alloc_ret = ret;
}
- return NULL;
+ return nullptr;
}
/*
if (stream->index_file) {
lttng_index_file_put(stream->index_file);
- stream->index_file = NULL;
+ stream->index_file = nullptr;
}
lttng_trace_chunk_put(stream->trace_chunk);
- stream->trace_chunk = NULL;
+ stream->trace_chunk = nullptr;
/* Check and cleanup relayd if needed. */
rcu_read_lock();
relayd = consumer_find_relayd(stream->net_seq_idx);
- if (relayd != NULL) {
+ if (relayd != nullptr) {
consumer_stream_relayd_close(stream, relayd);
stream->net_seq_idx = -1ULL;
}
switch (the_consumer_data.type) {
case LTTNG_CONSUMER_KERNEL:
- if (stream->mmap_base != NULL) {
+ if (stream->mmap_base != nullptr) {
const auto ret = munmap(stream->mmap_base, stream->mmap_len);
if (ret != 0) {
*/
static struct lttng_consumer_channel *unref_channel(struct lttng_consumer_stream *stream)
{
- struct lttng_consumer_channel *free_chan = NULL;
+ struct lttng_consumer_channel *free_chan = nullptr;
LTTNG_ASSERT(stream);
LTTNG_ASSERT(stream->chan);
/* Stream is in monitor mode. */
if (stream->monitor) {
- struct lttng_consumer_channel *free_chan = NULL;
+ struct lttng_consumer_channel *free_chan = nullptr;
/*
* This means that the stream was successfully removed from the streams
/* Free stream within a RCU call. */
lttng_trace_chunk_put(stream->trace_chunk);
- stream->trace_chunk = NULL;
+ stream->trace_chunk = nullptr;
lttng_dynamic_array_reset(&stream->read_subbuffer_ops.post_consume_cbs);
consumer_stream_free(stream);
}
stream->name,
stream->chan->tracefile_size,
stream->tracefile_count_current,
- NULL,
+ nullptr,
stream_path,
sizeof(stream_path));
if (ret < 0) {
ssize_t ret;
struct lttng_consumer_stream *stream = (lttng_consumer_stream *) data;
- ret = consumer_stream_consume_mmap(NULL, stream, buffer);
+ ret = consumer_stream_consume_mmap(nullptr, stream, buffer);
if (ret < 0) {
goto end;
}
its.it_interval.tv_sec = its.it_value.tv_sec;
its.it_interval.tv_nsec = its.it_value.tv_nsec;
- ret = timer_settime(*timer_id, 0, &its, NULL);
+ ret = timer_settime(*timer_id, 0, &its, nullptr);
if (ret == -1) {
PERROR("timer_settime");
goto error_destroy_timer;
}
consumer_timer_signal_thread_qs(signal);
- *timer_id = 0;
+ *timer_id = nullptr;
end:
return ret;
}
* Block the RT signals for the entire process. It must be called from the
* consumer main before creating the threads
*/
-int consumer_signal_init(void)
+int consumer_signal_init()
{
int ret;
sigset_t mask;
/* Block signal for entire process, so only our thread processes it. */
setmask(&mask);
- ret = pthread_sigmask(SIG_BLOCK, &mask, NULL);
+ ret = pthread_sigmask(SIG_BLOCK, &mask, nullptr);
if (ret) {
errno = ret;
PERROR("pthread_sigmask");
}
}
-int consumer_timer_thread_get_channel_monitor_pipe(void)
+int consumer_timer_thread_get_channel_monitor_pipe()
{
return uatomic_read(&the_channel_monitor_pipe);
}
setmask(&mask);
CMM_STORE_SHARED(timer_signal.tid, pthread_self());
- while (1) {
+ while (true) {
health_code_update();
health_poll_entry();
end:
health_unregister(health_consumerd);
rcu_unregister_thread();
- return NULL;
+ return nullptr;
}
unsigned int monitor_timer_interval_us);
int consumer_timer_monitor_stop(struct lttng_consumer_channel *channel);
void *consumer_timer_thread(void *data);
-int consumer_signal_init(void);
+int consumer_signal_init();
int consumer_flush_kernel_index(struct lttng_consumer_stream *stream);
int consumer_flush_ust_index(struct lttng_consumer_stream *stream);
-int consumer_timer_thread_get_channel_monitor_pipe(void);
+int consumer_timer_thread_get_channel_monitor_pipe();
int consumer_timer_thread_set_channel_monitor_pipe(int fd);
#endif /* CONSUMER_TIMER_H */
*/
int consumer_quit;
-static const char *get_consumer_domain(void)
+static const char *get_consumer_domain()
{
switch (the_consumer_data.type) {
case LTTNG_CONSUMER_KERNEL:
*/
static void notify_thread_lttng_pipe(struct lttng_pipe *pipe)
{
- struct lttng_consumer_stream *null_stream = NULL;
+ struct lttng_consumer_stream *null_stream = nullptr;
LTTNG_ASSERT(pipe);
void notify_thread_del_channel(struct lttng_consumer_local_data *ctx, uint64_t key)
{
- notify_channel_pipe(ctx, NULL, key, CONSUMER_CHANNEL_DEL);
+ notify_channel_pipe(ctx, nullptr, key, CONSUMER_CHANNEL_DEL);
}
static int read_channel_pipe(struct lttng_consumer_local_data *ctx,
* global hash table.
*/
stream->monitor = 0;
- consumer_stream_destroy(stream, NULL);
+ consumer_stream_destroy(stream, nullptr);
}
}
{
struct lttng_ht_iter iter;
struct lttng_ht_node_u64 *node;
- struct lttng_consumer_stream *stream = NULL;
+ struct lttng_consumer_stream *stream = nullptr;
LTTNG_ASSERT(ht);
/* -1ULL keys are lookup failures */
if (key == (uint64_t) -1ULL) {
- return NULL;
+ return nullptr;
}
rcu_read_lock();
lttng_ht_lookup(ht, &key, &iter);
node = lttng_ht_iter_get_node_u64(&iter);
- if (node != NULL) {
+ if (node != nullptr) {
stream = lttng::utils::container_of(node, <tng_consumer_stream::node);
}
{
struct lttng_ht_iter iter;
struct lttng_ht_node_u64 *node;
- struct lttng_consumer_channel *channel = NULL;
+ struct lttng_consumer_channel *channel = nullptr;
ASSERT_RCU_READ_LOCKED();
/* -1ULL keys are lookup failures */
if (key == (uint64_t) -1ULL) {
- return NULL;
+ return nullptr;
}
lttng_ht_lookup(the_consumer_data.channel_ht, &key, &iter);
node = lttng_ht_iter_get_node_u64(&iter);
- if (node != NULL) {
+ if (node != nullptr) {
channel = lttng::utils::container_of(node, <tng_consumer_channel::node);
}
int ret;
struct lttng_ht_iter iter;
- if (relayd == NULL) {
+ if (relayd == nullptr) {
return;
}
}
lttng_trace_chunk_put(channel->trace_chunk);
- channel->trace_chunk = NULL;
+ channel->trace_chunk = nullptr;
if (channel->is_published) {
int ret;
* Iterate over the relayd hash table and destroy each element. Finally,
* destroy the whole hash table.
*/
-static void cleanup_relayd_ht(void)
+static void cleanup_relayd_ht()
{
struct lttng_ht_iter iter;
struct consumer_relayd_sock_pair *relayd;
lttng_ht_lookup(the_consumer_data.relayd_ht, &relayd->net_seq_idx, &iter);
node = lttng_ht_iter_get_node_u64(&iter);
- if (node != NULL) {
+ if (node != nullptr) {
goto end;
}
lttng_ht_add_unique_u64(the_consumer_data.relayd_ht, &relayd->node);
*/
static struct consumer_relayd_sock_pair *consumer_allocate_relayd_sock_pair(uint64_t net_seq_idx)
{
- struct consumer_relayd_sock_pair *obj = NULL;
+ struct consumer_relayd_sock_pair *obj = nullptr;
/* net sequence index of -1 is a failure */
if (net_seq_idx == (uint64_t) -1ULL) {
}
obj = zmalloc<consumer_relayd_sock_pair>();
- if (obj == NULL) {
+ if (obj == nullptr) {
PERROR("zmalloc relayd sock");
goto error;
}
obj->control_sock.sock.fd = -1;
obj->data_sock.sock.fd = -1;
lttng_ht_node_init_u64(&obj->node, obj->net_seq_idx);
- pthread_mutex_init(&obj->ctrl_sock_mutex, NULL);
+ pthread_mutex_init(&obj->ctrl_sock_mutex, nullptr);
error:
return obj;
{
struct lttng_ht_iter iter;
struct lttng_ht_node_u64 *node;
- struct consumer_relayd_sock_pair *relayd = NULL;
+ struct consumer_relayd_sock_pair *relayd = nullptr;
ASSERT_RCU_READ_LOCKED();
lttng_ht_lookup(the_consumer_data.relayd_ht, &key, &iter);
node = lttng_ht_iter_get_node_u64(&iter);
- if (node != NULL) {
+ if (node != nullptr) {
relayd = lttng::utils::container_of(node, &consumer_relayd_sock_pair::node);
}
/* The stream is not metadata. Get relayd reference if exists. */
rcu_read_lock();
relayd = consumer_find_relayd(stream->net_seq_idx);
- if (relayd != NULL) {
+ if (relayd != nullptr) {
/* Add stream on the relayd */
pthread_mutex_lock(&relayd->ctrl_sock_mutex);
ret = relayd_add_stream(&relayd->control_sock,
/* The stream is not metadata. Get relayd reference if exists. */
rcu_read_lock();
relayd = consumer_find_relayd(net_seq_idx);
- if (relayd != NULL) {
+ if (relayd != nullptr) {
/* Add stream on the relayd */
pthread_mutex_lock(&relayd->ctrl_sock_mutex);
ret = relayd_streams_sent(&relayd->control_sock);
const char *root_shm_path,
const char *shm_path)
{
- struct lttng_consumer_channel *channel = NULL;
- struct lttng_trace_chunk *trace_chunk = NULL;
+ struct lttng_consumer_channel *channel = nullptr;
+ struct lttng_trace_chunk *trace_chunk = nullptr;
if (chunk_id) {
trace_chunk = lttng_trace_chunk_registry_find_chunk(
}
channel = zmalloc<lttng_consumer_channel>();
- if (channel == NULL) {
+ if (channel == nullptr) {
PERROR("malloc struct lttng_consumer_channel");
goto end;
}
channel->monitor = monitor;
channel->live_timer_interval = live_timer_interval;
channel->is_live = is_in_live_session;
- pthread_mutex_init(&channel->lock, NULL);
- pthread_mutex_init(&channel->timer_lock, NULL);
+ pthread_mutex_init(&channel->lock, nullptr);
+ pthread_mutex_init(&channel->timer_lock, nullptr);
switch (output) {
case LTTNG_EVENT_SPLICE:
default:
abort();
free(channel);
- channel = NULL;
+ channel = nullptr;
goto end;
}
return channel;
error:
consumer_del_channel(channel);
- channel = NULL;
+ channel = nullptr;
goto end;
}
* Close all the tracefiles and stream fds and MUST be called when all
* instances are destroyed i.e. when all threads were joined and are ended.
*/
-void lttng_consumer_cleanup(void)
+void lttng_consumer_cleanup()
{
struct lttng_ht_iter iter;
struct lttng_consumer_channel *channel;
the_consumer_data.type = type;
ctx = zmalloc<lttng_consumer_local_data>();
- if (ctx == NULL) {
+ if (ctx == nullptr) {
PERROR("allocating context");
goto error;
}
ctx->consumer_error_socket = -1;
ctx->consumer_metadata_socket = -1;
- pthread_mutex_init(&ctx->metadata_socket_lock, NULL);
+ pthread_mutex_init(&ctx->metadata_socket_lock, nullptr);
/* assign the callbacks */
ctx->on_buffer_ready = buffer_ready;
ctx->on_recv_channel = recv_channel;
error_poll_pipe:
free(ctx);
error:
- return NULL;
+ return nullptr;
}
/*
struct lttng_ht_iter iter;
struct lttng_consumer_stream *stream;
- if (ht == NULL) {
+ if (ht == nullptr) {
return;
}
struct lttng_ht_iter iter;
struct lttng_consumer_stream *stream;
- if (ht == NULL) {
+ if (ht == nullptr) {
return;
}
off_t orig_offset = stream->out_fd_offset;
/* Default is on the disk */
int outfd = stream->out_fd;
- struct consumer_relayd_sock_pair *relayd = NULL;
+ struct consumer_relayd_sock_pair *relayd = nullptr;
unsigned int relayd_hang_up = 0;
const size_t subbuf_content_size = buffer->size - padding;
size_t write_len;
/* Flag that the current stream if set for network streaming. */
if (stream->net_seq_idx != (uint64_t) -1ULL) {
relayd = consumer_find_relayd(stream->net_seq_idx);
- if (relayd == NULL) {
+ if (relayd == nullptr) {
ret = -EPIPE;
goto end;
}
int fd = stream->wait_fd;
/* Default is on the disk */
int outfd = stream->out_fd;
- struct consumer_relayd_sock_pair *relayd = NULL;
+ struct consumer_relayd_sock_pair *relayd = nullptr;
int *splice_pipe;
unsigned int relayd_hang_up = 0;
/* Flag that the current stream if set for network streaming. */
if (stream->net_seq_idx != (uint64_t) -1ULL) {
relayd = consumer_find_relayd(stream->net_seq_idx);
- if (relayd == NULL) {
+ if (relayd == nullptr) {
written = -ret;
goto end;
}
fd,
splice_pipe[1]);
ret_splice = splice(
- fd, &offset, splice_pipe[1], NULL, len, SPLICE_F_MOVE | SPLICE_F_MORE);
+ fd, &offset, splice_pipe[1], nullptr, len, SPLICE_F_MOVE | SPLICE_F_MORE);
DBG("splice chan to pipe, ret %zd", ret_splice);
if (ret_splice < 0) {
ret = errno;
/* Splice data out */
ret_splice = splice(splice_pipe[0],
- NULL,
+ nullptr,
outfd,
- NULL,
+ nullptr,
ret_splice,
SPLICE_F_MOVE | SPLICE_F_MORE);
DBG("Consumer splice pipe to file (out_fd: %d), ret %zd", outfd, ret_splice);
}
}
-static void lttng_consumer_close_all_metadata(void)
+static void lttng_consumer_close_all_metadata()
{
switch (the_consumer_data.type) {
case LTTNG_CONSUMER_KERNEL:
*/
void consumer_del_metadata_stream(struct lttng_consumer_stream *stream, struct lttng_ht *ht)
{
- struct lttng_consumer_channel *channel = NULL;
+ struct lttng_consumer_channel *channel = nullptr;
bool free_channel = false;
LTTNG_ASSERT(stream);
/* Go for channel deletion! */
free_channel = true;
}
- stream->chan = NULL;
+ stream->chan = nullptr;
/*
* Nullify the stream reference so it is not used after deletion. The
* channel lock MUST be acquired before being able to check for a NULL
* pointer value.
*/
- channel->metadata_stream = NULL;
+ channel->metadata_stream = nullptr;
if (channel->metadata_cache) {
pthread_mutex_unlock(&channel->metadata_cache->lock);
}
lttng_trace_chunk_put(stream->trace_chunk);
- stream->trace_chunk = NULL;
+ stream->trace_chunk = nullptr;
consumer_stream_free(stream);
}
/*
* Delete data stream that are flagged for deletion (endpoint_status).
*/
-static void validate_endpoint_status_data_stream(void)
+static void validate_endpoint_status_data_stream()
{
struct lttng_ht_iter iter;
struct lttng_consumer_stream *stream;
{
int ret, i, pollfd, err = -1;
uint32_t revents, nb_fd;
- struct lttng_consumer_stream *stream = NULL;
+ struct lttng_consumer_stream *stream = nullptr;
struct lttng_ht_iter iter;
struct lttng_ht_node_u64 *node;
struct lttng_poll_event events;
/* Main loop */
DBG("Metadata main loop started");
- while (1) {
+ while (true) {
restart:
health_code_update();
health_poll_entry();
}
/* A NULL stream means that the state has changed. */
- if (stream == NULL) {
+ if (stream == nullptr) {
/* Check for deleted streams. */
validate_endpoint_status_metadata_stream(&events);
goto restart;
}
health_unregister(health_consumerd);
rcu_unregister_thread();
- return NULL;
+ return nullptr;
}
/*
void *consumer_thread_data_poll(void *data)
{
int num_rdy, num_hup, high_prio, ret, i, err = -1;
- struct pollfd *pollfd = NULL;
+ struct pollfd *pollfd = nullptr;
/* local view of the streams */
- struct lttng_consumer_stream **local_stream = NULL, *new_stream = NULL;
+ struct lttng_consumer_stream **local_stream = nullptr, *new_stream = nullptr;
/* local view of consumer_data.fds_count */
int nb_fd = 0;
/* 2 for the consumer_data_pipe and wake up pipe */
health_code_update();
local_stream = zmalloc<lttng_consumer_stream *>();
- if (local_stream == NULL) {
+ if (local_stream == nullptr) {
PERROR("local_stream malloc");
goto end;
}
- while (1) {
+ while (true) {
health_code_update();
high_prio = 0;
pthread_mutex_lock(&the_consumer_data.lock);
if (the_consumer_data.need_update) {
free(pollfd);
- pollfd = NULL;
+ pollfd = nullptr;
free(local_stream);
- local_stream = NULL;
+ local_stream = nullptr;
/* Allocate for all fds */
pollfd =
calloc<struct pollfd>(the_consumer_data.stream_count + nb_pipes_fd);
- if (pollfd == NULL) {
+ if (pollfd == nullptr) {
PERROR("pollfd malloc");
pthread_mutex_unlock(&the_consumer_data.lock);
goto end;
local_stream = calloc<lttng_consumer_stream *>(
the_consumer_data.stream_count + nb_pipes_fd);
- if (local_stream == NULL) {
+ if (local_stream == nullptr) {
PERROR("local_stream malloc");
pthread_mutex_unlock(&the_consumer_data.lock);
goto end;
* the sessiond poll thread changed the consumer_quit state and is
* waking us up to test it.
*/
- if (new_stream == NULL) {
+ if (new_stream == nullptr) {
validate_endpoint_status_data_stream();
continue;
}
for (i = 0; i < nb_fd; i++) {
health_code_update();
- if (local_stream[i] == NULL) {
+ if (local_stream[i] == nullptr) {
continue;
}
if (pollfd[i].revents & POLLPRI) {
if (len < 0 && len != -EAGAIN && len != -ENODATA) {
/* Clean the stream and free it. */
consumer_del_stream(local_stream[i], data_ht);
- local_stream[i] = NULL;
+ local_stream[i] = nullptr;
} else if (len > 0) {
local_stream[i]->has_data_left_to_be_read_before_teardown =
1;
for (i = 0; i < nb_fd; i++) {
health_code_update();
- if (local_stream[i] == NULL) {
+ if (local_stream[i] == nullptr) {
continue;
}
if ((pollfd[i].revents & POLLIN) || local_stream[i]->hangup_flush_done ||
if (len < 0 && len != -EAGAIN && len != -ENODATA) {
/* Clean the stream and free it. */
consumer_del_stream(local_stream[i], data_ht);
- local_stream[i] = NULL;
+ local_stream[i] = nullptr;
} else if (len > 0) {
local_stream[i]->has_data_left_to_be_read_before_teardown =
1;
for (i = 0; i < nb_fd; i++) {
health_code_update();
- if (local_stream[i] == NULL) {
+ if (local_stream[i] == nullptr) {
continue;
}
if (!local_stream[i]->hangup_flush_done &&
DBG("Polling fd %d tells it has hung up.", pollfd[i].fd);
if (!local_stream[i]->has_data_left_to_be_read_before_teardown) {
consumer_del_stream(local_stream[i], data_ht);
- local_stream[i] = NULL;
+ local_stream[i] = nullptr;
num_hup++;
}
} else if (pollfd[i].revents & POLLERR) {
ERR("Error returned in polling fd %d.", pollfd[i].fd);
if (!local_stream[i]->has_data_left_to_be_read_before_teardown) {
consumer_del_stream(local_stream[i], data_ht);
- local_stream[i] = NULL;
+ local_stream[i] = nullptr;
num_hup++;
}
} else if (pollfd[i].revents & POLLNVAL) {
ERR("Polling fd %d tells fd is not open.", pollfd[i].fd);
if (!local_stream[i]->has_data_left_to_be_read_before_teardown) {
consumer_del_stream(local_stream[i], data_ht);
- local_stream[i] = NULL;
+ local_stream[i] = nullptr;
num_hup++;
}
}
- if (local_stream[i] != NULL) {
+ if (local_stream[i] != nullptr) {
local_stream[i]->has_data_left_to_be_read_before_teardown = 0;
}
}
health_unregister(health_consumerd);
rcu_unregister_thread();
- return NULL;
+ return nullptr;
}
/*
struct lttng_consumer_channel *channel;
int ret;
- if (ht == NULL) {
+ if (ht == nullptr) {
return;
}
{
int ret, i, pollfd, err = -1;
uint32_t revents, nb_fd;
- struct lttng_consumer_channel *chan = NULL;
+ struct lttng_consumer_channel *chan = nullptr;
struct lttng_ht_iter iter;
struct lttng_ht_node_u64 *node;
struct lttng_poll_event events;
/* Main loop */
DBG("Channel main loop started");
- while (1) {
+ while (true) {
restart:
health_code_update();
DBG("Channel poll wait");
}
health_unregister(health_consumerd);
rcu_unregister_thread();
- return NULL;
+ return nullptr;
}
static int set_metadata_socket(struct lttng_consumer_local_data *ctx,
consumer_sockpoll[1].fd = sock;
consumer_sockpoll[1].events = POLLIN | POLLPRI;
- while (1) {
+ while (true) {
health_code_update();
health_poll_entry();
*/
notify_thread_lttng_pipe(ctx->consumer_data_pipe);
- notify_channel_pipe(ctx, NULL, -1, CONSUMER_CHANNEL_QUIT);
+ notify_channel_pipe(ctx, nullptr, -1, CONSUMER_CHANNEL_QUIT);
notify_health_quit_pipe(health_quit_pipe);
health_unregister(health_consumerd);
rcu_unregister_thread();
- return NULL;
+ return nullptr;
}
static int post_consume(struct lttng_consumer_stream *stream,
/*
* Allocate and set consumer data hash tables.
*/
-int lttng_consumer_init(void)
+int lttng_consumer_init()
{
the_consumer_data.channel_ht = lttng_ht_new(0, LTTNG_HT_TYPE_U64);
if (!the_consumer_data.channel_ht) {
{
int fd = -1, ret = -1, relayd_created = 0;
enum lttcomm_return_code ret_code = LTTCOMM_CONSUMERD_SUCCESS;
- struct consumer_relayd_sock_pair *relayd = NULL;
+ struct consumer_relayd_sock_pair *relayd = nullptr;
LTTNG_ASSERT(ctx);
LTTNG_ASSERT(sock >= 0);
/* Get relayd reference if exists. */
relayd = consumer_find_relayd(net_seq_idx);
- if (relayd == NULL) {
+ if (relayd == nullptr) {
LTTNG_ASSERT(sock_type == LTTNG_STREAM_CONTROL);
/* Not found. Allocate one. */
relayd = consumer_allocate_relayd_sock_pair(net_seq_idx);
- if (relayd == NULL) {
+ if (relayd == nullptr) {
ret_code = LTTCOMM_CONSUMERD_ENOMEM;
goto error;
} else {
static struct consumer_relayd_sock_pair *find_relayd_by_session_id(uint64_t id)
{
struct lttng_ht_iter iter;
- struct consumer_relayd_sock_pair *relayd = NULL;
+ struct consumer_relayd_sock_pair *relayd = nullptr;
ASSERT_RCU_READ_LOCKED();
}
}
- return NULL;
+ return nullptr;
found:
return relayd;
struct lttng_ht_iter iter;
struct lttng_ht *ht;
struct lttng_consumer_stream *stream;
- struct consumer_relayd_sock_pair *relayd = NULL;
+ struct consumer_relayd_sock_pair *relayd = nullptr;
int (*data_pending)(struct lttng_consumer_stream *);
DBG("Consumer data pending command on session id %" PRIu64, id);
uint64_t next_chunk_id, stream_count = 0;
enum lttng_trace_chunk_status chunk_status;
const bool is_local_trace = relayd_id == -1ULL;
- struct consumer_relayd_sock_pair *relayd = NULL;
+ struct consumer_relayd_sock_pair *relayd = nullptr;
bool rotating_to_new_chunk = true;
/* Array of `struct lttng_consumer_stream *` */
struct lttng_dynamic_pointer_array streams_packet_to_open;
DBG("Consumer sample rotate position for channel %" PRIu64, key);
- lttng_dynamic_array_init(
- &stream_rotation_positions, sizeof(struct relayd_stream_rotation_position), NULL);
- lttng_dynamic_pointer_array_init(&streams_packet_to_open, NULL);
+ lttng_dynamic_array_init(&stream_rotation_positions,
+ sizeof(struct relayd_stream_rotation_position),
+ nullptr);
+ lttng_dynamic_pointer_array_init(&streams_packet_to_open, nullptr);
rcu_read_lock();
chunk_status = lttng_trace_chunk_get_name(
stream->trace_chunk,
&trace_chunk_name,
- NULL);
+ nullptr);
if (chunk_status == LTTNG_TRACE_CHUNK_STATUS_NONE) {
trace_chunk_name = "none";
}
pthread_mutex_unlock(&stream->lock);
}
- stream = NULL;
+ stream = nullptr;
if (!is_local_trace) {
relayd = consumer_find_relayd(relayd_id);
pthread_mutex_lock(&relayd->ctrl_sock_mutex);
ret = relayd_rotate_streams(&relayd->control_sock,
stream_count,
- rotating_to_new_chunk ? &next_chunk_id : NULL,
+ rotating_to_new_chunk ? &next_chunk_id : nullptr,
(const struct relayd_stream_rotation_position *)
stream_rotation_positions.buffer.data);
pthread_mutex_unlock(&relayd->ctrl_sock_mutex);
{
int ret;
- ret = consumer_stream_flush_buffer(stream, 1);
+ ret = consumer_stream_flush_buffer(stream, true);
if (ret < 0) {
ERR("Failed to flush stream %" PRIu64 " during channel clear", stream->key);
ret = LTTCOMM_CONSUMERD_FATAL;
if (stream->index_file) {
lttng_index_file_put(stream->index_file);
- stream->index_file = NULL;
+ stream->index_file = nullptr;
}
if (!stream->trace_chunk) {
* parent channel, becomes part of no chunk and can't output
* anything until a new trace chunk is created.
*/
- stream->trace_chunk = NULL;
+ stream->trace_chunk = nullptr;
} else if (stream->chan->trace_chunk && !lttng_trace_chunk_get(stream->chan->trace_chunk)) {
ERR("Failed to acquire a reference to channel's trace chunk during stream rotation");
ret = -1;
{
int ret;
enum lttcomm_return_code ret_code = LTTCOMM_CONSUMERD_SUCCESS;
- struct lttng_trace_chunk *created_chunk = NULL, *published_chunk = NULL;
+ struct lttng_trace_chunk *created_chunk = nullptr, *published_chunk = nullptr;
enum lttng_trace_chunk_status chunk_status;
char relayd_id_buffer[MAX_INT_DEC_LEN(*relayd_id)];
char creation_timestamp_buffer[ISO8601_STR_LEN];
* the session daemon through the LTTNG_CONSUMER_CREATE_TRACE_CHUNK
* and LTTNG_CONSUMER_DESTROY_TRACE_CHUNK commands.
*/
- created_chunk = lttng_trace_chunk_create(chunk_id, chunk_creation_timestamp, NULL);
+ created_chunk = lttng_trace_chunk_create(chunk_id, chunk_creation_timestamp, nullptr);
if (!created_chunk) {
ERR("Failed to create trace chunk");
ret_code = LTTCOMM_CONSUMERD_CREATE_TRACE_CHUNK_FAILED;
* directory.
*/
chunk_status = lttng_trace_chunk_set_as_user(created_chunk, chunk_directory_handle);
- chunk_directory_handle = NULL;
+ chunk_directory_handle = nullptr;
if (chunk_status != LTTNG_TRACE_CHUNK_STATUS_OK) {
ERR("Failed to set trace chunk's directory handle");
ret_code = LTTCOMM_CONSUMERD_CREATE_TRACE_CHUNK_FAILED;
published_chunk = lttng_trace_chunk_registry_publish_chunk(
the_consumer_data.chunk_registry, session_id, created_chunk);
lttng_trace_chunk_put(created_chunk);
- created_chunk = NULL;
+ created_chunk = nullptr;
if (!published_chunk) {
ERR("Failed to publish trace chunk");
ret_code = LTTCOMM_CONSUMERD_CREATE_TRACE_CHUNK_FAILED;
session_id,
chunk_id,
chunk_creation_timestamp,
- NULL,
+ nullptr,
path);
if (close_ret != LTTCOMM_CONSUMERD_SUCCESS) {
ERR("Failed to roll-back the creation of new chunk: session_id = %" PRIu64
session_id,
chunk_id,
chunk_creation_timestamp,
- NULL,
+ nullptr,
path);
if (close_ret != LTTCOMM_CONSUMERD_SUCCESS) {
ERR("Failed to roll-back the creation of new chunk: session_id = %" PRIu64
if (channel->trace_chunk != chunk) {
continue;
}
- ret = lttng_consumer_channel_set_trace_chunk(channel, NULL);
+ ret = lttng_consumer_channel_set_trace_chunk(channel, nullptr);
if (ret) {
/*
* Attempt to close the chunk on as many channels as
char relayd_id_buffer[MAX_INT_DEC_LEN(*relayd_id)];
const char *relayd_id_str = "(none)";
const bool is_local_trace = !relayd_id;
- struct consumer_relayd_sock_pair *relayd = NULL;
+ struct consumer_relayd_sock_pair *relayd = nullptr;
bool chunk_exists_local, chunk_exists_remote;
if (relayd_id) {
/*
* Init consumer data structures.
*/
-int lttng_consumer_init(void);
+int lttng_consumer_init();
/*
* Set the error socket for communication with a session daemon.
/*
* Cleanup the daemon's socket on exit.
*/
-void lttng_consumer_cleanup(void);
+void lttng_consumer_cleanup();
/*
* Poll on the should_quit pipe and the command socket return -1 on error and
int parse_application_context(const char *str, char **out_provider_name, char **out_ctx_name)
{
const char app_ctx_prefix[] = "$app.";
- char *provider_name = NULL, *ctx_name = NULL;
+ char *provider_name = nullptr, *ctx_name = nullptr;
size_t i, len, colon_pos = 0, provider_name_len, ctx_name_len;
if (!str || !out_provider_name || !out_ctx_name) {
static int pthread_attr_init_done;
static pthread_attr_t tattr;
-static size_t get_page_size(void)
+static size_t get_page_size()
{
const long ret = sysconf(_SC_PAGE_SIZE);
return (size_t) ret;
}
-size_t default_get_channel_subbuf_size(void)
+size_t default_get_channel_subbuf_size()
{
return std::max<size_t>(_DEFAULT_CHANNEL_SUBBUF_SIZE, get_page_size());
}
-size_t default_get_metadata_subbuf_size(void)
+size_t default_get_metadata_subbuf_size()
{
return std::max<size_t>(DEFAULT_METADATA_SUBBUF_SIZE, get_page_size());
}
-size_t default_get_kernel_channel_subbuf_size(void)
+size_t default_get_kernel_channel_subbuf_size()
{
return std::max<size_t>(DEFAULT_KERNEL_CHANNEL_SUBBUF_SIZE, get_page_size());
}
-size_t default_get_ust_pid_channel_subbuf_size(void)
+size_t default_get_ust_pid_channel_subbuf_size()
{
return std::max<size_t>(DEFAULT_UST_PID_CHANNEL_SUBBUF_SIZE, get_page_size());
}
-size_t default_get_ust_uid_channel_subbuf_size(void)
+size_t default_get_ust_uid_channel_subbuf_size()
{
return std::max<size_t>(DEFAULT_UST_UID_CHANNEL_SUBBUF_SIZE, get_page_size());
}
-pthread_attr_t *default_pthread_attr(void)
+pthread_attr_t *default_pthread_attr()
{
if (pthread_attr_init_done) {
return &tattr;
}
WARN("Uninitialized pthread attributes, using libc defaults.");
- return NULL;
+ return nullptr;
}
-static void __attribute__((constructor)) init_default_pthread_attr(void)
+static void __attribute__((constructor)) init_default_pthread_attr()
{
int ret;
struct rlimit rlim;
}
}
-static void __attribute__((destructor)) fini_default_pthread_attr(void)
+static void __attribute__((destructor)) fini_default_pthread_attr()
{
int ret;
* This function depends on a value that is set at constructor time, so it is
* unsafe to call it from another constructor.
*/
-size_t default_get_channel_subbuf_size(void);
+size_t default_get_channel_subbuf_size();
/*
* Returns the default metadata subbuf size.
* This function depends on a value that is set at constructor time, so it is
* unsafe to call it from another constructor.
*/
-size_t default_get_metadata_subbuf_size(void);
+size_t default_get_metadata_subbuf_size();
/*
* Returns the default subbuf size for the kernel domain.
* This function depends on a value that is set at constructor time, so it is
* unsafe to call it from another constructor.
*/
-size_t default_get_kernel_channel_subbuf_size(void);
+size_t default_get_kernel_channel_subbuf_size();
/*
* Returns the default subbuf size for the UST domain per PID.
* This function depends on a value that is set at constructor time, so it is
* unsafe to call it from another constructor.
*/
-size_t default_get_ust_pid_channel_subbuf_size(void);
+size_t default_get_ust_pid_channel_subbuf_size();
/*
* Returns the default subbuf size for the UST domain per UID.
* This function depends on a value that is set at constructor time, so it is
* unsafe to call it from another constructor.
*/
-size_t default_get_ust_uid_channel_subbuf_size(void);
+size_t default_get_ust_uid_channel_subbuf_size();
/*
* Get the default pthread_attr to use on thread creation.
* pthread_attr_t pointer where the thread stack size is set to the soft stack
* size limit.
*/
-pthread_attr_t *default_pthread_attr(void);
+pthread_attr_t *default_pthread_attr();
#endif /* _DEFAULTS_H */
* Prevent the destructor from being used by the underlying
* dynamic array.
*/
- array->array.destructor = NULL;
+ array->array.destructor = nullptr;
if (destructor) {
destructor(lttng_dynamic_pointer_array_get_pointer(array, index));
}
* Prevent the destructor from being used by the underlying
* dynamic array.
*/
- array->array.destructor = NULL;
+ array->array.destructor = nullptr;
}
lttng_dynamic_array_reset(&array->array);
}
* Prevent the destructor from being used by the underlying
* dynamic array.
*/
- array->array.destructor = NULL;
+ array->array.destructor = nullptr;
if (destructor) {
size_t i, count = lttng_dynamic_pointer_array_get_count(array);
void **p_element = (void **) lttng_dynamic_array_get_element(&array->array, index);
void *element = *p_element;
- *p_element = NULL;
+ *p_element = nullptr;
return element;
}
buffer->size = 0;
buffer->_capacity = 0;
free(buffer->data);
- buffer->data = NULL;
+ buffer->data = nullptr;
}
size_t lttng_dynamic_buffer_get_capacity_left(struct lttng_dynamic_buffer *buffer)
struct lttng_error_query *lttng_error_query_trigger_create(const struct lttng_trigger *trigger)
{
- struct lttng_error_query_trigger *query = NULL;
- struct lttng_trigger *trigger_copy = NULL;
+ struct lttng_error_query_trigger *query = nullptr;
+ struct lttng_trigger *trigger_copy = nullptr;
if (!trigger) {
goto end;
query->parent.target_type = LTTNG_ERROR_QUERY_TARGET_TYPE_TRIGGER;
query->trigger = trigger_copy;
- trigger_copy = NULL;
+ trigger_copy = nullptr;
error:
lttng_trigger_put(trigger_copy);
end:
- return query ? &query->parent : NULL;
+ return query ? &query->parent : nullptr;
}
struct lttng_error_query *lttng_error_query_condition_create(const struct lttng_trigger *trigger)
{
- struct lttng_error_query_condition *query = NULL;
- struct lttng_trigger *trigger_copy = NULL;
+ struct lttng_error_query_condition *query = nullptr;
+ struct lttng_trigger *trigger_copy = nullptr;
if (!trigger) {
goto end;
query->parent.target_type = LTTNG_ERROR_QUERY_TARGET_TYPE_CONDITION;
query->trigger = trigger_copy;
- trigger_copy = NULL;
+ trigger_copy = nullptr;
error:
lttng_trigger_put(trigger_copy);
end:
- return query ? &query->parent : NULL;
+ return query ? &query->parent : nullptr;
}
static struct lttng_action *
{
size_t index_count, i;
enum lttng_action_path_status path_status;
- struct lttng_action *current_action = NULL;
+ struct lttng_action *current_action = nullptr;
path_status = lttng_action_path_get_index_count(action_path, &index_count);
if (path_status != LTTNG_ACTION_PATH_STATUS_OK) {
lttng_error_query_action_create(const struct lttng_trigger *trigger,
const struct lttng_action_path *action_path)
{
- struct lttng_error_query_action *query = NULL;
- struct lttng_trigger *trigger_copy = NULL;
+ struct lttng_error_query_action *query = nullptr;
+ struct lttng_trigger *trigger_copy = nullptr;
int ret_copy;
if (!trigger || !action_path || !is_valid_action_path(trigger, action_path)) {
query->parent.target_type = LTTNG_ERROR_QUERY_TARGET_TYPE_ACTION;
query->trigger = trigger_copy;
- trigger_copy = NULL;
+ trigger_copy = nullptr;
goto end;
error:
lttng_trigger_put(trigger_copy);
- lttng_error_query_destroy(query ? &query->parent : NULL);
+ lttng_error_query_destroy(query ? &query->parent : nullptr);
end:
- return query ? &query->parent : NULL;
+ return query ? &query->parent : nullptr;
}
void lttng_error_query_destroy(struct lttng_error_query *query)
error:
lttng_error_query_result_destroy(&counter->parent);
end:
- return counter ? &counter->parent : NULL;
+ return counter ? &counter->parent : nullptr;
}
static void destroy_result(void *ptr)
lttng_error_query_result_destroy(result);
}
-struct lttng_error_query_results *lttng_error_query_results_create(void)
+struct lttng_error_query_results *lttng_error_query_results_create()
{
struct lttng_error_query_results *set = zmalloc<lttng_error_query_results>();
struct lttng_error_query_results_comm *header;
struct lttng_payload_view header_view =
lttng_payload_view_from_view(view, 0, sizeof(*header));
- struct lttng_error_query_results *results = NULL;
+ struct lttng_error_query_results *results = nullptr;
if (!lttng_payload_view_is_valid(&header_view)) {
ERR("Failed to map view to error query result set header");
}
*_results = results;
- results = NULL;
+ results = nullptr;
end:
lttng_error_query_results_destroy(results);
return total_used_size;
{
ssize_t used_size = 0;
struct lttng_error_query_comm *header;
- struct lttng_trigger *trigger = NULL;
+ struct lttng_trigger *trigger = nullptr;
struct lttng_payload_view header_view =
lttng_payload_view_from_view(view, 0, sizeof(*header));
}
case LTTNG_ERROR_QUERY_TARGET_TYPE_ACTION:
{
- struct lttng_action_path *action_path = NULL;
+ struct lttng_action_path *action_path = nullptr;
{
ssize_t trigger_used_size;
enum lttng_error_code ret_code;
enum lttng_error_query_result_status result_status;
enum lttng_error_query_result_type type;
- const char *name = NULL;
- const char *description = NULL;
+ const char *name = nullptr;
+ const char *description = nullptr;
LTTNG_ASSERT(result);
LTTNG_ASSERT(writer);
DEFINE_URCU_TLS(struct log_time, error_log_time);
DEFINE_URCU_TLS(const char *, logger_thread_name);
-const char *log_add_time(void)
+const char *log_add_time()
{
int ret;
struct tm tm, *res;
* the caller. On error, an empty string is returned thus no time will be
* printed in the log.
*/
-const char *log_add_time(void);
+const char *log_add_time();
/* Name must be a statically-allocated string. */
void logger_set_thread_name(const char *name, bool set_pthread_name);
if (expr) {
lttng_event_expr_destroy(&expr->parent);
}
- expr = NULL;
+ expr = nullptr;
end:
return expr;
struct lttng_event_expr *lttng_event_expr_event_payload_field_create(const char *field_name)
{
- struct lttng_event_expr *expr = NULL;
+ struct lttng_event_expr *expr = nullptr;
if (!field_name) {
goto end;
struct lttng_event_expr *lttng_event_expr_channel_context_field_create(const char *field_name)
{
- struct lttng_event_expr *expr = NULL;
+ struct lttng_event_expr *expr = nullptr;
if (!field_name) {
goto end;
struct lttng_event_expr *
lttng_event_expr_app_specific_context_field_create(const char *provider_name, const char *type_name)
{
- struct lttng_event_expr_app_specific_context_field *expr = NULL;
+ struct lttng_event_expr_app_specific_context_field *expr = nullptr;
struct lttng_event_expr *ret_parent_expr;
if (!type_name || !provider_name) {
if (expr) {
lttng_event_expr_destroy(&expr->parent);
}
- ret_parent_expr = NULL;
+ ret_parent_expr = nullptr;
end:
return ret_parent_expr;
lttng_event_expr_array_field_element_create(struct lttng_event_expr *array_field_expr,
unsigned int index)
{
- struct lttng_event_expr_array_field_element *expr = NULL;
+ struct lttng_event_expr_array_field_element *expr = nullptr;
struct lttng_event_expr *ret_parent_expr;
/* The parent array field expression must be an l-value */
goto end;
error:
- ret_parent_expr = NULL;
+ ret_parent_expr = nullptr;
end:
return ret_parent_expr;
const char *lttng_event_expr_event_payload_field_get_name(const struct lttng_event_expr *expr)
{
- const char *ret = NULL;
+ const char *ret = nullptr;
if (!expr || expr->type != LTTNG_EVENT_EXPR_TYPE_EVENT_PAYLOAD_FIELD) {
goto end;
const char *lttng_event_expr_channel_context_field_get_name(const struct lttng_event_expr *expr)
{
- const char *ret = NULL;
+ const char *ret = nullptr;
if (!expr || expr->type != LTTNG_EVENT_EXPR_TYPE_CHANNEL_CONTEXT_FIELD) {
goto end;
const char *
lttng_event_expr_app_specific_context_field_get_provider_name(const struct lttng_event_expr *expr)
{
- const char *ret = NULL;
+ const char *ret = nullptr;
if (!expr || expr->type != LTTNG_EVENT_EXPR_TYPE_APP_SPECIFIC_CONTEXT_FIELD) {
goto end;
const char *
lttng_event_expr_app_specific_context_field_get_type_name(const struct lttng_event_expr *expr)
{
- const char *ret = NULL;
+ const char *ret = nullptr;
if (!expr || expr->type != LTTNG_EVENT_EXPR_TYPE_APP_SPECIFIC_CONTEXT_FIELD) {
goto end;
const struct lttng_event_expr *
lttng_event_expr_array_field_element_get_parent_expr(const struct lttng_event_expr *expr)
{
- const struct lttng_event_expr *ret = NULL;
+ const struct lttng_event_expr *ret = nullptr;
if (!expr || expr->type != LTTNG_EVENT_EXPR_TYPE_ARRAY_FIELD_ELEMENT) {
goto end;
case LTTNG_EVENT_EXPR_TYPE_APP_SPECIFIC_CONTEXT_FIELD:
{
int ret;
- char *name = NULL;
+ char *name = nullptr;
const char *provider_name, *type_name;
status = bytecode_push_get_app_context_root(bytecode);
{
int status;
struct return_op ret_insn;
- struct lttng_bytecode_alloc *bytecode = NULL;
- struct lttng_bytecode_alloc *bytecode_reloc = NULL;
+ struct lttng_bytecode_alloc *bytecode = nullptr;
+ struct lttng_bytecode_alloc *bytecode_reloc = nullptr;
status = bytecode_init(&bytecode);
if (status) {
{
int ret;
enum lttng_error_code ret_code;
- const char *name = NULL;
+ const char *name = nullptr;
LTTNG_ASSERT(expression);
LTTNG_ASSERT(writer);
{
int ret;
enum lttng_error_code ret_code;
- const char *name = NULL;
+ const char *name = nullptr;
LTTNG_ASSERT(expression);
LTTNG_ASSERT(writer);
{
int ret;
enum lttng_error_code ret_code;
- const char *provider_name = NULL;
- const char *type_name = NULL;
+ const char *provider_name = nullptr;
+ const char *type_name = nullptr;
LTTNG_ASSERT(expression);
LTTNG_ASSERT(writer);
int ret;
enum lttng_error_code ret_code;
enum lttng_event_expr_status status;
- const struct lttng_event_expr *parent_expr = NULL;
+ const struct lttng_event_expr *parent_expr = nullptr;
unsigned int index;
LTTNG_ASSERT(expression);
LTTNG_ASSERT(status == LTTNG_EVENT_EXPR_STATUS_OK);
parent_expr = lttng_event_expr_array_field_element_get_parent_expr(expression);
- LTTNG_ASSERT(parent_expr != NULL);
+ LTTNG_ASSERT(parent_expr != nullptr);
/* Open event expr array field element. */
ret = mi_lttng_writer_open_element(writer, mi_lttng_element_event_expr_array_field_element);
lttng_event_field_value_destroy((lttng_event_field_value *) field_val);
}
-struct lttng_event_field_value *lttng_event_field_value_array_create(void)
+struct lttng_event_field_value *lttng_event_field_value_array_create()
{
struct lttng_event_field_value_array *field_val = lttng::utils::container_of(
create_empty_field_val(LTTNG_EVENT_FIELD_VALUE_TYPE_ARRAY, sizeof(*field_val)),
->labels,
new_label);
if (ret == 0) {
- new_label = NULL;
+ new_label = nullptr;
}
end:
return lttng_dynamic_pointer_array_add_pointer(
<tng::utils::container_of(array_field_val, <tng_event_field_value_array::parent)
->elems,
- NULL);
+ nullptr);
}
enum lttng_event_field_value_type
const struct lttng_event_field_value_enum *enum_field_val;
if (!field_val || !is_enum_field_val(field_val)) {
- ret = NULL;
+ ret = nullptr;
goto end;
}
lttng::utils::container_of(field_val, <tng_event_field_value_enum::parent);
if (index >= lttng_dynamic_pointer_array_get_count(&enum_field_val->labels)) {
- ret = NULL;
+ ret = nullptr;
goto end;
}
struct lttng_event_rule **event_rule)
{
ssize_t ret, consumed = 0;
- event_rule_create_from_payload_cb create_from_payload = NULL;
+ event_rule_create_from_payload_cb create_from_payload = nullptr;
const struct lttng_event_rule_comm *event_rule_comm;
const struct lttng_payload_view event_rule_comm_view =
lttng_payload_view_from_view(view, 0, sizeof(*event_rule_comm));
{
struct lttng_event_rule_jul_logging *jul_logging;
- if (rule == NULL) {
+ if (rule == nullptr) {
return;
}
pattern_len = strlen(jul_logging->pattern) + 1;
- if (jul_logging->filter_expression != NULL) {
+ if (jul_logging->filter_expression != nullptr) {
filter_expression_len = strlen(jul_logging->filter_expression) + 1;
} else {
filter_expression_len = 0;
{
int err;
int ret = 0;
- char *agent_filter = NULL;
+ char *agent_filter = nullptr;
const char *pattern;
const char *filter;
- const struct lttng_log_level_rule *log_level_rule = NULL;
+ const struct lttng_log_level_rule *log_level_rule = nullptr;
enum lttng_event_rule_status status;
LTTNG_ASSERT(rule);
status = lttng_event_rule_jul_logging_get_filter(rule, &filter);
if (status == LTTNG_EVENT_RULE_STATUS_UNSET) {
- filter = NULL;
+ filter = nullptr;
} else if (status != LTTNG_EVENT_RULE_STATUS_OK) {
ret = -1;
goto end;
}
*_agent_filter = agent_filter;
- agent_filter = NULL;
+ agent_filter = nullptr;
end:
free(agent_filter);
struct lttng_event_rule_jul_logging *jul_logging;
enum lttng_event_rule_status status;
const char *filter;
- struct lttng_bytecode *bytecode = NULL;
+ struct lttng_bytecode *bytecode = nullptr;
char *agent_filter;
LTTNG_ASSERT(rule);
status = lttng_event_rule_jul_logging_get_filter(rule, &filter);
if (status == LTTNG_EVENT_RULE_STATUS_UNSET) {
- filter = NULL;
+ filter = nullptr;
} else if (status != LTTNG_EVENT_RULE_STATUS_OK) {
ret_code = LTTNG_ERR_FILTER_INVAL;
goto end;
jul_logging->internal_filter.filter = agent_filter;
- if (jul_logging->internal_filter.filter == NULL) {
+ if (jul_logging->internal_filter.filter == nullptr) {
ret_code = LTTNG_OK;
goto end;
}
}
jul_logging->internal_filter.bytecode = bytecode;
- bytecode = NULL;
+ bytecode = nullptr;
ret_code = LTTNG_OK;
error:
struct lttng_event_exclusion **_exclusions)
{
/* Unsupported. */
- *_exclusions = NULL;
+ *_exclusions = nullptr;
return LTTNG_EVENT_RULE_GENERATE_EXCLUSIONS_STATUS_NONE;
}
{
int ret;
const struct lttng_event_rule_jul_logging *jul_logging;
- struct lttng_event *local_event = NULL;
- struct lttng_event *event = NULL;
+ struct lttng_event *local_event = nullptr;
+ struct lttng_event *event = nullptr;
enum lttng_loglevel_type loglevel_type;
int loglevel_value = 0;
enum lttng_event_rule_status status;
local_event->loglevel = loglevel_value;
event = local_event;
- local_event = NULL;
+ local_event = nullptr;
error:
free(local_event);
return event;
enum lttng_error_code ret_code;
enum lttng_event_rule_status status;
- const char *filter = NULL;
- const char *name_pattern = NULL;
- const struct lttng_log_level_rule *log_level_rule = NULL;
+ const char *filter = nullptr;
+ const char *name_pattern = nullptr;
+ const struct lttng_log_level_rule *log_level_rule = nullptr;
LTTNG_ASSERT(rule);
LTTNG_ASSERT(writer);
}
/* Filter expression. */
- if (filter != NULL) {
+ if (filter != nullptr) {
ret = mi_lttng_writer_write_element_string(
writer, mi_lttng_element_event_rule_filter_expression, filter);
if (ret) {
struct lttng_event_rule *lttng_event_rule_jul_logging_create(void)
{
- struct lttng_event_rule *rule = NULL;
+ struct lttng_event_rule *rule = nullptr;
struct lttng_event_rule_jul_logging *tp_rule;
enum lttng_event_rule_status status;
tp_rule->parent.generate_lttng_event = lttng_event_rule_jul_logging_generate_lttng_event;
tp_rule->parent.mi_serialize = lttng_event_rule_jul_logging_mi_serialize;
- tp_rule->log_level_rule = NULL;
+ tp_rule->log_level_rule = nullptr;
/* Default pattern is '*'. */
status = lttng_event_rule_jul_logging_set_name_pattern(rule, "*");
if (status != LTTNG_EVENT_RULE_STATUS_OK) {
lttng_event_rule_destroy(rule);
- rule = NULL;
+ rule = nullptr;
}
end:
enum lttng_event_rule_status status;
const struct lttng_event_rule_jul_logging_comm *jul_logging_comm;
const char *pattern;
- const char *filter_expression = NULL;
+ const char *filter_expression = nullptr;
struct lttng_buffer_view current_buffer_view;
- struct lttng_event_rule *rule = NULL;
- struct lttng_log_level_rule *log_level_rule = NULL;
+ struct lttng_event_rule *rule = nullptr;
+ struct lttng_log_level_rule *log_level_rule = nullptr;
if (!_event_rule) {
ret = -1;
}
*_event_rule = rule;
- rule = NULL;
+ rule = nullptr;
ret = offset;
end:
lttng_log_level_rule_destroy(log_level_rule);
enum lttng_event_rule_status
lttng_event_rule_jul_logging_set_name_pattern(struct lttng_event_rule *rule, const char *pattern)
{
- char *pattern_copy = NULL;
+ char *pattern_copy = nullptr;
struct lttng_event_rule_jul_logging *jul_logging;
enum lttng_event_rule_status status = LTTNG_EVENT_RULE_STATUS_OK;
free(jul_logging->pattern);
jul_logging->pattern = pattern_copy;
- pattern_copy = NULL;
+ pattern_copy = nullptr;
end:
return status;
}
enum lttng_event_rule_status lttng_event_rule_jul_logging_set_filter(struct lttng_event_rule *rule,
const char *expression)
{
- char *expression_copy = NULL;
+ char *expression_copy = nullptr;
struct lttng_event_rule_jul_logging *jul_logging;
enum lttng_event_rule_status status = LTTNG_EVENT_RULE_STATUS_OK;
}
jul_logging->filter_expression = expression_copy;
- expression_copy = NULL;
+ expression_copy = nullptr;
end:
return status;
}
{
struct lttng_event_rule_jul_logging *jul_logging;
enum lttng_event_rule_status status = LTTNG_EVENT_RULE_STATUS_OK;
- struct lttng_log_level_rule *copy = NULL;
+ struct lttng_log_level_rule *copy = nullptr;
if (!rule || !IS_JUL_LOGGING_EVENT_RULE(rule)) {
status = LTTNG_EVENT_RULE_STATUS_INVALID;
}
copy = lttng_log_level_rule_copy(log_level_rule);
- if (copy == NULL) {
+ if (copy == nullptr) {
status = LTTNG_EVENT_RULE_STATUS_ERROR;
goto end;
}
}
jul_logging = lttng::utils::container_of(rule, <tng_event_rule_jul_logging::parent);
- if (jul_logging->log_level_rule == NULL) {
+ if (jul_logging->log_level_rule == nullptr) {
status = LTTNG_EVENT_RULE_STATUS_UNSET;
goto end;
}
__attribute__((unused)))
{
/* Not supported. */
- return NULL;
+ return nullptr;
}
static const struct lttng_bytecode *
__attribute__((unused)))
{
/* Not supported. */
- return NULL;
+ return nullptr;
}
static enum lttng_event_rule_generate_exclusions_status
struct lttng_event_exclusion **exclusions)
{
/* Not supported. */
- *exclusions = NULL;
+ *exclusions = nullptr;
return LTTNG_EVENT_RULE_GENERATE_EXCLUSIONS_STATUS_NONE;
}
const struct lttng_kernel_probe_location *location)
{
int ret;
- struct lttng_kernel_probe_location *location_copy = NULL;
+ struct lttng_kernel_probe_location *location_copy = nullptr;
if (!kprobe || !location || kprobe->location) {
ret = -1;
}
kprobe->location = location_copy;
- location_copy = NULL;
+ location_copy = nullptr;
ret = 0;
end:
lttng_kernel_probe_location_destroy(location_copy);
int ret;
enum lttng_error_code ret_code;
enum lttng_event_rule_status status;
- const char *event_name = NULL;
- const struct lttng_kernel_probe_location *location = NULL;
+ const char *event_name = nullptr;
+ const struct lttng_kernel_probe_location *location = nullptr;
LTTNG_ASSERT(rule);
LTTNG_ASSERT(writer);
struct lttng_event_rule *
lttng_event_rule_kernel_kprobe_create(const struct lttng_kernel_probe_location *location)
{
- struct lttng_event_rule *rule = NULL;
+ struct lttng_event_rule *rule = nullptr;
struct lttng_event_rule_kernel_kprobe *krule;
krule = zmalloc<lttng_event_rule_kernel_kprobe>();
if (kernel_probe_set_location(krule, location)) {
lttng_event_rule_destroy(rule);
- rule = NULL;
+ rule = nullptr;
}
end:
const struct lttng_event_rule_kernel_kprobe_comm *kprobe_comm;
const char *name;
struct lttng_buffer_view current_buffer_view;
- struct lttng_event_rule *rule = NULL;
- struct lttng_kernel_probe_location *location = NULL;
+ struct lttng_event_rule *rule = nullptr;
+ struct lttng_kernel_probe_location *location = nullptr;
if (!_event_rule) {
ret = -1;
}
*_event_rule = rule;
- rule = NULL;
+ rule = nullptr;
ret = offset;
end:
lttng_kernel_probe_location_destroy(location);
enum lttng_event_rule_status
lttng_event_rule_kernel_kprobe_set_event_name(struct lttng_event_rule *rule, const char *name)
{
- char *name_copy = NULL;
+ char *name_copy = nullptr;
struct lttng_event_rule_kernel_kprobe *kprobe;
enum lttng_event_rule_status status = LTTNG_EVENT_RULE_STATUS_OK;
free(kprobe->name);
kprobe->name = name_copy;
- name_copy = NULL;
+ name_copy = nullptr;
end:
return status;
}
{
struct lttng_event_rule_kernel_syscall *syscall;
- if (rule == NULL) {
+ if (rule == nullptr) {
return;
}
pattern_len = strlen(syscall->pattern) + 1;
- if (syscall->filter_expression != NULL) {
+ if (syscall->filter_expression != nullptr) {
filter_expression_len = strlen(syscall->filter_expression) + 1;
} else {
filter_expression_len = 0;
struct lttng_event_rule_kernel_syscall *syscall;
enum lttng_event_rule_status status;
const char *filter;
- struct lttng_bytecode *bytecode = NULL;
+ struct lttng_bytecode *bytecode = nullptr;
LTTNG_ASSERT(rule);
/* Generate the filter bytecode. */
status = lttng_event_rule_kernel_syscall_get_filter(rule, &filter);
if (status == LTTNG_EVENT_RULE_STATUS_UNSET) {
- filter = NULL;
+ filter = nullptr;
} else if (status != LTTNG_EVENT_RULE_STATUS_OK) {
ret_code = LTTNG_ERR_FILTER_INVAL;
goto end;
goto end;
}
- if (filter == NULL) {
+ if (filter == nullptr) {
/* Nothing to do. */
ret = LTTNG_OK;
goto end;
}
syscall->internal_filter.filter = strdup(filter);
- if (syscall->internal_filter.filter == NULL) {
+ if (syscall->internal_filter.filter == nullptr) {
ret_code = LTTNG_ERR_NOMEM;
goto end;
}
}
syscall->internal_filter.bytecode = bytecode;
- bytecode = NULL;
+ bytecode = nullptr;
end:
free(bytecode);
struct lttng_event_exclusion **exclusions)
{
/* Unsupported. */
- *exclusions = NULL;
+ *exclusions = nullptr;
return LTTNG_EVENT_RULE_GENERATE_EXCLUSIONS_STATUS_NONE;
}
enum lttng_event_rule_status status;
enum lttng_event_rule_kernel_syscall_emission_site site_type;
- const char *filter = NULL;
- const char *name_pattern = NULL;
- const char *site_type_str = NULL;
+ const char *filter = nullptr;
+ const char *name_pattern = nullptr;
+ const char *site_type_str = nullptr;
LTTNG_ASSERT(rule);
LTTNG_ASSERT(writer);
}
/* Filter. */
- if (filter != NULL) {
+ if (filter != nullptr) {
ret = mi_lttng_writer_write_element_string(
writer, mi_lttng_element_event_rule_filter_expression, filter);
if (ret) {
struct lttng_event_rule *lttng_event_rule_kernel_syscall_create(
enum lttng_event_rule_kernel_syscall_emission_site emission_site)
{
- struct lttng_event_rule *rule = NULL;
+ struct lttng_event_rule *rule = nullptr;
struct lttng_event_rule_kernel_syscall *syscall_rule;
enum lttng_event_rule_status status;
status = lttng_event_rule_kernel_syscall_set_name_pattern(rule, "*");
if (status != LTTNG_EVENT_RULE_STATUS_OK) {
lttng_event_rule_destroy(rule);
- rule = NULL;
+ rule = nullptr;
}
/* Emission site type */
enum lttng_event_rule_status status;
const struct lttng_event_rule_kernel_syscall_comm *syscall_comm;
const char *pattern;
- const char *filter_expression = NULL;
+ const char *filter_expression = nullptr;
struct lttng_buffer_view current_buffer_view;
- struct lttng_event_rule *rule = NULL;
+ struct lttng_event_rule *rule = nullptr;
if (!_event_rule) {
ret = -1;
}
*_event_rule = rule;
- rule = NULL;
+ rule = nullptr;
ret = offset;
end:
lttng_event_rule_destroy(rule);
enum lttng_event_rule_status
lttng_event_rule_kernel_syscall_set_name_pattern(struct lttng_event_rule *rule, const char *pattern)
{
- char *pattern_copy = NULL;
+ char *pattern_copy = nullptr;
struct lttng_event_rule_kernel_syscall *syscall;
enum lttng_event_rule_status status = LTTNG_EVENT_RULE_STATUS_OK;
free(syscall->pattern);
syscall->pattern = pattern_copy;
- pattern_copy = NULL;
+ pattern_copy = nullptr;
end:
return status;
}
enum lttng_event_rule_status
lttng_event_rule_kernel_syscall_set_filter(struct lttng_event_rule *rule, const char *expression)
{
- char *expression_copy = NULL;
+ char *expression_copy = nullptr;
struct lttng_event_rule_kernel_syscall *syscall;
enum lttng_event_rule_status status = LTTNG_EVENT_RULE_STATUS_OK;
}
syscall->filter_expression = expression_copy;
- expression_copy = NULL;
+ expression_copy = nullptr;
end:
return status;
}
{
struct lttng_event_rule_kernel_tracepoint *tracepoint;
- if (rule == NULL) {
+ if (rule == nullptr) {
return;
}
pattern_len = strlen(tracepoint->pattern) + 1;
- if (tracepoint->filter_expression != NULL) {
+ if (tracepoint->filter_expression != nullptr) {
filter_expression_len = strlen(tracepoint->filter_expression) + 1;
} else {
filter_expression_len = 0;
struct lttng_event_rule_kernel_tracepoint *tracepoint;
enum lttng_event_rule_status status;
const char *filter;
- struct lttng_bytecode *bytecode = NULL;
+ struct lttng_bytecode *bytecode = nullptr;
LTTNG_ASSERT(rule);
status = lttng_event_rule_kernel_tracepoint_get_filter(rule, &filter);
if (status == LTTNG_EVENT_RULE_STATUS_UNSET) {
- filter = NULL;
+ filter = nullptr;
} else if (status != LTTNG_EVENT_RULE_STATUS_OK) {
ret_code = LTTNG_ERR_FILTER_INVAL;
goto end;
if (filter) {
tracepoint->internal_filter.filter = strdup(filter);
- if (tracepoint->internal_filter.filter == NULL) {
+ if (tracepoint->internal_filter.filter == nullptr) {
ret_code = LTTNG_ERR_NOMEM;
goto error;
}
} else {
- tracepoint->internal_filter.filter = NULL;
+ tracepoint->internal_filter.filter = nullptr;
}
- if (tracepoint->internal_filter.filter == NULL) {
+ if (tracepoint->internal_filter.filter == nullptr) {
ret_code = LTTNG_OK;
goto end;
}
}
tracepoint->internal_filter.bytecode = bytecode;
- bytecode = NULL;
+ bytecode = nullptr;
ret_code = LTTNG_OK;
error:
struct lttng_event_exclusion **_exclusions)
{
/* Unsupported. */
- *_exclusions = NULL;
+ *_exclusions = nullptr;
return LTTNG_EVENT_RULE_GENERATE_EXCLUSIONS_STATUS_NONE;
}
int ret;
enum lttng_error_code ret_code;
enum lttng_event_rule_status status;
- const char *filter = NULL;
- const char *name_pattern = NULL;
+ const char *filter = nullptr;
+ const char *name_pattern = nullptr;
LTTNG_ASSERT(rule);
LTTNG_ASSERT(writer);
}
/* Filter. */
- if (filter != NULL) {
+ if (filter != nullptr) {
ret = mi_lttng_writer_write_element_string(
writer, mi_lttng_element_event_rule_filter_expression, filter);
if (ret) {
struct lttng_event_rule *lttng_event_rule_kernel_tracepoint_create(void)
{
- struct lttng_event_rule *rule = NULL;
+ struct lttng_event_rule *rule = nullptr;
struct lttng_event_rule_kernel_tracepoint *tp_rule;
enum lttng_event_rule_status status;
tp_rule->parent.mi_serialize = lttng_event_rule_kernel_tracepoint_mi_serialize;
/* Not necessary for now. */
- tp_rule->parent.generate_lttng_event = NULL;
+ tp_rule->parent.generate_lttng_event = nullptr;
/* Default pattern is '*'. */
status = lttng_event_rule_kernel_tracepoint_set_name_pattern(rule, "*");
if (status != LTTNG_EVENT_RULE_STATUS_OK) {
lttng_event_rule_destroy(rule);
- rule = NULL;
+ rule = nullptr;
}
end:
enum lttng_event_rule_status status;
const struct lttng_event_rule_kernel_tracepoint_comm *tracepoint_comm;
const char *pattern;
- const char *filter_expression = NULL;
+ const char *filter_expression = nullptr;
struct lttng_buffer_view current_buffer_view;
- struct lttng_event_rule *rule = NULL;
+ struct lttng_event_rule *rule = nullptr;
if (!_event_rule) {
ret = -1;
}
*_event_rule = rule;
- rule = NULL;
+ rule = nullptr;
ret = offset;
end:
lttng_event_rule_destroy(rule);
lttng_event_rule_kernel_tracepoint_set_name_pattern(struct lttng_event_rule *rule,
const char *pattern)
{
- char *pattern_copy = NULL;
+ char *pattern_copy = nullptr;
struct lttng_event_rule_kernel_tracepoint *tracepoint;
enum lttng_event_rule_status status = LTTNG_EVENT_RULE_STATUS_OK;
free(tracepoint->pattern);
tracepoint->pattern = pattern_copy;
- pattern_copy = NULL;
+ pattern_copy = nullptr;
end:
return status;
}
enum lttng_event_rule_status
lttng_event_rule_kernel_tracepoint_set_filter(struct lttng_event_rule *rule, const char *expression)
{
- char *expression_copy = NULL;
+ char *expression_copy = nullptr;
struct lttng_event_rule_kernel_tracepoint *tracepoint;
enum lttng_event_rule_status status = LTTNG_EVENT_RULE_STATUS_OK;
}
tracepoint->filter_expression = expression_copy;
- expression_copy = NULL;
+ expression_copy = nullptr;
end:
return status;
}
__attribute__((unused)))
{
/* Unsupported. */
- return NULL;
+ return nullptr;
}
static const struct lttng_bytecode *
__attribute__((unused)))
{
/* Unsupported. */
- return NULL;
+ return nullptr;
}
static enum lttng_event_rule_generate_exclusions_status
struct lttng_event_exclusion **exclusions)
{
/* Unsupported. */
- *exclusions = NULL;
+ *exclusions = nullptr;
return LTTNG_EVENT_RULE_GENERATE_EXCLUSIONS_STATUS_NONE;
}
const struct lttng_userspace_probe_location *location)
{
int ret;
- struct lttng_userspace_probe_location *location_copy = NULL;
+ struct lttng_userspace_probe_location *location_copy = nullptr;
if (!uprobe || !location || uprobe->location) {
ret = -1;
}
uprobe->location = location_copy;
- location_copy = NULL;
+ location_copy = nullptr;
ret = 0;
end:
lttng_userspace_probe_location_destroy(location_copy);
int ret;
enum lttng_error_code ret_code;
enum lttng_event_rule_status status;
- const char *event_name = NULL;
- const struct lttng_userspace_probe_location *location = NULL;
+ const char *event_name = nullptr;
+ const struct lttng_userspace_probe_location *location = nullptr;
LTTNG_ASSERT(rule);
LTTNG_ASSERT(writer);
struct lttng_event_rule *
lttng_event_rule_kernel_uprobe_create(const struct lttng_userspace_probe_location *location)
{
- struct lttng_event_rule *rule = NULL;
+ struct lttng_event_rule *rule = nullptr;
struct lttng_event_rule_kernel_uprobe *urule;
urule = zmalloc<lttng_event_rule_kernel_uprobe>();
if (userspace_probe_set_location(urule, location)) {
lttng_event_rule_destroy(rule);
- rule = NULL;
+ rule = nullptr;
}
end:
const struct lttng_event_rule_kernel_uprobe_comm *uprobe_comm;
const char *name;
struct lttng_buffer_view current_buffer_view;
- struct lttng_event_rule *rule = NULL;
- struct lttng_userspace_probe_location *location = NULL;
+ struct lttng_event_rule *rule = nullptr;
+ struct lttng_userspace_probe_location *location = nullptr;
enum lttng_event_rule_status status;
if (!_event_rule) {
}
*_event_rule = rule;
- rule = NULL;
+ rule = nullptr;
ret = offset;
end:
lttng_userspace_probe_location_destroy(location);
enum lttng_event_rule_status
lttng_event_rule_kernel_uprobe_set_event_name(struct lttng_event_rule *rule, const char *name)
{
- char *name_copy = NULL;
+ char *name_copy = nullptr;
struct lttng_event_rule_kernel_uprobe *uprobe;
enum lttng_event_rule_status status = LTTNG_EVENT_RULE_STATUS_OK;
}
uprobe->name = name_copy;
- name_copy = NULL;
+ name_copy = nullptr;
end:
return status;
}
{
struct lttng_event_rule_log4j_logging *log4j_logging;
- if (rule == NULL) {
+ if (rule == nullptr) {
return;
}
pattern_len = strlen(log4j_logging->pattern) + 1;
- if (log4j_logging->filter_expression != NULL) {
+ if (log4j_logging->filter_expression != nullptr) {
filter_expression_len = strlen(log4j_logging->filter_expression) + 1;
} else {
filter_expression_len = 0;
{
int err;
int ret = 0;
- char *agent_filter = NULL;
+ char *agent_filter = nullptr;
const char *pattern;
const char *filter;
- const struct lttng_log_level_rule *log_level_rule = NULL;
+ const struct lttng_log_level_rule *log_level_rule = nullptr;
enum lttng_event_rule_status status;
LTTNG_ASSERT(rule);
status = lttng_event_rule_log4j_logging_get_filter(rule, &filter);
if (status == LTTNG_EVENT_RULE_STATUS_UNSET) {
- filter = NULL;
+ filter = nullptr;
} else if (status != LTTNG_EVENT_RULE_STATUS_OK) {
ret = -1;
goto end;
}
*_agent_filter = agent_filter;
- agent_filter = NULL;
+ agent_filter = nullptr;
end:
free(agent_filter);
struct lttng_event_rule_log4j_logging *log4j_logging;
enum lttng_event_rule_status status;
const char *filter;
- struct lttng_bytecode *bytecode = NULL;
+ struct lttng_bytecode *bytecode = nullptr;
char *agent_filter;
LTTNG_ASSERT(rule);
status = lttng_event_rule_log4j_logging_get_filter(rule, &filter);
if (status == LTTNG_EVENT_RULE_STATUS_UNSET) {
- filter = NULL;
+ filter = nullptr;
} else if (status != LTTNG_EVENT_RULE_STATUS_OK) {
ret_code = LTTNG_ERR_FILTER_INVAL;
goto end;
log4j_logging->internal_filter.filter = agent_filter;
- if (log4j_logging->internal_filter.filter == NULL) {
+ if (log4j_logging->internal_filter.filter == nullptr) {
ret_code = LTTNG_OK;
goto end;
}
}
log4j_logging->internal_filter.bytecode = bytecode;
- bytecode = NULL;
+ bytecode = nullptr;
ret_code = LTTNG_OK;
error:
struct lttng_event_exclusion **_exclusions)
{
/* Unsupported. */
- *_exclusions = NULL;
+ *_exclusions = nullptr;
return LTTNG_EVENT_RULE_GENERATE_EXCLUSIONS_STATUS_NONE;
}
{
int ret;
const struct lttng_event_rule_log4j_logging *log4j_logging;
- struct lttng_event *local_event = NULL;
- struct lttng_event *event = NULL;
+ struct lttng_event *local_event = nullptr;
+ struct lttng_event *event = nullptr;
enum lttng_loglevel_type loglevel_type;
int loglevel_value = 0;
enum lttng_event_rule_status status;
local_event->loglevel = loglevel_value;
event = local_event;
- local_event = NULL;
+ local_event = nullptr;
error:
free(local_event);
return event;
int ret;
enum lttng_error_code ret_code;
enum lttng_event_rule_status status;
- const char *filter = NULL;
- const char *name_pattern = NULL;
- const struct lttng_log_level_rule *log_level_rule = NULL;
+ const char *filter = nullptr;
+ const char *name_pattern = nullptr;
+ const struct lttng_log_level_rule *log_level_rule = nullptr;
LTTNG_ASSERT(rule);
LTTNG_ASSERT(writer);
}
/* Filter expression. */
- if (filter != NULL) {
+ if (filter != nullptr) {
ret = mi_lttng_writer_write_element_string(
writer, mi_lttng_element_event_rule_filter_expression, filter);
if (ret) {
struct lttng_event_rule *lttng_event_rule_log4j_logging_create(void)
{
- struct lttng_event_rule *rule = NULL;
+ struct lttng_event_rule *rule = nullptr;
struct lttng_event_rule_log4j_logging *tp_rule;
enum lttng_event_rule_status status;
tp_rule->parent.generate_lttng_event = lttng_event_rule_log4j_logging_generate_lttng_event;
tp_rule->parent.mi_serialize = lttng_event_rule_log4j_logging_mi_serialize;
- tp_rule->log_level_rule = NULL;
+ tp_rule->log_level_rule = nullptr;
/* Default pattern is '*'. */
status = lttng_event_rule_log4j_logging_set_name_pattern(rule, "*");
if (status != LTTNG_EVENT_RULE_STATUS_OK) {
lttng_event_rule_destroy(rule);
- rule = NULL;
+ rule = nullptr;
}
end:
enum lttng_event_rule_status status;
const struct lttng_event_rule_log4j_logging_comm *log4j_logging_comm;
const char *pattern;
- const char *filter_expression = NULL;
+ const char *filter_expression = nullptr;
struct lttng_buffer_view current_buffer_view;
- struct lttng_event_rule *rule = NULL;
- struct lttng_log_level_rule *log_level_rule = NULL;
+ struct lttng_event_rule *rule = nullptr;
+ struct lttng_log_level_rule *log_level_rule = nullptr;
if (!_event_rule) {
ret = -1;
}
*_event_rule = rule;
- rule = NULL;
+ rule = nullptr;
ret = offset;
end:
lttng_log_level_rule_destroy(log_level_rule);
enum lttng_event_rule_status
lttng_event_rule_log4j_logging_set_name_pattern(struct lttng_event_rule *rule, const char *pattern)
{
- char *pattern_copy = NULL;
+ char *pattern_copy = nullptr;
struct lttng_event_rule_log4j_logging *log4j_logging;
enum lttng_event_rule_status status = LTTNG_EVENT_RULE_STATUS_OK;
free(log4j_logging->pattern);
log4j_logging->pattern = pattern_copy;
- pattern_copy = NULL;
+ pattern_copy = nullptr;
end:
return status;
}
enum lttng_event_rule_status
lttng_event_rule_log4j_logging_set_filter(struct lttng_event_rule *rule, const char *expression)
{
- char *expression_copy = NULL;
+ char *expression_copy = nullptr;
struct lttng_event_rule_log4j_logging *log4j_logging;
enum lttng_event_rule_status status = LTTNG_EVENT_RULE_STATUS_OK;
}
log4j_logging->filter_expression = expression_copy;
- expression_copy = NULL;
+ expression_copy = nullptr;
end:
return status;
}
{
struct lttng_event_rule_log4j_logging *log4j_logging;
enum lttng_event_rule_status status = LTTNG_EVENT_RULE_STATUS_OK;
- struct lttng_log_level_rule *copy = NULL;
+ struct lttng_log_level_rule *copy = nullptr;
if (!rule || !IS_LOG4J_LOGGING_EVENT_RULE(rule)) {
status = LTTNG_EVENT_RULE_STATUS_INVALID;
}
copy = lttng_log_level_rule_copy(log_level_rule);
- if (copy == NULL) {
+ if (copy == nullptr) {
status = LTTNG_EVENT_RULE_STATUS_ERROR;
goto end;
}
}
log4j_logging = lttng::utils::container_of(rule, <tng_event_rule_log4j_logging::parent);
- if (log4j_logging->log_level_rule == NULL) {
+ if (log4j_logging->log_level_rule == nullptr) {
status = LTTNG_EVENT_RULE_STATUS_UNSET;
goto end;
}
{
struct lttng_event_rule_python_logging *python_logging;
- if (rule == NULL) {
+ if (rule == nullptr) {
return;
}
pattern_len = strlen(python_logging->pattern) + 1;
- if (python_logging->filter_expression != NULL) {
+ if (python_logging->filter_expression != nullptr) {
filter_expression_len = strlen(python_logging->filter_expression) + 1;
} else {
filter_expression_len = 0;
{
int err;
int ret = 0;
- char *agent_filter = NULL;
+ char *agent_filter = nullptr;
const char *pattern;
const char *filter;
- const struct lttng_log_level_rule *log_level_rule = NULL;
+ const struct lttng_log_level_rule *log_level_rule = nullptr;
enum lttng_event_rule_status status;
LTTNG_ASSERT(rule);
status = lttng_event_rule_python_logging_get_filter(rule, &filter);
if (status == LTTNG_EVENT_RULE_STATUS_UNSET) {
- filter = NULL;
+ filter = nullptr;
} else if (status != LTTNG_EVENT_RULE_STATUS_OK) {
ret = -1;
goto end;
}
*_agent_filter = agent_filter;
- agent_filter = NULL;
+ agent_filter = nullptr;
end:
free(agent_filter);
struct lttng_event_rule_python_logging *python_logging;
enum lttng_event_rule_status status;
const char *filter;
- struct lttng_bytecode *bytecode = NULL;
+ struct lttng_bytecode *bytecode = nullptr;
char *agent_filter;
LTTNG_ASSERT(rule);
status = lttng_event_rule_python_logging_get_filter(rule, &filter);
if (status == LTTNG_EVENT_RULE_STATUS_UNSET) {
- filter = NULL;
+ filter = nullptr;
} else if (status != LTTNG_EVENT_RULE_STATUS_OK) {
ret_code = LTTNG_ERR_FILTER_INVAL;
goto end;
python_logging->internal_filter.filter = agent_filter;
- if (python_logging->internal_filter.filter == NULL) {
+ if (python_logging->internal_filter.filter == nullptr) {
ret_code = LTTNG_OK;
goto end;
}
}
python_logging->internal_filter.bytecode = bytecode;
- bytecode = NULL;
+ bytecode = nullptr;
ret_code = LTTNG_OK;
error:
struct lttng_event_exclusion **_exclusions)
{
/* Unsupported. */
- *_exclusions = NULL;
+ *_exclusions = nullptr;
return LTTNG_EVENT_RULE_GENERATE_EXCLUSIONS_STATUS_NONE;
}
{
int ret;
const struct lttng_event_rule_python_logging *python_logging;
- struct lttng_event *local_event = NULL;
- struct lttng_event *event = NULL;
+ struct lttng_event *local_event = nullptr;
+ struct lttng_event *event = nullptr;
enum lttng_loglevel_type loglevel_type;
int loglevel_value = 0;
enum lttng_event_rule_status status;
local_event->loglevel = loglevel_value;
event = local_event;
- local_event = NULL;
+ local_event = nullptr;
error:
free(local_event);
return event;
int ret;
enum lttng_error_code ret_code;
enum lttng_event_rule_status status;
- const char *filter = NULL;
- const char *name_pattern = NULL;
- const struct lttng_log_level_rule *log_level_rule = NULL;
+ const char *filter = nullptr;
+ const char *name_pattern = nullptr;
+ const struct lttng_log_level_rule *log_level_rule = nullptr;
LTTNG_ASSERT(rule);
LTTNG_ASSERT(writer);
}
/* Filter expression. */
- if (filter != NULL) {
+ if (filter != nullptr) {
ret = mi_lttng_writer_write_element_string(
writer, mi_lttng_element_event_rule_filter_expression, filter);
if (ret) {
struct lttng_event_rule *lttng_event_rule_python_logging_create(void)
{
- struct lttng_event_rule *rule = NULL;
+ struct lttng_event_rule *rule = nullptr;
struct lttng_event_rule_python_logging *tp_rule;
enum lttng_event_rule_status status;
tp_rule->parent.generate_lttng_event = lttng_event_rule_python_logging_generate_lttng_event;
tp_rule->parent.mi_serialize = lttng_event_rule_python_logging_mi_serialize;
- tp_rule->log_level_rule = NULL;
+ tp_rule->log_level_rule = nullptr;
/* Default pattern is '*'. */
status = lttng_event_rule_python_logging_set_name_pattern(rule, "*");
if (status != LTTNG_EVENT_RULE_STATUS_OK) {
lttng_event_rule_destroy(rule);
- rule = NULL;
+ rule = nullptr;
}
end:
enum lttng_event_rule_status status;
const struct lttng_event_rule_python_logging_comm *python_logging_comm;
const char *pattern;
- const char *filter_expression = NULL;
+ const char *filter_expression = nullptr;
struct lttng_buffer_view current_buffer_view;
- struct lttng_event_rule *rule = NULL;
- struct lttng_log_level_rule *log_level_rule = NULL;
+ struct lttng_event_rule *rule = nullptr;
+ struct lttng_log_level_rule *log_level_rule = nullptr;
if (!_event_rule) {
ret = -1;
}
*_event_rule = rule;
- rule = NULL;
+ rule = nullptr;
ret = offset;
end:
lttng_log_level_rule_destroy(log_level_rule);
enum lttng_event_rule_status
lttng_event_rule_python_logging_set_name_pattern(struct lttng_event_rule *rule, const char *pattern)
{
- char *pattern_copy = NULL;
+ char *pattern_copy = nullptr;
struct lttng_event_rule_python_logging *python_logging;
enum lttng_event_rule_status status = LTTNG_EVENT_RULE_STATUS_OK;
free(python_logging->pattern);
python_logging->pattern = pattern_copy;
- pattern_copy = NULL;
+ pattern_copy = nullptr;
end:
return status;
}
enum lttng_event_rule_status
lttng_event_rule_python_logging_set_filter(struct lttng_event_rule *rule, const char *expression)
{
- char *expression_copy = NULL;
+ char *expression_copy = nullptr;
struct lttng_event_rule_python_logging *python_logging;
enum lttng_event_rule_status status = LTTNG_EVENT_RULE_STATUS_OK;
}
python_logging->filter_expression = expression_copy;
- expression_copy = NULL;
+ expression_copy = nullptr;
end:
return status;
}
{
struct lttng_event_rule_python_logging *python_logging;
enum lttng_event_rule_status status = LTTNG_EVENT_RULE_STATUS_OK;
- struct lttng_log_level_rule *copy = NULL;
+ struct lttng_log_level_rule *copy = nullptr;
if (!rule || !IS_PYTHON_LOGGING_EVENT_RULE(rule)) {
status = LTTNG_EVENT_RULE_STATUS_INVALID;
}
copy = lttng_log_level_rule_copy(log_level_rule);
- if (copy == NULL) {
+ if (copy == nullptr) {
status = LTTNG_EVENT_RULE_STATUS_ERROR;
goto end;
}
}
python_logging = lttng::utils::container_of(rule, <tng_event_rule_python_logging::parent);
- if (python_logging->log_level_rule == NULL) {
+ if (python_logging->log_level_rule == nullptr) {
status = LTTNG_EVENT_RULE_STATUS_UNSET;
goto end;
}
{
struct lttng_event_rule_user_tracepoint *tracepoint;
- if (rule == NULL) {
+ if (rule == nullptr) {
return;
}
pattern_len = strlen(tracepoint->pattern) + 1;
- if (tracepoint->filter_expression != NULL) {
+ if (tracepoint->filter_expression != nullptr) {
filter_expression_len = strlen(tracepoint->filter_expression) + 1;
} else {
filter_expression_len = 0;
struct lttng_event_rule_user_tracepoint *tracepoint;
enum lttng_event_rule_status status;
const char *filter;
- struct lttng_bytecode *bytecode = NULL;
+ struct lttng_bytecode *bytecode = nullptr;
LTTNG_ASSERT(rule);
status = lttng_event_rule_user_tracepoint_get_filter(rule, &filter);
if (status == LTTNG_EVENT_RULE_STATUS_UNSET) {
- filter = NULL;
+ filter = nullptr;
} else if (status != LTTNG_EVENT_RULE_STATUS_OK) {
ret_code = LTTNG_ERR_FILTER_INVAL;
goto end;
if (filter) {
tracepoint->internal_filter.filter = strdup(filter);
- if (tracepoint->internal_filter.filter == NULL) {
+ if (tracepoint->internal_filter.filter == nullptr) {
ret_code = LTTNG_ERR_NOMEM;
goto error;
}
} else {
- tracepoint->internal_filter.filter = NULL;
+ tracepoint->internal_filter.filter = nullptr;
}
- if (tracepoint->internal_filter.filter == NULL) {
+ if (tracepoint->internal_filter.filter == nullptr) {
ret_code = LTTNG_OK;
goto end;
}
}
tracepoint->internal_filter.bytecode = bytecode;
- bytecode = NULL;
+ bytecode = nullptr;
ret_code = LTTNG_OK;
error:
LTTNG_ASSERT(event_rule_status == LTTNG_EVENT_RULE_STATUS_OK);
if (nb_exclusions == 0) {
/* Nothing to do. */
- exclusions = NULL;
+ exclusions = nullptr;
ret_status = LTTNG_EVENT_RULE_GENERATE_EXCLUSIONS_STATUS_NONE;
goto end;
}
sizeof(LTTNG_EVENT_EXCLUSION_NAME_AT(exclusions, i)));
if (copy_ret) {
free(exclusions);
- exclusions = NULL;
+ exclusions = nullptr;
ret_status = LTTNG_EVENT_RULE_GENERATE_EXCLUSIONS_STATUS_ERROR;
goto end;
}
int ret;
enum lttng_error_code ret_code;
enum lttng_event_rule_status status;
- const char *filter = NULL;
- const char *name_pattern = NULL;
- const struct lttng_log_level_rule *log_level_rule = NULL;
+ const char *filter = nullptr;
+ const char *name_pattern = nullptr;
+ const struct lttng_log_level_rule *log_level_rule = nullptr;
unsigned int exclusion_count = 0;
LTTNG_ASSERT(rule);
}
/* Filter expression. */
- if (filter != NULL) {
+ if (filter != nullptr) {
ret = mi_lttng_writer_write_element_string(
writer, mi_lttng_element_event_rule_filter_expression, filter);
if (ret) {
struct lttng_event_rule *lttng_event_rule_user_tracepoint_create(void)
{
- struct lttng_event_rule *rule = NULL;
+ struct lttng_event_rule *rule = nullptr;
struct lttng_event_rule_user_tracepoint *tp_rule;
enum lttng_event_rule_status status;
tp_rule->parent.mi_serialize = lttng_event_rule_user_tracepoint_mi_serialize;
/* Not necessary for now. */
- tp_rule->parent.generate_lttng_event = NULL;
+ tp_rule->parent.generate_lttng_event = nullptr;
- tp_rule->log_level_rule = NULL;
+ tp_rule->log_level_rule = nullptr;
lttng_dynamic_pointer_array_init(&tp_rule->exclusions, destroy_lttng_exclusions_element);
status = lttng_event_rule_user_tracepoint_set_name_pattern(rule, "*");
if (status != LTTNG_EVENT_RULE_STATUS_OK) {
lttng_event_rule_destroy(rule);
- rule = NULL;
+ rule = nullptr;
}
end:
enum lttng_event_rule_status status;
const struct lttng_event_rule_user_tracepoint_comm *tracepoint_comm;
const char *pattern;
- const char *filter_expression = NULL;
- const char **exclusions = NULL;
+ const char *filter_expression = nullptr;
+ const char **exclusions = nullptr;
const uint32_t *exclusion_len;
const char *exclusion;
struct lttng_buffer_view current_buffer_view;
- struct lttng_event_rule *rule = NULL;
- struct lttng_log_level_rule *log_level_rule = NULL;
+ struct lttng_event_rule *rule = nullptr;
+ struct lttng_log_level_rule *log_level_rule = nullptr;
if (!_event_rule) {
ret = -1;
}
*_event_rule = rule;
- rule = NULL;
+ rule = nullptr;
ret = offset;
end:
free(exclusions);
lttng_event_rule_user_tracepoint_set_name_pattern(struct lttng_event_rule *rule,
const char *pattern)
{
- char *pattern_copy = NULL;
+ char *pattern_copy = nullptr;
struct lttng_event_rule_user_tracepoint *tracepoint;
enum lttng_event_rule_status status = LTTNG_EVENT_RULE_STATUS_OK;
free(tracepoint->pattern);
tracepoint->pattern = pattern_copy;
- pattern_copy = NULL;
+ pattern_copy = nullptr;
end:
return status;
}
enum lttng_event_rule_status
lttng_event_rule_user_tracepoint_set_filter(struct lttng_event_rule *rule, const char *expression)
{
- char *expression_copy = NULL;
+ char *expression_copy = nullptr;
struct lttng_event_rule_user_tracepoint *tracepoint;
enum lttng_event_rule_status status = LTTNG_EVENT_RULE_STATUS_OK;
}
tracepoint->filter_expression = expression_copy;
- expression_copy = NULL;
+ expression_copy = nullptr;
end:
return status;
}
{
struct lttng_event_rule_user_tracepoint *tracepoint;
enum lttng_event_rule_status status = LTTNG_EVENT_RULE_STATUS_OK;
- struct lttng_log_level_rule *copy = NULL;
+ struct lttng_log_level_rule *copy = nullptr;
if (!rule || !IS_USER_TRACEPOINT_EVENT_RULE(rule)) {
status = LTTNG_EVENT_RULE_STATUS_INVALID;
}
copy = lttng_log_level_rule_copy(log_level_rule);
- if (copy == NULL) {
+ if (copy == nullptr) {
status = LTTNG_EVENT_RULE_STATUS_ERROR;
goto end;
}
}
tracepoint = lttng::utils::container_of(rule, <tng_event_rule_user_tracepoint::parent);
- if (tracepoint->log_level_rule == NULL) {
+ if (tracepoint->log_level_rule == nullptr) {
status = LTTNG_EVENT_RULE_STATUS_UNSET;
goto end;
}
const char *exclusion)
{
int ret;
- char *exclusion_copy = NULL;
+ char *exclusion_copy = nullptr;
struct lttng_event_rule_user_tracepoint *tracepoint;
enum lttng_event_rule_status status = LTTNG_EVENT_RULE_STATUS_OK;
goto end;
}
- exclusion_copy = NULL;
+ exclusion_copy = nullptr;
end:
free(exclusion_copy);
return status;
return new_event;
error:
free(new_event);
- new_event = NULL;
+ new_event = nullptr;
goto end;
}
{
ssize_t ret, offset = 0;
const struct lttng_event_probe_attr_comm *comm;
- struct lttng_event_probe_attr *local_attr = NULL;
+ struct lttng_event_probe_attr *local_attr = nullptr;
struct lttng_payload_view comm_view =
lttng_payload_view_from_view(view, offset, sizeof(*comm));
offset += sizeof(*comm);
local_attr = zmalloc<lttng_event_probe_attr>();
- if (local_attr == NULL) {
+ if (local_attr == nullptr) {
ret = -1;
goto end;
}
}
*probe_attr = local_attr;
- local_attr = NULL;
+ local_attr = nullptr;
ret = offset;
end:
free(local_attr);
{
ssize_t ret, offset = 0;
const struct lttng_event_function_attr_comm *comm;
- struct lttng_event_function_attr *local_attr = NULL;
+ struct lttng_event_function_attr *local_attr = nullptr;
struct lttng_payload_view comm_view =
lttng_payload_view_from_view(view, offset, sizeof(*comm));
offset += sizeof(*comm);
local_attr = zmalloc<lttng_event_function_attr>();
- if (local_attr == NULL) {
+ if (local_attr == nullptr) {
ret = -1;
goto end;
}
}
*function_attr = local_attr;
- local_attr = NULL;
+ local_attr = nullptr;
ret = offset;
end:
free(local_attr);
}
*exclusions = local_exclusions;
- local_exclusions = NULL;
+ local_exclusions = nullptr;
ret = offset;
end:
free(local_exclusions);
struct lttng_bytecode **out_bytecode)
{
ssize_t ret, offset = 0;
- struct lttng_event *local_event = NULL;
- struct lttng_event_exclusion *local_exclusions = NULL;
- struct lttng_bytecode *local_bytecode = NULL;
- char *local_filter_expression = NULL;
+ struct lttng_event *local_event = nullptr;
+ struct lttng_event_exclusion *local_exclusions = nullptr;
+ struct lttng_bytecode *local_bytecode = nullptr;
+ char *local_filter_expression = nullptr;
const struct lttng_event_comm *event_comm;
- struct lttng_event_function_attr *local_function_attr = NULL;
- struct lttng_event_probe_attr *local_probe_attr = NULL;
- struct lttng_userspace_probe_location *local_userspace_probe_location = NULL;
+ struct lttng_event_function_attr *local_function_attr = nullptr;
+ struct lttng_event_probe_attr *local_probe_attr = nullptr;
+ struct lttng_userspace_probe_location *local_userspace_probe_location = nullptr;
/*
* Only event is obligatory, the other output argument are optional and
}
local_event = lttng_event_create();
- if (local_event == NULL) {
+ if (local_event == nullptr) {
ret = -1;
goto end;
}
* Userspace probe location object ownership transfered to the
* event object.
*/
- local_userspace_probe_location = NULL;
+ local_userspace_probe_location = nullptr;
offset += event_comm->userspace_probe_location_len;
break;
}
/* Transfer ownership to the caller. */
*out_event = local_event;
- local_event = NULL;
+ local_event = nullptr;
if (out_bytecode) {
*out_bytecode = local_bytecode;
- local_bytecode = NULL;
+ local_bytecode = nullptr;
}
if (out_exclusion) {
*out_exclusion = local_exclusions;
- local_exclusions = NULL;
+ local_exclusions = nullptr;
}
if (out_filter_expression) {
*out_filter_expression = local_filter_expression;
- local_filter_expression = NULL;
+ local_filter_expression = nullptr;
}
ret = offset;
{
ssize_t ret, offset = 0;
const struct lttng_event_context_app_comm *comm;
- char *provider_name = NULL, *context_name = NULL;
+ char *provider_name = nullptr, *context_name = nullptr;
size_t provider_name_len, context_name_len;
const struct lttng_buffer_view comm_view =
lttng_buffer_view_from_view(&view->buffer, offset, sizeof(*comm));
/* Transfer ownership of the strings */
event_ctx->u.app_ctx.provider_name = provider_name;
event_ctx->u.app_ctx.ctx_name = context_name;
- provider_name = NULL;
- context_name = NULL;
+ provider_name = nullptr;
+ context_name = nullptr;
ret = offset;
end:
{
ssize_t ret, offset = 0;
const struct lttng_event_context_comm *comm;
- struct lttng_event_context *local_context = NULL;
+ struct lttng_event_context *local_context = nullptr;
struct lttng_buffer_view comm_view =
lttng_buffer_view_from_view(&view->buffer, offset, sizeof(*comm));
offset += ret;
*event_ctx = local_context;
- local_context = NULL;
+ local_context = nullptr;
ret = offset;
end:
memcpy(destination, src, sizeof(*destination));
/* Remove all possible dynamic data from the destination event rule. */
- destination->extended.ptr = NULL;
+ destination->extended.ptr = nullptr;
}
ssize_t lttng_event_field_create_from_payload(struct lttng_payload_view *view,
struct lttng_event_field **field)
{
ssize_t ret, offset = 0;
- struct lttng_event_field *local_event_field = NULL;
- struct lttng_event *event = NULL;
+ struct lttng_event_field *local_event_field = nullptr;
+ struct lttng_event *event = nullptr;
const struct lttng_event_field_comm *comm;
- const char *name = NULL;
+ const char *name = nullptr;
assert(field);
assert(view);
goto end;
}
- ret = lttng_event_create_from_payload(&event_view, &event, NULL, NULL, NULL);
+ ret = lttng_event_create_from_payload(
+ &event_view, &event, nullptr, nullptr, nullptr);
if (ret != comm->event_len) {
ret = -1;
goto end;
lttng_event_field_populate_lttng_event_from_event(event, &local_event_field->event);
*field = local_event_field;
- local_event_field = NULL;
+ local_event_field = nullptr;
ret = offset;
end:
lttng_event_destroy(event);
}
size_before_event = payload->buffer.size;
- ret = lttng_event_serialize(&field->event, 0, NULL, NULL, 0, 0, payload);
+ ret = lttng_event_serialize(&field->event, 0, nullptr, nullptr, 0, nullptr, payload);
if (ret) {
ret = -1;
goto end;
const struct event_list_element *element =
(const struct event_list_element *) lttng_dynamic_pointer_array_get_pointer(
events, i);
- const struct lttng_userspace_probe_location *location = NULL;
+ const struct lttng_userspace_probe_location *location = nullptr;
location = lttng_event_get_userspace_probe_location(element->event);
if (location) {
- ret = lttng_userspace_probe_location_flatten(location, NULL);
+ ret = lttng_userspace_probe_location_flatten(location, nullptr);
if (ret < 0) {
ret_code = LTTNG_ERR_PROBE_LOCATION_INVAL;
goto end;
struct lttng_event_extended *event_extended =
(struct lttng_event_extended *) (local_flattened_events.data +
local_flattened_events.size);
- const struct lttng_userspace_probe_location *location = NULL;
+ const struct lttng_userspace_probe_location *location = nullptr;
assert(element);
&element->event,
&element->exclusions,
&element->filter_expression,
- NULL);
+ nullptr);
if (event_size < 0) {
ret_code = LTTNG_ERR_INVALID;
goto end;
enum lttng_error_code ret_code;
int ret, offset = 0;
unsigned int i;
- struct lttng_dynamic_pointer_array *list = NULL;
+ struct lttng_dynamic_pointer_array *list = nullptr;
assert(view);
assert(event_field_list);
for (i = 0; i < count; i++) {
ssize_t event_field_size;
- struct lttng_event_field *field = NULL;
+ struct lttng_event_field *field = nullptr;
struct lttng_payload_view event_field_view =
lttng_payload_view_from_view(view, offset, -1);
}
*event_field_list = list;
- list = NULL;
+ list = nullptr;
ret_code = LTTNG_OK;
end:
struct lttng_payload_view *view, unsigned int count, struct lttng_event_field **fields)
{
enum lttng_error_code ret_code;
- struct lttng_dynamic_pointer_array *local_event_fields = NULL;
+ struct lttng_dynamic_pointer_array *local_event_fields = nullptr;
ret_code = event_field_list_create_from_payload(view, count, &local_event_fields);
if (ret_code != LTTNG_OK) {
struct fd_handle *fd_handle_create(int fd)
{
- struct fd_handle *handle = NULL;
+ struct fd_handle *handle = nullptr;
if (fd < 0) {
ERR("Attempted to create an fd_handle from an invalid file descriptor: fd = %d",
struct fd_handle *fd_handle_copy(const struct fd_handle *handle)
{
- struct fd_handle *new_handle = NULL;
+ struct fd_handle *new_handle = nullptr;
const int new_fd = dup(handle->fd);
if (new_fd < 0) {
return entry;
error:
unsuspendable_fd_destroy(entry);
- return NULL;
+ return nullptr;
}
static void fs_handle_tracked_log(struct fs_handle_tracked *handle)
const char *path;
pthread_mutex_lock(&handle->lock);
- lttng_inode_borrow_location(handle->inode, NULL, &path);
+ lttng_inode_borrow_location(handle->inode, nullptr, &path);
if (handle->fd >= 0) {
DBG_NO_LOC(" %s [active, fd %d%s]",
pthread_mutex_lock(&seed.lock);
if (!seed.initialized) {
- seed.value = (unsigned long) time(NULL);
+ seed.value = (unsigned long) time(nullptr);
seed.initialized = true;
}
pthread_mutex_unlock(&seed.lock);
CDS_INIT_LIST_HEAD(&tracker->suspended_handles);
tracker->capacity = capacity;
tracker->unsuspendable_fds = cds_lfht_new(
- DEFAULT_HT_SIZE, 1, 0, CDS_LFHT_AUTO_RESIZE | CDS_LFHT_ACCOUNTING, NULL);
+ DEFAULT_HT_SIZE, 1, 0, CDS_LFHT_AUTO_RESIZE | CDS_LFHT_ACCOUNTING, nullptr);
if (!tracker->unsuspendable_fds) {
ERR("Failed to create fd-tracker's unsuspendable_fds hash table");
goto error;
return tracker;
error:
fd_tracker_destroy(tracker);
- return NULL;
+ return nullptr;
}
void fd_tracker_log(struct fd_tracker *tracker)
pthread_mutex_unlock(&tracker->lock);
if (tracker->unsuspendable_fds) {
- ret = cds_lfht_destroy(tracker->unsuspendable_fds, NULL);
+ ret = cds_lfht_destroy(tracker->unsuspendable_fds, nullptr);
LTTNG_ASSERT(!ret);
}
mode_t *mode)
{
int ret;
- struct fs_handle_tracked *handle = NULL;
+ struct fs_handle_tracked *handle = nullptr;
struct stat fd_stat;
struct open_properties properties = { .flags = flags,
.mode = {
handle->tracker = tracker;
- ret = pthread_mutex_init(&handle->lock, NULL);
+ ret = pthread_mutex_init(&handle->lock, nullptr);
if (ret) {
PERROR("Failed to initialize handle mutex while creating fs handle");
goto error_mutex_init;
fd_tracker_track(tracker, handle);
end:
pthread_mutex_unlock(&tracker->lock);
- return handle ? &handle->parent : NULL;
+ return handle ? &handle->parent : nullptr;
error:
if (handle->inode) {
lttng_inode_put(handle->inode);
pthread_mutex_destroy(&handle->lock);
error_mutex_init:
free(handle);
- handle = NULL;
+ handle = nullptr;
goto end;
}
*/
for (i = 0; i < fd_count; i++) {
struct unsuspendable_fd *entry =
- unsuspendable_fd_create(names ? names[i] : NULL, out_fds[i]);
+ unsuspendable_fd_create(names ? names[i] : nullptr, out_fds[i]);
if (!entry) {
ret = -1;
rcu_read_unlock();
goto end_free_entries;
}
- entries[i] = NULL;
+ entries[i] = nullptr;
}
tracker->count.unsuspendable += fd_count;
rcu_read_unlock();
void *user_data)
{
int i, ret, user_ret;
- int *fds = NULL;
+ int *fds = nullptr;
/*
* Maintain a local copy of fds_in as the user's callback may modify its
static int fs_handle_tracked_close(struct fs_handle *_handle)
{
int ret = 0;
- const char *path = NULL;
+ const char *path = nullptr;
struct fs_handle_tracked *handle =
lttng::utils::container_of(_handle, &fs_handle_tracked::parent);
- struct lttng_directory_handle *inode_directory_handle = NULL;
+ struct lttng_directory_handle *inode_directory_handle = nullptr;
if (!handle) {
ret = -EINVAL;
pthread_mutex_lock(&handle->tracker->lock);
pthread_mutex_lock(&handle->lock);
if (handle->inode) {
- lttng_inode_borrow_location(handle->inode, NULL, &path);
+ lttng_inode_borrow_location(handle->inode, nullptr, &path);
/*
* Here a reference to the inode's directory handle is acquired
* to prevent the last reference to it from being released while
}
lttng_directory_handle_put(inode->location.directory_handle);
- inode->location.directory_handle = NULL;
+ inode->location.directory_handle = nullptr;
reference_acquired = lttng_directory_handle_get(pool->unlink_directory_handle);
LTTNG_ASSERT(reference_acquired);
inode->location.directory_handle = pool->unlink_directory_handle;
free(inode->location.path);
inode->location.path = inode_unlinked_name;
- inode_unlinked_name = NULL;
+ inode_unlinked_name = nullptr;
LTTNG_OPTIONAL_SET(&inode->unlinked_id, unlinked_id);
pool->file_count++;
end:
goto end;
}
free(inode->location.path);
- inode->location.path = NULL;
+ inode->location.path = nullptr;
lttng_directory_handle_put(inode->location.directory_handle);
- inode->location.directory_handle = NULL;
+ inode->location.directory_handle = nullptr;
pool->file_count--;
if (pool->file_count == 0) {
pool->unlink_directory_path);
}
lttng_directory_handle_put(pool->unlink_directory_handle);
- pool->unlink_directory_handle = NULL;
+ pool->unlink_directory_handle = nullptr;
}
end:
return ret;
}
lttng_directory_handle_put(inode->location.directory_handle);
- inode->location.directory_handle = NULL;
+ inode->location.directory_handle = nullptr;
free(inode->location.path);
- inode->location.path = NULL;
+ inode->location.path = nullptr;
call_rcu(&inode->rcu_head, lttng_inode_free);
}
return pool;
error:
lttng_unlinked_file_pool_destroy(pool);
- return NULL;
+ return nullptr;
}
void lttng_unlinked_file_pool_destroy(struct lttng_unlinked_file_pool *pool)
inode->location.directory_handle = new_directory_handle;
/* Ownership transferred. */
inode->location.path = new_path_copy;
- new_path_copy = NULL;
+ new_path_copy = nullptr;
end:
free(new_path_copy);
return ret;
struct lttng_directory_handle *directory_handle,
const char *path)
{
- struct lttng_inode *inode = NULL;
+ struct lttng_inode *inode = nullptr;
char *path_copy;
bool reference_acquired;
inode->unlinked_file_pool = unlinked_file_pool;
/* Ownership of path copy is transferred to inode. */
inode->location.path = path_copy;
- path_copy = NULL;
+ path_copy = nullptr;
inode->location.directory_handle = directory_handle;
end:
free(path_copy);
return inode;
}
-struct lttng_inode_registry *lttng_inode_registry_create(void)
+struct lttng_inode_registry *lttng_inode_registry_create()
{
struct lttng_inode_registry *registry = zmalloc<lttng_inode_registry>();
pthread_mutex_lock(&seed.lock);
if (!seed.initialized) {
- seed.value = (unsigned long) time(NULL);
+ seed.value = (unsigned long) time(nullptr);
seed.initialized = true;
}
pthread_mutex_unlock(&seed.lock);
registry->inodes = cds_lfht_new(
- DEFAULT_HT_SIZE, 1, 0, CDS_LFHT_AUTO_RESIZE | CDS_LFHT_ACCOUNTING, NULL);
+ DEFAULT_HT_SIZE, 1, 0, CDS_LFHT_AUTO_RESIZE | CDS_LFHT_ACCOUNTING, nullptr);
if (!registry->inodes) {
goto error;
}
return registry;
error:
lttng_inode_registry_destroy(registry);
- return NULL;
+ return nullptr;
}
void lttng_inode_registry_destroy(struct lttng_inode_registry *registry)
return;
}
if (registry->inodes) {
- int ret = cds_lfht_destroy(registry->inodes, NULL);
+ int ret = cds_lfht_destroy(registry->inodes, nullptr);
LTTNG_ASSERT(!ret);
}
struct inode_id id;
struct cds_lfht_iter iter;
struct cds_lfht_node *node;
- struct lttng_inode *inode = NULL;
+ struct lttng_inode *inode = nullptr;
ret = fstat(fd, &statbuf);
if (ret < 0) {
}
ret = fd_tracker_open_unsuspendable_fd(
- tracker, pipe, (const char **) names, 2, open_pipe_cloexec, NULL);
+ tracker, pipe, (const char **) names, 2, open_pipe_cloexec, nullptr);
free(names[0]);
free(names[1]);
end:
int fd_tracker_util_pipe_close(struct fd_tracker *tracker, int *pipe)
{
- return fd_tracker_close_unsuspendable_fd(tracker, pipe, 2, close_pipe, NULL);
+ return fd_tracker_close_unsuspendable_fd(tracker, pipe, 2, close_pipe, nullptr);
}
namespace {
{
int ret = 0;
struct open_directory_handle_args *args = (open_directory_handle_args *) _args;
- struct lttng_directory_handle *new_handle = NULL;
+ struct lttng_directory_handle *new_handle = nullptr;
new_handle = args->in_handle ?
lttng_directory_handle_create_from_handle(args->path, args->in_handle) :
{
struct fd_tracker *tracker = (fd_tracker *) data;
const int ret =
- fd_tracker_close_unsuspendable_fd(tracker, &handle->dirfd, 1, fd_close, NULL);
+ fd_tracker_close_unsuspendable_fd(tracker, &handle->dirfd, 1, fd_close, nullptr);
if (ret) {
ERR("Failed to untrack directory handle file descriptor");
struct lttng_directory_handle *fd_tracker_create_directory_handle(struct fd_tracker *tracker,
const char *path)
{
- return fd_tracker_create_directory_handle_from_handle(tracker, NULL, path);
+ return fd_tracker_create_directory_handle_from_handle(tracker, nullptr, path);
}
struct lttng_directory_handle *fd_tracker_create_directory_handle_from_handle(
{
int ret;
int dirfd = -1;
- char *handle_name = NULL;
+ char *handle_name = nullptr;
char cwd_path[LTTNG_PATH_MAX] = "working directory";
- struct lttng_directory_handle *new_handle = NULL;
+ struct lttng_directory_handle *new_handle = nullptr;
open_directory_handle_args open_args{};
open_args.in_handle = in_handle;
file_descriptor(const file_descriptor&) = delete;
- file_descriptor(file_descriptor&& other) : _raw_fd{-1}
- {
+ file_descriptor(file_descriptor&& other) noexcept {
LTTNG_ASSERT(_is_valid_fd(_raw_fd));
std::swap(_raw_fd, other._raw_fd);
}
return fd >= 0;
}
- int _raw_fd;
+ int _raw_fd = -1;
};
} /* namespace lttng */
struct bytecode_symbol_iterator *bytecode_symbol_iterator_create(struct lttng_bytecode *bytecode)
{
- struct bytecode_symbol_iterator *it = NULL;
+ struct bytecode_symbol_iterator *it = nullptr;
if (!bytecode) {
goto end;
const char *bytecode_symbol_iterator_get_name(struct bytecode_symbol_iterator *it)
{
- const char *ret = NULL;
+ const char *ret = nullptr;
if (!it) {
goto end;
typename FormatCtx::iterator format(const std::type_info& type_info, FormatCtx& ctx)
{
int status;
- auto demangled_name = abi::__cxa_demangle(type_info.name(), nullptr, 0, &status);
+ auto demangled_name =
+ abi::__cxa_demangle(type_info.name(), nullptr, nullptr, &status);
auto it = status == 0 ? formatter<std::string>::format(demangled_name, ctx) :
formatter<std::string>::format(type_info.name(), ctx);
{
if (active) {
uatomic_set(futex, 1);
- if (futex_async(futex, FUTEX_WAKE, INT_MAX, NULL, NULL, 0) < 0) {
+ if (futex_async(futex, FUTEX_WAKE, INT_MAX, nullptr, nullptr, 0) < 0) {
PERROR("futex_async");
abort();
}
cmm_smp_mb();
while (uatomic_read(futex) == -1) {
- if (!futex_async(futex, FUTEX_WAIT, -1, NULL, NULL, 0)) {
+ if (!futex_async(futex, FUTEX_WAIT, -1, nullptr, nullptr, 0)) {
/*
* Prior queued wakeups queued by unrelated code
* using the same address can cause futex wait to
if (caa_unlikely(uatomic_read(futex) != -1))
goto end;
uatomic_set(futex, 0);
- if (futex_async(futex, FUTEX_WAKE, 1, NULL, NULL, 0) < 0) {
+ if (futex_async(futex, FUTEX_WAKE, 1, nullptr, nullptr, 0) < 0) {
PERROR("futex_async");
abort();
}
pthread_mutex_lock(&seed_lock);
if (!seed_init) {
- lttng_ht_seed = (unsigned long) time(NULL);
+ lttng_ht_seed = (unsigned long) time(nullptr);
seed_init = true;
}
pthread_mutex_unlock(&seed_lock);
ht = zmalloc<lttng_ht>();
- if (ht == NULL) {
+ if (ht == nullptr) {
PERROR("zmalloc lttng_ht");
goto error;
}
min_hash_alloc_size,
max_hash_buckets_size,
CDS_LFHT_AUTO_RESIZE | CDS_LFHT_ACCOUNTING,
- NULL);
+ nullptr);
/*
* There is already an assert in the RCU hashtable code so if the ht is
* NULL here there is a *huge* problem.
return ht;
error:
- return NULL;
+ return nullptr;
}
/*
{
int ret;
- ret = cds_lfht_destroy(ht->ht, NULL);
+ ret = cds_lfht_destroy(ht->ht, nullptr);
LTTNG_ASSERT(!ret);
free(ht);
}
&node->node);
rcu_read_unlock();
if (!node_ptr) {
- return NULL;
+ return nullptr;
} else {
return lttng::utils::container_of(node_ptr, <tng_ht_node_ulong::node);
}
&node->node);
rcu_read_unlock();
if (!node_ptr) {
- return NULL;
+ return nullptr;
} else {
return lttng::utils::container_of(node_ptr, <tng_ht_node_u64::node);
}
LTTNG_ASSERT(iter);
node = cds_lfht_iter_get_node(&iter->iter);
if (!node) {
- return NULL;
+ return nullptr;
}
return lttng::utils::container_of(node, <tng_ht_node_str::node);
}
LTTNG_ASSERT(iter);
node = cds_lfht_iter_get_node(&iter->iter);
if (!node) {
- return NULL;
+ return nullptr;
}
return lttng::utils::container_of(node, <tng_ht_node_ulong::node);
}
LTTNG_ASSERT(iter);
node = cds_lfht_iter_get_node(&iter->iter);
if (!node) {
- return NULL;
+ return nullptr;
}
return lttng::utils::container_of(node, <tng_ht_node_u64::node);
}
LTTNG_ASSERT(iter);
node = cds_lfht_iter_get_node(&iter->iter);
if (!node) {
- return NULL;
+ return nullptr;
}
return lttng::utils::container_of(node, <tng_ht_node_two_u64::node);
}
ha = zmalloc<health_app>();
if (!ha) {
- return NULL;
+ return nullptr;
}
ha->flags = calloc<health_flags>(nr_types);
if (!ha->flags) {
goto error_flags;
}
CDS_INIT_LIST_HEAD(&ha->list);
- pthread_mutex_init(&ha->lock, NULL);
+ pthread_mutex_init(&ha->lock, nullptr);
ha->nr_types = nr_types;
ha->time_delta.tv_sec = DEFAULT_HEALTH_CHECK_DELTA_S;
ha->time_delta.tv_nsec = DEFAULT_HEALTH_CHECK_DELTA_NS;
error_flags:
free(ha);
- return NULL;
+ return nullptr;
}
void health_app_destroy(struct health_app *ha)
struct lttng_index_allocator *lttng_index_allocator_create(uint64_t index_count)
{
- struct lttng_index_allocator *allocator = NULL;
+ struct lttng_index_allocator *allocator = nullptr;
allocator = zmalloc<lttng_index_allocator>();
if (!allocator) {
enum lttng_index_allocator_status
lttng_index_allocator_release(struct lttng_index_allocator *allocator, uint64_t idx)
{
- struct lttng_index *index = NULL;
+ struct lttng_index *index = nullptr;
enum lttng_index_allocator_status status = LTTNG_INDEX_ALLOCATOR_STATUS_OK;
LTTNG_ASSERT(idx < allocator->size);
void lttng_index_allocator_destroy(struct lttng_index_allocator *allocator)
{
- struct lttng_index *index = NULL, *tmp_index = NULL;
+ struct lttng_index *index = nullptr, *tmp_index = nullptr;
if (!allocator) {
return;
struct lttng_index_file *index_file;
enum lttng_trace_chunk_status chunk_status;
int ret;
- struct fs_handle *fs_handle = NULL;
+ struct fs_handle *fs_handle = nullptr;
ssize_t size_ret;
struct ctf_packet_index_file_hdr hdr;
char index_directory_path[LTTNG_PATH_MAX];
{
int ret = 0;
const char *path;
- FILE *config_file = NULL;
+ FILE *config_file = nullptr;
struct handler_filter_args filter = { section, handler, user_data };
/* First, try system-wide conf. file. */
#endif
/* Scan through file line by line */
- while (fgets(line, INI_MAX_LINE, file) != NULL) {
+ while (fgets(line, INI_MAX_LINE, file) != nullptr) {
lineno++;
start = line;
}
metadata_stream->out_fd = -1;
lttng_trace_chunk_put(metadata_stream->trace_chunk);
- metadata_stream->trace_chunk = NULL;
+ metadata_stream->trace_chunk = nullptr;
}
}
ret = 0;
error_snapshot:
metadata_stream->read_subbuffer_ops.unlock(metadata_stream);
- consumer_stream_destroy(metadata_stream, NULL);
- metadata_channel->metadata_stream = NULL;
+ consumer_stream_destroy(metadata_stream, nullptr);
+ metadata_channel->metadata_stream = nullptr;
rcu_read_unlock();
return ret;
}
health_code_update();
DBG("consumer_add_channel %" PRIu64, msg.u.channel.channel_key);
- new_channel =
- consumer_allocate_channel(msg.u.channel.channel_key,
- msg.u.channel.session_id,
- msg.u.channel.chunk_id.is_set ? &chunk_id : NULL,
- msg.u.channel.pathname,
- msg.u.channel.name,
- msg.u.channel.relayd_id,
- msg.u.channel.output,
- msg.u.channel.tracefile_size,
- msg.u.channel.tracefile_count,
- 0,
- msg.u.channel.monitor,
- msg.u.channel.live_timer_interval,
- msg.u.channel.is_live,
- NULL,
- NULL);
- if (new_channel == NULL) {
+ new_channel = consumer_allocate_channel(msg.u.channel.channel_key,
+ msg.u.channel.session_id,
+ msg.u.channel.chunk_id.is_set ? &chunk_id :
+ nullptr,
+ msg.u.channel.pathname,
+ msg.u.channel.name,
+ msg.u.channel.relayd_id,
+ msg.u.channel.output,
+ msg.u.channel.tracefile_size,
+ msg.u.channel.tracefile_count,
+ 0,
+ msg.u.channel.monitor,
+ msg.u.channel.live_timer_interval,
+ msg.u.channel.is_live,
+ nullptr,
+ nullptr);
+ if (new_channel == nullptr) {
lttng_consumer_send_error(ctx, LTTCOMM_CONSUMERD_OUTFD_ERROR);
goto end_nosignal;
}
health_code_update();
- if (ctx->on_recv_channel != NULL) {
+ if (ctx->on_recv_channel != nullptr) {
int ret_recv_channel = ctx->on_recv_channel(new_channel);
if (ret_recv_channel == 0) {
ret_add_channel = consumer_add_channel(new_channel, ctx);
&alloc_ret,
channel->type,
channel->monitor);
- if (new_stream == NULL) {
+ if (new_stream == nullptr) {
switch (alloc_ret) {
case -ENOMEM:
case -EINVAL:
/* Get relayd reference if exists. */
relayd = consumer_find_relayd(index);
- if (relayd == NULL) {
+ if (relayd == nullptr) {
DBG("Unable to find relayd %" PRIu64, index);
ret_code = LTTCOMM_CONSUMERD_RELAYD_FAIL;
}
const uint64_t relayd_id = msg.u.create_trace_chunk.relayd_id.value;
const char *chunk_override_name = *msg.u.create_trace_chunk.override_name ?
msg.u.create_trace_chunk.override_name :
- NULL;
- struct lttng_directory_handle *chunk_directory_handle = NULL;
+ nullptr;
+ struct lttng_directory_handle *chunk_directory_handle = nullptr;
/*
* The session daemon will only provide a chunk directory file
}
ret_code = lttng_consumer_create_trace_chunk(
- !is_local_trace ? &relayd_id : NULL,
+ !is_local_trace ? &relayd_id : nullptr,
msg.u.create_trace_chunk.session_id,
msg.u.create_trace_chunk.chunk_id,
(time_t) msg.u.create_trace_chunk.creation_timestamp,
chunk_override_name,
- msg.u.create_trace_chunk.credentials.is_set ? &credentials : NULL,
+ msg.u.create_trace_chunk.credentials.is_set ? &credentials : nullptr,
chunk_directory_handle);
lttng_directory_handle_put(chunk_directory_handle);
goto end_msg_sessiond;
ssize_t ret_send;
ret_code = lttng_consumer_close_trace_chunk(
- msg.u.close_trace_chunk.relayd_id.is_set ? &relayd_id : NULL,
+ msg.u.close_trace_chunk.relayd_id.is_set ? &relayd_id : nullptr,
msg.u.close_trace_chunk.session_id,
msg.u.close_trace_chunk.chunk_id,
(time_t) msg.u.close_trace_chunk.close_timestamp,
- msg.u.close_trace_chunk.close_command.is_set ? &close_command : NULL,
+ msg.u.close_trace_chunk.close_command.is_set ? &close_command : nullptr,
path);
reply.ret_code = ret_code;
reply.path_length = strlen(path) + 1;
const uint64_t relayd_id = msg.u.trace_chunk_exists.relayd_id.value;
ret_code = lttng_consumer_trace_chunk_exists(
- msg.u.trace_chunk_exists.relayd_id.is_set ? &relayd_id : NULL,
+ msg.u.trace_chunk_exists.relayd_id.is_set ? &relayd_id : nullptr,
msg.u.trace_chunk_exists.session_id,
msg.u.trace_chunk_exists.chunk_id);
goto end_msg_sessiond;
static bool is_get_next_check_metadata_available(int tracer_fd)
{
- const int ret = kernctl_get_next_subbuf_metadata_check(tracer_fd, NULL);
+ const int ret = kernctl_get_next_subbuf_metadata_check(tracer_fd, nullptr);
const bool available = ret != -ENOTTY;
if (ret == 0) {
*/
WARN("Kernel tracer does not support get_next_subbuffer_metadata_check which may cause live clients to fail to parse the metadata stream");
metadata_bucket_destroy(stream->metadata_bucket);
- stream->metadata_bucket = NULL;
+ stream->metadata_bucket = nullptr;
}
stream->read_subbuffer_ops.on_sleep = signal_metadata;
stream->mmap_len = (size_t) mmap_len;
stream->mmap_base =
- mmap(NULL, stream->mmap_len, PROT_READ, MAP_PRIVATE, stream->wait_fd, 0);
+ mmap(nullptr, stream->mmap_len, PROT_READ, MAP_PRIVATE, stream->wait_fd, 0);
if (stream->mmap_base == MAP_FAILED) {
PERROR("Error mmaping");
ret = -1;
int kernctl_syscall_mask(int fd, char **syscall_mask, uint32_t *nr_bits)
{
- struct lttng_kernel_abi_syscall_mask kmask_len, *kmask = NULL;
+ struct lttng_kernel_abi_syscall_mask kmask_len, *kmask = nullptr;
size_t array_alloc_len;
char *new_mask;
int ret = 0;
static void lttng_kernel_probe_location_symbol_destroy(struct lttng_kernel_probe_location *location)
{
- struct lttng_kernel_probe_location_symbol *location_symbol = NULL;
+ struct lttng_kernel_probe_location_symbol *location_symbol = nullptr;
LTTNG_ASSERT(location);
struct lttng_kernel_probe_location *lttng_kernel_probe_location_address_create(uint64_t address)
{
- struct lttng_kernel_probe_location *ret = NULL;
+ struct lttng_kernel_probe_location *ret = nullptr;
struct lttng_kernel_probe_location_address *location;
location = zmalloc<lttng_kernel_probe_location_address>();
struct lttng_kernel_probe_location *
lttng_kernel_probe_location_symbol_create(const char *symbol_name, uint64_t offset)
{
- char *symbol_name_copy = NULL;
- struct lttng_kernel_probe_location *ret = NULL;
+ char *symbol_name_copy = nullptr;
+ struct lttng_kernel_probe_location *ret = nullptr;
struct lttng_kernel_probe_location_symbol *location;
if (!symbol_name || strlen(symbol_name) >= LTTNG_SYMBOL_NAME_LEN) {
const char *
lttng_kernel_probe_location_symbol_get_name(const struct lttng_kernel_probe_location *location)
{
- const char *ret = NULL;
+ const char *ret = nullptr;
struct lttng_kernel_probe_location_symbol *symbol_location;
if (!location ||
static struct lttng_kernel_probe_location *
lttng_kernel_probe_location_symbol_copy(const struct lttng_kernel_probe_location *location)
{
- struct lttng_kernel_probe_location *new_location = NULL;
+ struct lttng_kernel_probe_location *new_location = nullptr;
enum lttng_kernel_probe_location_status status;
- const char *symbol_name = NULL;
+ const char *symbol_name = nullptr;
uint64_t offset;
LTTNG_ASSERT(location);
goto end;
error:
- new_location = NULL;
+ new_location = nullptr;
end:
return new_location;
}
static struct lttng_kernel_probe_location *
lttng_kernel_probe_location_address_copy(const struct lttng_kernel_probe_location *location)
{
- struct lttng_kernel_probe_location *new_location = NULL;
+ struct lttng_kernel_probe_location *new_location = nullptr;
enum lttng_kernel_probe_location_status status;
uint64_t address;
goto end;
error:
- new_location = NULL;
+ new_location = nullptr;
end:
return new_location;
}
struct lttng_kernel_probe_location *
lttng_kernel_probe_location_copy(const struct lttng_kernel_probe_location *location)
{
- struct lttng_kernel_probe_location *new_location = NULL;
+ struct lttng_kernel_probe_location *new_location = nullptr;
enum lttng_kernel_probe_location_type type;
if (!location) {
}
break;
default:
- new_location = NULL;
+ new_location = nullptr;
goto err;
}
err:
int ret;
enum lttng_error_code ret_code;
enum lttng_kernel_probe_location_status status;
- const char *name = NULL;
+ const char *name = nullptr;
uint64_t offset;
LTTNG_ASSERT(location);
struct lttng_trace_archive_location *
lttng_trace_archive_location_local_create(const char *absolute_path)
{
- struct lttng_trace_archive_location *location = NULL;
+ struct lttng_trace_archive_location *location = nullptr;
if (!absolute_path) {
goto end;
return location;
error:
lttng_trace_archive_location_put(location);
- return NULL;
+ return nullptr;
}
struct lttng_trace_archive_location *lttng_trace_archive_location_relay_create(
uint16_t data_port,
const char *relative_path)
{
- struct lttng_trace_archive_location *location = NULL;
+ struct lttng_trace_archive_location *location = nullptr;
if (!host || !relative_path) {
goto end;
return location;
error:
lttng_trace_archive_location_put(location);
- return NULL;
+ return nullptr;
}
ssize_t
struct lttng_log_level_rule *lttng_log_level_rule_exactly_create(int level)
{
- struct lttng_log_level_rule *rule = NULL;
+ struct lttng_log_level_rule *rule = nullptr;
rule = zmalloc<lttng_log_level_rule>();
if (!rule) {
struct lttng_log_level_rule *lttng_log_level_rule_at_least_as_severe_as_create(int level)
{
- struct lttng_log_level_rule *rule = NULL;
+ struct lttng_log_level_rule *rule = nullptr;
rule = zmalloc<lttng_log_level_rule>();
if (!rule) {
{
ssize_t ret;
size_t offset = 0;
- struct lttng_log_level_rule *rule = NULL;
+ struct lttng_log_level_rule *rule = nullptr;
const struct lttng_log_level_rule_comm *comm =
(const struct lttng_log_level_rule_comm *) view->buffer.data;
{
bool is_equal = false;
- if (a == NULL && b == NULL) {
+ if (a == nullptr && b == nullptr) {
/* Both are null. */
is_equal = true;
goto end;
}
- if (a == NULL || b == NULL) {
+ if (a == nullptr || b == nullptr) {
/* One is NULL.*/
goto end;
}
struct lttng_log_level_rule *lttng_log_level_rule_copy(const struct lttng_log_level_rule *source)
{
- struct lttng_log_level_rule *copy = NULL;
+ struct lttng_log_level_rule *copy = nullptr;
LTTNG_ASSERT(source);
int ret;
enum lttng_error_code ret_code;
enum lttng_log_level_rule_status status;
- const char *element_str = NULL;
+ const char *element_str = nullptr;
int level;
LTTNG_ASSERT(rule);
*/
static char *lttng_elf_get_section_name(struct lttng_elf *elf, off_t offset)
{
- char *name = NULL;
+ char *name = nullptr;
size_t name_length = 0, to_read; /* name_length does not include \0 */
if (!elf) {
error:
free(name);
- return NULL;
+ return nullptr;
}
static int lttng_elf_validate_and_populate(struct lttng_elf *elf)
{
uint8_t version;
uint8_t e_ident[EI_NIDENT];
- uint8_t *magic_number = NULL;
+ uint8_t *magic_number = nullptr;
int ret = 0;
if (elf->fd == -1) {
free_elf_error:
free(elf->ehdr);
- elf->ehdr = NULL;
+ elf->ehdr = nullptr;
end:
return ret;
}
static struct lttng_elf *lttng_elf_create(int fd)
{
struct lttng_elf_shdr section_names_shdr;
- struct lttng_elf *elf = NULL;
+ struct lttng_elf *elf = nullptr;
int ret;
struct stat stat_buf;
}
free(elf);
}
- return NULL;
+ return nullptr;
}
/*
free_error:
free(data);
error:
- return NULL;
+ return nullptr;
}
/*
int sym_count = 0;
int sym_idx = 0;
uint64_t addr = 0;
- char *curr_sym_str = NULL;
- char *symbol_table_data = NULL;
- char *string_table_data = NULL;
- const char *string_table_name = NULL;
+ char *curr_sym_str = nullptr;
+ char *symbol_table_data = nullptr;
+ char *string_table_data = nullptr;
+ const char *string_table_name = nullptr;
struct lttng_elf_shdr symtab_hdr;
struct lttng_elf_shdr strtab_hdr;
- struct lttng_elf *elf = NULL;
+ struct lttng_elf *elf = nullptr;
if (!symbol || !offset) {
ret = LTTNG_ERR_ELF_PARSING;
/* Get the data associated with the symbol table section. */
symbol_table_data = lttng_elf_get_section_data(elf, &symtab_hdr);
- if (symbol_table_data == NULL) {
+ if (symbol_table_data == nullptr) {
DBG("Cannot get ELF Symbol Table data.");
ret = LTTNG_ERR_ELF_PARSING;
goto destroy_elf;
/* Get the data associated with the string table section. */
string_table_data = lttng_elf_get_section_data(elf, &strtab_hdr);
- if (string_table_data == NULL) {
+ if (string_table_data == nullptr) {
DBG("Cannot get ELF string table section data.");
ret = LTTNG_ERR_ELF_PARSING;
goto free_symbol_table_data;
{
int ret = 0, nb_match = 0;
struct lttng_elf_shdr stap_note_section_hdr;
- struct lttng_elf *elf = NULL;
- char *stap_note_section_data = NULL;
+ struct lttng_elf *elf = nullptr;
+ char *stap_note_section_data = nullptr;
char *curr_note_section_begin, *curr_data_ptr, *curr_probe, *curr_provider;
char *next_note_ptr;
uint32_t name_size, desc_size, note_type;
uint64_t curr_probe_location, curr_probe_offset, curr_semaphore_location;
- uint64_t *probe_locs = NULL, *new_probe_locs = NULL;
+ uint64_t *probe_locs = nullptr, *new_probe_locs = nullptr;
if (!provider_name || !probe_name || !nb_probes || !offsets) {
DBG("Invalid arguments.");
/* Get the data associated with the stap note section. */
stap_note_section_data = lttng_elf_get_section_data(elf, &stap_note_section_hdr);
- if (stap_note_section_data == NULL) {
+ if (stap_note_section_data == nullptr) {
DBG("Cannot get ELF stap note section data.");
ret = LTTNG_ERR_ELF_PARSING;
goto destroy_elf_error;
next_note_ptr = stap_note_section_data;
curr_note_section_begin = stap_note_section_data;
- *offsets = NULL;
- while (1) {
+ *offsets = nullptr;
+ while (true) {
curr_data_ptr = next_note_ptr;
/* Check if we have reached the end of the note section. */
if (curr_data_ptr >= curr_note_section_begin + stap_note_section_hdr.sh_size) {
goto realloc_error;
}
probe_locs = new_probe_locs;
- new_probe_locs = NULL;
+ new_probe_locs = nullptr;
/*
* Use the virtual address of the probe to compute the offset of
case LTTNG_EVENT_CONTEXT_VSGID:
return config_event_context_vsgid;
default:
- return NULL;
+ return nullptr;
}
}
default:
/* Should not have an unknown domain */
abort();
- return NULL;
+ return nullptr;
}
}
default:
/* Should not have an unknow buffer type */
abort();
- return NULL;
+ return nullptr;
}
}
default:
/* Should not have an unknow rotation state. */
abort();
- return NULL;
+ return nullptr;
}
}
default:
/* Should not have an unknown relay protocol. */
abort();
- return NULL;
+ return nullptr;
}
}
err_destroy:
free(mi_writer);
- return NULL;
+ return nullptr;
}
int mi_lttng_writer_destroy(struct mi_writer *writer)
struct lttng_notification *lttng_notification_create(struct lttng_trigger *trigger,
struct lttng_evaluation *evaluation)
{
- struct lttng_notification *notification = NULL;
+ struct lttng_notification *notification = nullptr;
if (!trigger || !evaluation) {
goto end;
struct lttng_notification **notification)
{
ssize_t ret, notification_size = 0, trigger_size, evaluation_size;
- struct lttng_trigger *trigger = NULL;
- struct lttng_evaluation *evaluation = NULL;
+ struct lttng_trigger *trigger = nullptr;
+ struct lttng_evaluation *evaluation = nullptr;
const struct lttng_notification_comm *notification_comm;
const struct lttng_payload_view notification_comm_view =
lttng_payload_view_from_view(src_view, 0, sizeof(*notification_comm));
const struct lttng_condition *
lttng_notification_get_condition(struct lttng_notification *notification)
{
- return notification ? lttng_trigger_get_const_condition(notification->trigger) : NULL;
+ return notification ? lttng_trigger_get_const_condition(notification->trigger) : nullptr;
}
const struct lttng_evaluation *
lttng_notification_get_evaluation(struct lttng_notification *notification)
{
- return notification ? notification->evaluation : NULL;
+ return notification ? notification->evaluation : nullptr;
}
const struct lttng_condition *
lttng_notification_get_const_condition(const struct lttng_notification *notification)
{
- return notification ? lttng_trigger_get_const_condition(notification->trigger) : NULL;
+ return notification ? lttng_trigger_get_const_condition(notification->trigger) : nullptr;
}
const struct lttng_evaluation *
lttng_notification_get_const_evaluation(const struct lttng_notification *notification)
{
- return notification ? notification->evaluation : NULL;
+ return notification ? notification->evaluation : nullptr;
}
const struct lttng_trigger *
lttng_notification_get_const_trigger(const struct lttng_notification *notification)
{
- return notification ? notification->trigger : NULL;
+ return notification ? notification->trigger : nullptr;
}
const struct lttng_trigger *lttng_notification_get_trigger(struct lttng_notification *notification)
{
- return notification ? notification->trigger : NULL;
+ return notification ? notification->trigger : nullptr;
}
*/
static char *utils_partial_realpath(const char *path)
{
- char *cut_path = NULL, *try_path = NULL, *try_path_prev = NULL;
+ char *cut_path = nullptr, *try_path = nullptr, *try_path_prev = nullptr;
const char *next, *prev, *end;
- char *resolved_path = NULL;
+ char *resolved_path = nullptr;
/* Safety net */
- if (path == NULL) {
+ if (path == nullptr) {
goto error;
}
try_path = (char *) next;
/* Resolve the canonical path of the first part of the path */
- while (try_path != NULL && next != end) {
- char *try_path_buf = NULL;
+ while (try_path != nullptr && next != end) {
+ char *try_path_buf = nullptr;
/*
* If there is not any '/' left, we want to try with
* the full path
*/
next = strpbrk(next + 1, "/");
- if (next == NULL) {
+ if (next == nullptr) {
next = end;
}
/* Cut the part we will be trying to resolve */
cut_path = lttng_strndup(path, next - path);
- if (cut_path == NULL) {
+ if (cut_path == nullptr) {
PERROR("lttng_strndup");
goto error;
}
/* Try to resolve this part */
try_path = realpath((char *) cut_path, try_path_buf);
- if (try_path == NULL) {
+ if (try_path == nullptr) {
free(try_path_buf);
/*
* There was an error, we just want to be assured it
}
} else {
/* Save the place we are before trying the next step */
- try_path_buf = NULL;
+ try_path_buf = nullptr;
free(try_path_prev);
try_path_prev = try_path;
prev = next;
/* Free the allocated memory */
free(cut_path);
- cut_path = NULL;
+ cut_path = nullptr;
}
/* Allocate memory for the resolved path. */
resolved_path = zmalloc<char>(LTTNG_PATH_MAX);
- if (resolved_path == NULL) {
+ if (resolved_path == nullptr) {
PERROR("zmalloc resolved path");
goto error;
}
* If we were able to solve at least partially the path, we can concatenate
* what worked and what didn't work
*/
- if (try_path_prev != NULL) {
+ if (try_path_prev != nullptr) {
/* If we risk to concatenate two '/', we remove one of them */
if (try_path_prev[strlen(try_path_prev) - 1] == '/' && prev[0] == '/') {
try_path_prev[strlen(try_path_prev) - 1] = '\0';
* path are pointers for the same memory space
*/
cut_path = strdup(prev);
- if (cut_path == NULL) {
+ if (cut_path == nullptr) {
PERROR("strdup");
goto error;
}
/* Free the allocated memory */
free(cut_path);
free(try_path_prev);
- cut_path = NULL;
- try_path_prev = NULL;
+ cut_path = nullptr;
+ try_path_prev = nullptr;
/*
* Else, we just copy the path in our resolved_path to
* return it as is
if (try_path_prev != try_path) {
free(try_path_prev);
}
- return NULL;
+ return nullptr;
}
static int expand_double_slashes_dot_and_dotdot(char *path)
}
next_slash = (const char *) memchr(curr_char, '/', path_last_char - curr_char);
- if (next_slash == NULL) {
+ if (next_slash == nullptr) {
/* Reached the end of the provided path. */
next_slash = path_last_char;
}
* beginning of the path. We can't go back any
* further.
*/
- if (prev_slash != NULL) {
+ if (prev_slash != nullptr) {
expanded_path_len = prev_slash - path;
}
continue;
static char *_utils_expand_path(const char *path, bool keep_symlink)
{
int ret;
- char *absolute_path = NULL;
+ char *absolute_path = nullptr;
char *last_token;
bool is_dot, is_dotdot;
/* Safety net */
- if (path == NULL) {
+ if (path == nullptr) {
goto error;
}
/* Allocate memory for the absolute_path */
absolute_path = zmalloc<char>(LTTNG_PATH_MAX);
- if (absolute_path == NULL) {
+ if (absolute_path == nullptr) {
PERROR("zmalloc expand path");
goto error;
}
error:
free(absolute_path);
- return NULL;
+ return nullptr;
}
char *utils_expand_path(const char *path)
{
struct fd_handle *lttng_payload_view_pop_fd_handle(struct lttng_payload_view *view)
{
- struct fd_handle *handle = NULL;
+ struct fd_handle *handle = nullptr;
size_t fd_handle_count;
size_t *pos;
return ret_val;
}
-static struct lttng_pipe *_pipe_create(void)
+static struct lttng_pipe *_pipe_create()
{
int ret;
struct lttng_pipe *p;
}
p->fd[0] = p->fd[1] = -1;
- ret = pthread_mutex_init(&p->read_mutex, NULL);
+ ret = pthread_mutex_init(&p->read_mutex, nullptr);
if (ret) {
PERROR("pthread_mutex_init read lock pipe create");
goto error_destroy;
}
- ret = pthread_mutex_init(&p->write_mutex, NULL);
+ ret = pthread_mutex_init(&p->write_mutex, nullptr);
if (ret) {
PERROR("pthread_mutex_init write lock pipe create");
goto error_destroy_rmutex;
(void) pthread_mutex_destroy(&p->read_mutex);
error_destroy:
free(p);
- return NULL;
+ return nullptr;
}
static int _pipe_set_flags(struct lttng_pipe *pipe, int flags)
return p;
error:
lttng_pipe_destroy(p);
- return NULL;
+ return nullptr;
}
/*
return pipe;
error:
lttng_pipe_destroy(pipe);
- return NULL;
+ return nullptr;
}
/*
*/
class mutex {
public:
- mutex(pthread_mutex_t& mutex_p) : _mutex{mutex_p}
+ explicit mutex(pthread_mutex_t& mutex_p) : _mutex{mutex_p}
{
}
*/
class lock_guard {
public:
- lock_guard(pthread_mutex_t& mutex) : _mutex{mutex}, _guard(_mutex)
+ explicit lock_guard(pthread_mutex_t& mutex) : _mutex{mutex}, _guard(_mutex)
{
}
}
buf = calloc<char>(buf_size);
- if (buf == NULL) {
+ if (buf == nullptr) {
PERROR("zmalloc relayd send command buf");
ret = -1;
goto alloc_error;
char *output_path)
{
int ret;
- struct lttcomm_relayd_create_session_2_11 *msg = NULL;
+ struct lttcomm_relayd_create_session_2_11 *msg = nullptr;
size_t session_name_len;
size_t hostname_len;
size_t base_path_len;
int ret;
/* Send command */
- ret = send_command(rsock, RELAYD_CREATE_SESSION, NULL, 0, 0);
+ ret = send_command(rsock, RELAYD_CREATE_SESSION, nullptr, 0, 0);
if (ret < 0) {
goto error;
}
uint64_t trace_archive_id)
{
int ret;
- struct lttcomm_relayd_add_stream_2_11 *msg = NULL;
+ struct lttcomm_relayd_add_stream_2_11 *msg = nullptr;
size_t channel_name_len;
size_t pathname_len;
size_t msg_length;
}
/* Send command */
- ret = send_command(rsock, RELAYD_STREAMS_SENT, NULL, 0, 0);
+ ret = send_command(rsock, RELAYD_STREAMS_SENT, nullptr, 0, 0);
if (ret < 0) {
goto error;
}
DBG("Relayd sending metadata of size %zu", len);
/* Send command */
- ret = send_command(rsock, RELAYD_SEND_METADATA, NULL, len, 0);
+ ret = send_command(rsock, RELAYD_SEND_METADATA, nullptr, len, 0);
if (ret < 0) {
goto error;
}
return 0;
}
#else
-static int use_clone(void)
+static int use_clone()
{
return !lttng_secure_getenv("LTTNG_DEBUG_NOCLONE");
}
static int _rename(struct run_as_data *data, struct run_as_ret *ret_value)
{
const char *old_path, *new_path;
- struct lttng_directory_handle *old_handle = NULL, *new_handle = NULL;
+ struct lttng_directory_handle *old_handle = nullptr, *new_handle = nullptr;
old_path = data->u.rename.old_path;
new_path = data->u.rename.new_path;
static int _extract_sdt_probe_offsets(struct run_as_data *data, struct run_as_ret *ret_value)
{
int ret = 0;
- uint64_t *offsets = NULL;
+ uint64_t *offsets = nullptr;
uint32_t num_offset;
ret_value->_error = false;
static int _generate_filter_bytecode(struct run_as_data *data, struct run_as_ret *ret_value)
{
int ret = 0;
- const char *filter_expression = NULL;
- struct filter_parser_ctx *ctx = NULL;
+ const char *filter_expression = nullptr;
+ struct filter_parser_ctx *ctx = nullptr;
ret_value->_error = false;
return _generate_filter_bytecode;
default:
ERR("Unknown command %d", (int) cmd);
- return NULL;
+ return nullptr;
}
}
static int get_user_infos_from_uid(uid_t uid, char **username, gid_t *primary_gid)
{
int ret;
- char *buf = NULL;
+ char *buf = nullptr;
long raw_get_pw_buf_size;
size_t get_pw_buf_size;
struct passwd pwd;
- struct passwd *result = NULL;
+ struct passwd *result = nullptr;
/* Fetch the max size for the temporary buffer. */
errno = 0;
get_pw_buf_size = (size_t) raw_get_pw_buf_size;
buf = calloc<char>(get_pw_buf_size);
- if (buf == NULL) {
+ if (buf == nullptr) {
PERROR("Failed to allocate buffer to get password file entries");
goto error;
}
goto error;
}
- if (result == NULL) {
+ if (result == nullptr) {
ERR("Failed to find user information in password entries: uid = %d", (int) uid);
ret = -1;
goto error;
}
*username = strdup(result->pw_name);
- if (*username == NULL) {
+ if (*username == nullptr) {
PERROR("Failed to copy user name");
goto error;
}
free(buf);
return ret;
error:
- *username = NULL;
+ *username = nullptr;
*primary_gid = -1;
ret = -1;
goto end;
{
int ret = 0;
gid_t primary_gid;
- char *username = NULL;
+ char *username = nullptr;
/* Change the group id. */
if (prev_gid != new_gid) {
{
int ret = 0;
gid_t primary_gid;
- char *username = NULL;
+ char *username = nullptr;
/* Change the group id. */
if (prev_gid != new_gid) {
return ret;
}
-static int reset_sighandler(void)
+static int reset_sighandler()
{
int sig;
signame = "SIGTERM";
break;
default:
- signame = NULL;
+ signame = nullptr;
}
if (signame) {
}
}
-static int set_worker_sighandlers(void)
+static int set_worker_sighandlers()
{
int ret = 0;
sigset_t sigset;
sa.sa_handler = worker_sighandler;
sa.sa_mask = sigset;
sa.sa_flags = 0;
- if ((ret = sigaction(SIGINT, &sa, NULL)) < 0) {
+ if ((ret = sigaction(SIGINT, &sa, nullptr)) < 0) {
PERROR("sigaction SIGINT");
goto end;
}
- if ((ret = sigaction(SIGTERM, &sa, NULL)) < 0) {
+ if ((ret = sigaction(SIGTERM, &sa, nullptr)) < 0) {
PERROR("sigaction SIGTERM");
goto end;
}
return ret;
}
-static void run_as_destroy_worker_no_lock(void)
+static void run_as_destroy_worker_no_lock()
{
run_as_worker_data *worker = global_worker;
}
free(worker->procname);
free(worker);
- global_worker = NULL;
+ global_worker = nullptr;
}
static int run_as_restart_worker(run_as_worker_data *worker)
{
int ret = 0;
- char *procname = NULL;
+ char *procname = nullptr;
procname = worker->procname;
run_as_destroy_worker_no_lock();
/* Create a new run_as worker process*/
- ret = run_as_create_worker_no_lock(procname, NULL, NULL);
+ ret = run_as_create_worker_no_lock(procname, nullptr, nullptr);
if (ret < 0) {
ERR("Restarting the worker process failed");
ret = -1;
int ret;
struct run_as_data data = {};
struct run_as_ret run_as_ret = {};
- const struct lttng_bytecode *view_bytecode = NULL;
- struct lttng_bytecode *local_bytecode = NULL;
+ const struct lttng_bytecode *view_bytecode = nullptr;
+ struct lttng_bytecode *local_bytecode = nullptr;
const uid_t uid = lttng_credentials_get_uid(creds);
const gid_t gid = lttng_credentials_get_gid(creds);
return ret;
}
-void run_as_destroy_worker(void)
+void run_as_destroy_worker()
{
pthread_mutex_lock(&worker_lock);
run_as_destroy_worker_no_lock();
struct lttng_bytecode **bytecode);
int run_as_create_worker(const char *procname,
post_fork_cleanup_cb clean_up_func, void *clean_up_user_data);
-void run_as_destroy_worker(void);
+void run_as_destroy_worker();
#endif /* _RUNAS_H */
* must be `noexcept` lest we anger the undefined behaviour gods.
*/
static_assert(details::is_invocation_noexcept<ScopeExitInvocableType>::value,
- "scope_exit requires a noexcept invocable type");
+ "scope_exit requires a noexcept invocable type");
explicit scope_exit(ScopeExitInvocableType&& scope_exit_callable) :
- _on_scope_exit{std::forward<ScopeExitInvocableType>(scope_exit_callable)}
+ _on_scope_exit{ std::forward<ScopeExitInvocableType>(scope_exit_callable) }
{
}
- scope_exit(scope_exit&& rhs) :
- _on_scope_exit{std::move(rhs._on_scope_exit)}, _armed{rhs._armed}
+ scope_exit(scope_exit&& rhs) noexcept :
+ _on_scope_exit{ std::move(rhs._on_scope_exit) }, _armed{ rhs._armed }
{
/* Don't invoke ScopeExitInvocableType for the moved-from copy. */
rhs.disarm();
scope_exit<ScopeExitInvocableType> make_scope_exit(ScopeExitInvocableType&& scope_exit_callable)
{
return scope_exit<ScopeExitInvocableType>(
- std::forward<ScopeExitInvocableType>(scope_exit_callable));
+ std::forward<ScopeExitInvocableType>(scope_exit_callable));
}
} /* namespace lttng */
static struct lttng_uri *uri_copy(const struct lttng_uri *uri)
{
- struct lttng_uri *new_uri = NULL;
+ struct lttng_uri *new_uri = nullptr;
if (!uri) {
goto end;
static struct lttng_uri *uri_from_path(const char *path)
{
- struct lttng_uri *uris = NULL;
+ struct lttng_uri *uris = nullptr;
ssize_t uri_count;
char local_protocol_string[LTTNG_PATH_MAX + sizeof("file://")] = "file://";
return uris;
error:
free(uris);
- return NULL;
+ return nullptr;
}
static void network_location_fini(struct lttng_session_descriptor_network_location *location)
free(location->data);
location->control = control;
location->data = data;
- control = NULL;
- data = NULL;
+ control = nullptr;
+ data = nullptr;
end:
free(control);
free(data);
{
int ret = 0;
ssize_t uri_count;
- struct lttng_uri *parsed_uris = NULL;
- struct lttng_uri *control_uri = NULL;
- struct lttng_uri *data_uri = NULL;
+ struct lttng_uri *parsed_uris = nullptr;
+ struct lttng_uri *control_uri = nullptr;
+ struct lttng_uri *data_uri = nullptr;
uri_count = uri_parse_str_urls(control, data, &parsed_uris);
if (uri_count != 2 && uri_count != 0) {
/* Ownership of control and data uris is transferred. */
ret = network_location_set_from_lttng_uris(location, control_uri, data_uri);
- control_uri = NULL;
- data_uri = NULL;
+ control_uri = nullptr;
+ data_uri = nullptr;
end:
free(parsed_uris);
free(control_uri);
return descriptor;
error:
lttng_session_descriptor_destroy(descriptor);
- return NULL;
+ return nullptr;
}
/* Ownership of uri is transferred. */
goto error;
}
descriptor->output.local = uri;
- uri = NULL;
+ uri = nullptr;
}
return descriptor;
error:
free(uri);
lttng_session_descriptor_destroy(descriptor);
- return NULL;
+ return nullptr;
}
struct lttng_session_descriptor *lttng_session_descriptor_local_create(const char *name,
const char *path)
{
- struct lttng_uri *uri = NULL;
+ struct lttng_uri *uri = nullptr;
struct lttng_session_descriptor *descriptor;
if (path) {
descriptor = _lttng_session_descriptor_local_create(name, uri);
return descriptor;
error:
- return NULL;
+ return nullptr;
}
/* Assumes the ownership of both uris. */
descriptor->output_type = LTTNG_SESSION_DESCRIPTOR_OUTPUT_TYPE_NETWORK;
/* Assumes the ownership of both uris. */
ret = network_location_set_from_lttng_uris(&descriptor->output.network, control, data);
- control = NULL;
- data = NULL;
+ control = nullptr;
+ data = nullptr;
if (ret) {
goto error;
}
lttng_session_descriptor_destroy(descriptor);
free(control);
free(data);
- return NULL;
+ return nullptr;
}
struct lttng_session_descriptor *lttng_session_descriptor_network_create(const char *name,
int ret;
struct lttng_session_descriptor *descriptor;
- descriptor = _lttng_session_descriptor_network_create(name, NULL, NULL);
+ descriptor = _lttng_session_descriptor_network_create(name, nullptr, nullptr);
if (!descriptor) {
goto error;
}
return descriptor;
error:
lttng_session_descriptor_destroy(descriptor);
- return NULL;
+ return nullptr;
}
static struct lttng_session_descriptor_snapshot *
}
return descriptor;
error:
- lttng_session_descriptor_destroy(descriptor ? &descriptor->base : NULL);
- return NULL;
+ lttng_session_descriptor_destroy(descriptor ? &descriptor->base : nullptr);
+ return nullptr;
}
/* Ownership of control and data is transferred. */
descriptor->base.output_type = LTTNG_SESSION_DESCRIPTOR_OUTPUT_TYPE_NETWORK;
/* Ownership of control and data is transferred. */
ret = network_location_set_from_lttng_uris(&descriptor->base.output.network, control, data);
- control = NULL;
- data = NULL;
+ control = nullptr;
+ data = nullptr;
if (ret) {
goto error;
}
error:
free(control);
free(data);
- lttng_session_descriptor_destroy(descriptor ? &descriptor->base : NULL);
- return NULL;
+ lttng_session_descriptor_destroy(descriptor ? &descriptor->base : nullptr);
+ return nullptr;
}
struct lttng_session_descriptor *lttng_session_descriptor_snapshot_create(const char *name)
struct lttng_session_descriptor_snapshot *descriptor;
descriptor = _lttng_session_descriptor_snapshot_create(name);
- return descriptor ? &descriptor->base : NULL;
+ return descriptor ? &descriptor->base : nullptr;
}
struct lttng_session_descriptor *lttng_session_descriptor_snapshot_network_create(
int ret;
struct lttng_session_descriptor_snapshot *descriptor;
- descriptor = _lttng_session_descriptor_snapshot_network_create(name, NULL, NULL);
+ descriptor = _lttng_session_descriptor_snapshot_network_create(name, nullptr, nullptr);
if (!descriptor) {
goto error;
}
}
return &descriptor->base;
error:
- lttng_session_descriptor_destroy(descriptor ? &descriptor->base : NULL);
- return NULL;
+ lttng_session_descriptor_destroy(descriptor ? &descriptor->base : nullptr);
+ return nullptr;
}
/* Ownership of uri is transferred. */
goto error;
}
descriptor->base.output.local = uri;
- uri = NULL;
+ uri = nullptr;
}
return descriptor;
error:
free(uri);
- lttng_session_descriptor_destroy(descriptor ? &descriptor->base : NULL);
- return NULL;
+ lttng_session_descriptor_destroy(descriptor ? &descriptor->base : nullptr);
+ return nullptr;
}
struct lttng_session_descriptor *lttng_session_descriptor_snapshot_local_create(const char *name,
const char *path)
{
- struct lttng_uri *path_uri = NULL;
+ struct lttng_uri *path_uri = nullptr;
struct lttng_session_descriptor_snapshot *descriptor;
if (path) {
}
}
descriptor = _lttng_session_descriptor_snapshot_local_create(name, path_uri);
- return descriptor ? &descriptor->base : NULL;
+ return descriptor ? &descriptor->base : nullptr;
error:
- return NULL;
+ return nullptr;
}
static struct lttng_session_descriptor_live *
_lttng_session_descriptor_live_create(const char *name, unsigned long long live_timer_interval_us)
{
- struct lttng_session_descriptor_live *descriptor = NULL;
+ struct lttng_session_descriptor_live *descriptor = nullptr;
if (live_timer_interval_us == 0) {
goto error;
return descriptor;
error:
- lttng_session_descriptor_destroy(descriptor ? &descriptor->base : NULL);
- return NULL;
+ lttng_session_descriptor_destroy(descriptor ? &descriptor->base : nullptr);
+ return nullptr;
}
/* Ownership of control and data is transferred. */
/* Ownerwhip of control and data is transferred. */
ret = network_location_set_from_lttng_uris(&descriptor->base.output.network, control, data);
- control = NULL;
- data = NULL;
+ control = nullptr;
+ data = nullptr;
if (ret) {
goto error;
}
error:
free(control);
free(data);
- lttng_session_descriptor_destroy(descriptor ? &descriptor->base : NULL);
- return NULL;
+ lttng_session_descriptor_destroy(descriptor ? &descriptor->base : nullptr);
+ return nullptr;
}
struct lttng_session_descriptor *
descriptor = _lttng_session_descriptor_live_create(name, live_timer_us);
- return descriptor ? &descriptor->base : NULL;
+ return descriptor ? &descriptor->base : nullptr;
}
struct lttng_session_descriptor *
int ret;
struct lttng_session_descriptor_live *descriptor;
- descriptor = _lttng_session_descriptor_live_network_create(name, NULL, NULL, live_timer_us);
+ descriptor = _lttng_session_descriptor_live_network_create(
+ name, nullptr, nullptr, live_timer_us);
if (!descriptor) {
goto error;
}
}
return &descriptor->base;
error:
- lttng_session_descriptor_destroy(descriptor ? &descriptor->base : NULL);
- return NULL;
+ lttng_session_descriptor_destroy(descriptor ? &descriptor->base : nullptr);
+ return nullptr;
}
void lttng_session_descriptor_destroy(struct lttng_session_descriptor *descriptor)
int i;
ssize_t offset = 0, ret;
struct lttng_buffer_view current_view;
- const char *name = NULL;
+ const char *name = nullptr;
const struct lttng_session_descriptor_comm *base_header;
size_t max_expected_uri_count;
uint64_t live_timer_us = 0;
/* Already checked. */
abort();
}
- *descriptor = snapshot ? &snapshot->base : NULL;
+ *descriptor = snapshot ? &snapshot->base : nullptr;
break;
}
case LTTNG_SESSION_DESCRIPTOR_TYPE_LIVE:
/* Already checked. */
abort();
}
- *descriptor = live ? &live->base : NULL;
+ *descriptor = live ? &live->base : nullptr;
break;
}
default:
.live_timer_us = 0,
};
- const void *header_ptr = NULL;
+ const void *header_ptr = nullptr;
size_t header_size;
switch (descriptor->output_type) {
const char *absolute_home_path)
{
enum lttng_error_code ret_code = LTTNG_OK;
- struct lttng_uri *uris = NULL;
+ struct lttng_uri *uris = nullptr;
switch (descriptor->output_type) {
case LTTNG_SESSION_DESCRIPTOR_OUTPUT_TYPE_NONE:
}
free(descriptor->output.local);
descriptor->output.local = &uris[0];
- uris = NULL;
+ uris = nullptr;
break;
}
case LTTNG_SESSION_DESCRIPTOR_OUTPUT_TYPE_NETWORK:
{
int ret;
ssize_t uri_ret;
- struct lttng_uri *control = NULL, *data = NULL;
+ struct lttng_uri *control = nullptr, *data = nullptr;
- uri_ret = uri_parse_str_urls("net://127.0.0.1", NULL, &uris);
+ uri_ret = uri_parse_str_urls("net://127.0.0.1", nullptr, &uris);
if (uri_ret != 2) {
ret_code = LTTNG_ERR_SET_URL;
goto end;
break;
case LTTNG_SESSION_DESCRIPTOR_OUTPUT_TYPE_NETWORK:
{
- struct lttng_uri *control_copy = NULL, *data_copy = NULL;
+ struct lttng_uri *control_copy = nullptr, *data_copy = nullptr;
control_copy = uri_copy(dst->output.network.control);
if (!control_copy && dst->output.network.control) {
}
new_sock = lttcomm_alloc_sock(sock->proto);
- if (new_sock == NULL) {
+ if (new_sock == nullptr) {
goto error;
}
error:
free(new_sock);
- return NULL;
+ return nullptr;
}
/*
buf[size_ret] = '\0';
errno = 0;
- r_val = strtol(buf, NULL, 10);
+ r_val = strtol(buf, nullptr, 10);
if (errno != 0 || r_val < -1L) {
val = 0;
goto error_close;
return val;
}
-void lttcomm_inet_init(void)
+void lttcomm_inet_init()
{
unsigned long syn_retries, fin_timeout, syn_timeout, env;
const void *buf, size_t len, int flags);
/* Initialize inet communication layer. */
-extern void lttcomm_inet_init(void);
+extern void lttcomm_inet_init();
#endif /* _LTTCOMM_INET_H */
}
new_sock = lttcomm_alloc_sock(sock->proto);
- if (new_sock == NULL) {
+ if (new_sock == nullptr) {
goto error;
}
error:
free(new_sock);
- return NULL;
+ return nullptr;
}
/*
{
struct lttcomm_sock *sock = zmalloc<lttcomm_sock>();
- if (sock == NULL) {
+ if (sock == nullptr) {
PERROR("zmalloc create sock");
goto end;
}
LTTNG_ASSERT(src);
sock = lttcomm_alloc_sock(src->proto);
- if (sock == NULL) {
+ if (sock == nullptr) {
goto alloc_error;
}
{
int ret;
int _sock_proto;
- struct lttcomm_sock *sock = NULL;
+ struct lttcomm_sock *sock = nullptr;
/* Safety net */
LTTNG_ASSERT(uri);
}
sock = lttcomm_alloc_sock((lttcomm_sock_proto) _sock_proto);
- if (sock == NULL) {
+ if (sock == nullptr) {
goto alloc_error;
}
error:
lttcomm_destroy_sock(sock);
alloc_error:
- return NULL;
+ return nullptr;
}
/*
lttcomm_alloc_relayd_sock(struct lttng_uri *uri, uint32_t major, uint32_t minor)
{
int ret;
- struct lttcomm_sock *tmp_sock = NULL;
+ struct lttcomm_sock *tmp_sock = nullptr;
struct lttcomm_relayd_sock *rsock = zmalloc<lttcomm_relayd_sock>();
LTTNG_ASSERT(uri);
/* Allocate socket object from URI */
tmp_sock = lttcomm_alloc_sock_from_uri(uri);
- if (tmp_sock == NULL) {
+ if (tmp_sock == nullptr) {
goto error_free;
}
error_free:
free(rsock);
error:
- return NULL;
+ return nullptr;
}
/*
return 0;
}
-void lttcomm_init(void)
+void lttcomm_init()
{
const char *env;
long timeout;
errno = 0;
- timeout = strtol(env, NULL, 0);
+ timeout = strtol(env, nullptr, 0);
if (errno != 0 || timeout < -1L) {
PERROR("Network timeout");
} else {
}
}
-unsigned long lttcomm_get_network_timeout(void)
+unsigned long lttcomm_get_network_timeout()
{
return network_timeout;
}
*/
int lttcomm_sock_set_port(struct lttcomm_sock *sock, uint16_t port);
-void lttcomm_init(void);
+void lttcomm_init();
/* Get network timeout, in milliseconds */
-unsigned long lttcomm_get_network_timeout(void);
+unsigned long lttcomm_get_network_timeout();
#endif /* _LTTNG_SESSIOND_COMM_H */
goto error;
}
- wait_shm_mmap =
- (char *) mmap(NULL, mmap_size, PROT_WRITE | PROT_READ, MAP_SHARED, wait_shm_fd, 0);
+ wait_shm_mmap = (char *) mmap(
+ nullptr, mmap_size, PROT_WRITE | PROT_READ, MAP_SHARED, wait_shm_fd, 0);
/* close shm fd immediately after taking the mmap reference */
ret = close(wait_shm_fd);
return wait_shm_mmap;
error:
- return NULL;
+ return nullptr;
}
/*
struct lttng_snapshot_output **output_p)
{
const struct lttng_snapshot_output_comm *comm;
- struct lttng_snapshot_output *output = NULL;
+ struct lttng_snapshot_output *output = nullptr;
int ret;
if (view->buffer.size != sizeof(*comm)) {
}
*output_p = output;
- output = NULL;
+ output = nullptr;
ret = sizeof(*comm);
end:
} viewers[] = {
{ "babeltrace", VIEWER_BABELTRACE },
{ "babeltrace2", VIEWER_BABELTRACE2 },
- { NULL, VIEWER_USER_DEFINED },
+ { nullptr, VIEWER_USER_DEFINED },
};
} /* namespace */
static const struct viewer *parse_viewer_option(const char *opt_viewer)
{
- if (opt_viewer == NULL) {
+ if (opt_viewer == nullptr) {
/* Default is babeltrace2 */
return &(viewers[VIEWER_BABELTRACE2]);
}
{
int i = 0, ignore_space = 0;
unsigned int num_opts = 1;
- char **argv, *token = opts, *saveptr = NULL;
+ char **argv, *token = opts, *saveptr = nullptr;
/* Count number of arguments. */
do {
/* Add two here for the NULL terminating element and trace path */
argv = calloc<char *>(num_opts + 2);
- if (argv == NULL) {
+ if (argv == nullptr) {
goto error;
}
token = strtok_r(opts, " ", &saveptr);
- while (token != NULL) {
+ while (token != nullptr) {
argv[i] = strdup(token);
- if (argv[i] == NULL) {
+ if (argv[i] == nullptr) {
goto error;
}
- token = strtok_r(NULL, " ", &saveptr);
+ token = strtok_r(nullptr, " ", &saveptr);
i++;
}
argv[num_opts] = (char *) trace_path;
- argv[num_opts + 1] = NULL;
+ argv[num_opts + 1] = nullptr;
return argv;
free(argv);
}
- return NULL;
+ return nullptr;
}
/*
}
argv = calloc<char *>(mem_len);
- if (argv == NULL) {
+ if (argv == nullptr) {
goto error;
}
argv[opts_len] = (char *) "-i";
argv[opts_len + 1] = (char *) "lttng-live";
argv[opts_len + 2] = (char *) trace_path;
- argv[opts_len + 3] = NULL;
+ argv[opts_len + 3] = nullptr;
} else {
argv[opts_len] = (char *) trace_path;
- argv[opts_len + 1] = NULL;
+ argv[opts_len + 1] = nullptr;
}
error:
{
int ret = 0;
struct stat status;
- const char *viewer_bin = NULL;
+ const char *viewer_bin = nullptr;
const struct viewer *viewer;
- char **argv = NULL;
+ char **argv = nullptr;
/* Check for --viewer option. */
viewer = parse_viewer_option(opt_viewer);
- if (viewer == NULL) {
+ if (viewer == nullptr) {
ret = -1;
goto error;
}
abort();
}
- if (argv == NULL || !viewer_bin) {
+ if (argv == nullptr || !viewer_bin) {
ret = -1;
goto error;
}
viewers[VIEWER_BABELTRACE].exec_name);
viewer = &viewers[VIEWER_BABELTRACE];
free(argv);
- argv = NULL;
+ argv = nullptr;
goto retry_viewer;
} else {
ERR("Default viewer \"%s\" (and fallback \"%s\") not found on the system",
{
char *old = *s;
char *new_str;
- size_t oldlen = (old == NULL) ? 0 : strlen(old);
+ size_t oldlen = (old == nullptr) ? 0 : strlen(old);
size_t appendlen = strlen(append);
new_str = zmalloc<char>(oldlen + appendlen + 1);
/* Compute length of formatted string we append. */
va_start(args, fmt);
- ret = vsnprintf(NULL, 0, fmt, args);
+ ret = vsnprintf(nullptr, 0, fmt, args);
va_end(args);
if (ret == -1) {
free(*s);
*s = new_str;
- new_str = NULL;
+ new_str = nullptr;
end:
return ret;
/*
* Toggle the support for testpoints on the application startup.
*/
-static void __attribute__((constructor)) lttng_testpoint_check(void)
+static void __attribute__((constructor)) lttng_testpoint_check()
{
- char *testpoint_env_val = NULL;
+ char *testpoint_env_val = nullptr;
testpoint_env_val = getenv(lttng_testpoint_env_var);
- if (testpoint_env_val != NULL && (strncmp(testpoint_env_val, "1", 1) == 0)) {
+ if (testpoint_env_val != nullptr && (strncmp(testpoint_env_val, "1", 1) == 0)) {
lttng_testpoint_activated = 1;
}
}
void *lttng_testpoint_lookup(const char *name)
{
if (!name) {
- return NULL;
+ return nullptr;
}
return dlsym(RTLD_DEFAULT, name);
static bool utf8_output_supported;
-bool locale_supports_utf8(void)
+bool locale_supports_utf8()
{
return utf8_output_supported;
}
return res;
}
-static void __attribute__((constructor)) init_locale_utf8_support(void)
+static void __attribute__((constructor)) init_locale_utf8_support()
{
- const char *program_locale = setlocale(LC_ALL, NULL);
+ const char *program_locale = setlocale(LC_ALL, nullptr);
const char *lang = getenv("LANG");
if (program_locale && strstr(program_locale, "utf8")) {
#define ISO8601_STR_LEN sizeof("YYYYmmddTHHMMSS+HHMM")
#define DATETIME_STR_LEN sizeof("YYYYmmdd-HHMMSS")
-bool locale_supports_utf8(void);
+bool locale_supports_utf8();
#define NSEC_UNIT "ns"
#define USEC_UNIT (locale_supports_utf8() ? "µs" : "us")
*
* Note that a trace chunk registry may only be accessed by an RCU thread.
*/
-struct lttng_trace_chunk_registry *lttng_trace_chunk_registry_create(void);
+struct lttng_trace_chunk_registry *lttng_trace_chunk_registry_create();
/*
* Destroy an lttng trace chunk registry. The registry must be emptied
const char *path,
int fd)
{
- struct fs_handle_untracked *handle = NULL;
+ struct fs_handle_untracked *handle = nullptr;
bool reference_acquired;
char *path_copy = strdup(path);
handle->location.directory_handle = directory_handle;
/* Ownership is transferred. */
handle->location.path = path_copy;
- path_copy = NULL;
+ path_copy = nullptr;
end:
free(path_copy);
- return handle ? &handle->parent : NULL;
+ return handle ? &handle->parent : nullptr;
}
static int fs_handle_untracked_get_fd(struct fs_handle *_handle)
generate_chunk_name(uint64_t chunk_id, time_t creation_timestamp, const time_t *close_timestamp)
{
int ret = 0;
- char *new_name = NULL;
+ char *new_name = nullptr;
char start_datetime[ISO8601_STR_LEN] = {};
/* Add 1 for a '-' prefix. */
char end_datetime_suffix[ISO8601_STR_LEN + 1] = {};
return new_name;
error:
free(new_name);
- return NULL;
+ return nullptr;
}
static void lttng_trace_chunk_init(struct lttng_trace_chunk *chunk)
{
urcu_ref_init(&chunk->ref);
- pthread_mutex_init(&chunk->lock, NULL);
+ pthread_mutex_init(&chunk->lock, nullptr);
lttng_dynamic_pointer_array_init(&chunk->top_level_directories, free);
lttng_dynamic_pointer_array_init(&chunk->files, free);
}
{
if (chunk->session_output_directory) {
lttng_directory_handle_put(chunk->session_output_directory);
- chunk->session_output_directory = NULL;
+ chunk->session_output_directory = nullptr;
}
if (chunk->chunk_directory) {
lttng_directory_handle_put(chunk->chunk_directory);
- chunk->chunk_directory = NULL;
+ chunk->chunk_directory = nullptr;
}
free(chunk->name);
- chunk->name = NULL;
+ chunk->name = nullptr;
free(chunk->path);
- chunk->path = NULL;
+ chunk->path = nullptr;
lttng_dynamic_pointer_array_reset(&chunk->top_level_directories);
lttng_dynamic_pointer_array_reset(&chunk->files);
pthread_mutex_destroy(&chunk->lock);
}
-static struct lttng_trace_chunk *lttng_trace_chunk_allocate(void)
+static struct lttng_trace_chunk *lttng_trace_chunk_allocate()
{
- struct lttng_trace_chunk *chunk = NULL;
+ struct lttng_trace_chunk *chunk = nullptr;
chunk = zmalloc<lttng_trace_chunk>();
if (!chunk) {
return chunk;
}
-struct lttng_trace_chunk *lttng_trace_chunk_create_anonymous(void)
+struct lttng_trace_chunk *lttng_trace_chunk_create_anonymous()
{
DBG("Creating anonymous trace chunk");
return lttng_trace_chunk_allocate();
LTTNG_OPTIONAL_SET(&chunk->id, chunk_id);
LTTNG_OPTIONAL_SET(&chunk->timestamp_creation, chunk_creation_time);
if (chunk_id != 0) {
- chunk->name = generate_chunk_name(chunk_id, chunk_creation_time, NULL);
+ chunk->name = generate_chunk_name(chunk_id, chunk_creation_time, nullptr);
if (!chunk->name) {
ERR("Failed to allocate trace chunk name storage");
goto error;
return chunk;
error:
lttng_trace_chunk_put(chunk);
- return NULL;
+ return nullptr;
}
void lttng_trace_chunk_set_fd_tracker(struct lttng_trace_chunk *chunk,
error_unlock:
pthread_mutex_unlock(&source_chunk->lock);
lttng_trace_chunk_put(new_chunk);
- return NULL;
+ return nullptr;
}
enum lttng_trace_chunk_status lttng_trace_chunk_get_id(struct lttng_trace_chunk *chunk,
{
enum lttng_trace_chunk_status status = LTTNG_TRACE_CHUNK_STATUS_OK;
- struct lttng_directory_handle *rename_directory = NULL;
+ struct lttng_directory_handle *rename_directory = nullptr;
char *new_path, *old_path;
int ret;
chunk->session_output_directory,
path,
LTTNG_OPTIONAL_GET(chunk->credentials).use_current_user ?
- NULL :
+ nullptr :
&chunk->credentials.value.user);
if (ret) {
PERROR("Failed to move trace chunk directory \"%s\" to \"%s\"",
* handle.
*/
chunk->chunk_directory = rename_directory;
- rename_directory = NULL;
+ rename_directory = nullptr;
} else if (old_path && old_path[0] == '\0') {
size_t i,
count = lttng_dynamic_pointer_array_get_count(
path,
DIR_CREATION_MODE,
LTTNG_OPTIONAL_GET(chunk->credentials).use_current_user ?
- NULL :
+ nullptr :
&chunk->credentials.value.user);
if (ret) {
PERROR("Failed to create trace chunk rename directory \"%s\"", path);
rename_directory,
top_level_name,
LTTNG_OPTIONAL_GET(chunk->credentials).use_current_user ?
- NULL :
+ nullptr :
&chunk->credentials.value.user);
if (ret) {
PERROR("Failed to move \"%s\" to trace chunk rename directory",
* handle.
*/
chunk->chunk_directory = rename_directory;
- rename_directory = NULL;
+ rename_directory = nullptr;
} else if (old_path) {
size_t i,
count = lttng_dynamic_pointer_array_get_count(
rename_directory,
top_level_name,
LTTNG_OPTIONAL_GET(chunk->credentials).use_current_user ?
- NULL :
+ nullptr :
&chunk->credentials.value.user);
if (ret) {
PERROR("Failed to move \"%s\" to trace chunk rename directory",
* handle.
*/
chunk->chunk_directory = rename_directory;
- rename_directory = NULL;
+ rename_directory = nullptr;
/* Remove old directory. */
status = (lttng_trace_chunk_status) lttng_directory_handle_remove_subdirectory(
{
int ret;
enum lttng_trace_chunk_status status = LTTNG_TRACE_CHUNK_STATUS_OK;
- struct lttng_directory_handle *chunk_directory_handle = NULL;
+ struct lttng_directory_handle *chunk_directory_handle = nullptr;
bool reference_acquired;
pthread_mutex_lock(&chunk->lock);
DIR_CREATION_MODE,
!chunk->credentials.value.use_current_user ?
&chunk->credentials.value.user :
- NULL);
+ nullptr);
if (ret) {
PERROR("Failed to create chunk output directory \"%s\"", chunk->path);
status = LTTNG_TRACE_CHUNK_STATUS_ERROR;
chunk_directory_handle = session_output_directory;
}
chunk->chunk_directory = chunk_directory_handle;
- chunk_directory_handle = NULL;
+ chunk_directory_handle = nullptr;
reference_acquired = lttng_directory_handle_get(session_output_directory);
LTTNG_ASSERT(reference_acquired);
chunk->session_output_directory = session_output_directory;
pthread_mutex_lock(&chunk->lock);
if (!chunk->session_output_directory) {
status = LTTNG_TRACE_CHUNK_STATUS_NONE;
- *handle = NULL;
+ *handle = nullptr;
goto end;
} else {
const bool reference_acquired =
chunk->chunk_directory,
path,
DIR_CREATION_MODE,
- chunk->credentials.value.use_current_user ? NULL : &chunk->credentials.value.user);
+ chunk->credentials.value.use_current_user ? nullptr :
+ &chunk->credentials.value.user);
if (ret) {
PERROR("Failed to create trace chunk subdirectory \"%s\"", path);
status = LTTNG_TRACE_CHUNK_STATUS_ERROR;
int ret;
enum lttng_trace_chunk_status status = LTTNG_TRACE_CHUNK_STATUS_OK;
- if (lttng_trace_chunk_find_file(chunk, path, NULL)) {
+ if (lttng_trace_chunk_find_file(chunk, path, nullptr)) {
return LTTNG_TRACE_CHUNK_STATUS_OK;
}
DBG("Adding new file \"%s\" to trace chunk \"%s\"", path, chunk->name ?: "(unnamed)");
file_path,
flags,
mode,
- chunk->credentials.value.use_current_user ? NULL :
+ chunk->credentials.value.use_current_user ? nullptr :
&chunk->credentials.value.user);
if (ret >= 0) {
*out_handle =
status = LTTNG_TRACE_CHUNK_STATUS_ERROR;
goto end;
}
- ret = lttng_directory_handle_unlink_file_as_user(
- chunk->chunk_directory,
- file_path,
- chunk->credentials.value.use_current_user ? NULL : &chunk->credentials.value.user);
+ ret = lttng_directory_handle_unlink_file_as_user(chunk->chunk_directory,
+ file_path,
+ chunk->credentials.value.use_current_user ?
+ nullptr :
+ &chunk->credentials.value.user);
if (ret < 0) {
status = LTTNG_TRACE_CHUNK_STATUS_ERROR;
goto end;
ret = lttng_directory_handle_remove_subdirectory_recursive_as_user(
chunk->chunk_directory,
path,
- chunk->credentials.value.use_current_user ? NULL : &chunk->credentials.value.user,
+ chunk->credentials.value.use_current_user ? nullptr :
+ &chunk->credentials.value.user,
LTTNG_DIRECTORY_HANDLE_SKIP_NON_EMPTY_FLAG);
if (ret < 0) {
status = LTTNG_TRACE_CHUNK_STATUS_ERROR;
static int lttng_trace_chunk_move_to_completed_post_release(struct lttng_trace_chunk *trace_chunk)
{
int ret = 0;
- char *archived_chunk_name = NULL;
+ char *archived_chunk_name = nullptr;
const uint64_t chunk_id = LTTNG_OPTIONAL_GET(trace_chunk->id);
const time_t creation_timestamp = LTTNG_OPTIONAL_GET(trace_chunk->timestamp_creation);
const time_t close_timestamp = LTTNG_OPTIONAL_GET(trace_chunk->timestamp_close);
- struct lttng_directory_handle *archived_chunks_directory = NULL;
+ struct lttng_directory_handle *archived_chunks_directory = nullptr;
enum lttng_trace_chunk_status status;
if (!trace_chunk->mode.is_set || trace_chunk->mode.value != TRACE_CHUNK_MODE_OWNER ||
DIR_CREATION_MODE,
!trace_chunk->credentials.value.use_current_user ?
&trace_chunk->credentials.value.user :
- NULL);
+ nullptr);
if (ret) {
PERROR("Failed to create \"" DEFAULT_ARCHIVED_TRACE_CHUNKS_DIRECTORY
"\" directory for archived trace chunks");
archived_chunks_directory,
archived_chunk_name,
LTTNG_OPTIONAL_GET(trace_chunk->credentials).use_current_user ?
- NULL :
+ nullptr :
&trace_chunk->credentials.value.user);
if (ret) {
PERROR("Failed to rename folder \"%s\" to \"%s\"",
}
if (!ret) {
lttng_directory_handle_put(trace_chunk->chunk_directory);
- trace_chunk->chunk_directory = NULL;
+ trace_chunk->chunk_directory = nullptr;
if (trace_chunk->path && trace_chunk->path[0] != '\0') {
status = (lttng_trace_chunk_status)
}
}
free(trace_chunk->path);
- trace_chunk->path = NULL;
+ trace_chunk->path = nullptr;
end:
return ret;
}
urcu_ref_put(&chunk->ref, lttng_trace_chunk_release);
}
-struct lttng_trace_chunk_registry *lttng_trace_chunk_registry_create(void)
+struct lttng_trace_chunk_registry *lttng_trace_chunk_registry_create()
{
struct lttng_trace_chunk_registry *registry;
}
registry->ht = cds_lfht_new(
- DEFAULT_HT_SIZE, 1, 0, CDS_LFHT_AUTO_RESIZE | CDS_LFHT_ACCOUNTING, NULL);
+ DEFAULT_HT_SIZE, 1, 0, CDS_LFHT_AUTO_RESIZE | CDS_LFHT_ACCOUNTING, nullptr);
if (!registry->ht) {
goto error;
}
return registry;
error:
lttng_trace_chunk_registry_destroy(registry);
- return NULL;
+ return nullptr;
}
void lttng_trace_chunk_registry_destroy(struct lttng_trace_chunk_registry *registry)
return;
}
if (registry->ht) {
- int ret = cds_lfht_destroy(registry->ht, NULL);
+ int ret = cds_lfht_destroy(registry->ht, nullptr);
LTTNG_ASSERT(!ret);
}
free(registry);
if (chunk->session_output_directory) {
/* Transferred ownership. */
element->chunk.session_output_directory = chunk->session_output_directory;
- chunk->session_output_directory = NULL;
+ chunk->session_output_directory = nullptr;
}
if (chunk->chunk_directory) {
/* Transferred ownership. */
element->chunk.chunk_directory = chunk->chunk_directory;
- chunk->chunk_directory = NULL;
+ chunk->chunk_directory = nullptr;
}
/*
* The original chunk becomes invalid; the name and path attributes are
* transferred to the new chunk instance.
*/
- chunk->name = NULL;
- chunk->path = NULL;
+ chunk->name = nullptr;
+ chunk->path = nullptr;
element->chunk.fd_tracker = chunk->fd_tracker;
element->chunk.in_registry_element = true;
end:
* chunk is now invalid, the only valid operation is a 'put' from the
* caller.
*/
- chunk = NULL;
+ chunk = nullptr;
element_hash = lttng_trace_chunk_registry_element_hash(element);
rcu_read_lock();
- while (1) {
+ while (true) {
struct cds_lfht_node *published_node;
struct lttng_trace_chunk *published_chunk;
struct lttng_trace_chunk_registry_element *published_element;
}
rcu_read_unlock();
end:
- return element ? &element->chunk : NULL;
+ return element ? &element->chunk : nullptr;
}
/*
const unsigned long element_hash = lttng_trace_chunk_registry_element_hash(&target_element);
struct cds_lfht_node *published_node;
struct lttng_trace_chunk_registry_element *published_element;
- struct lttng_trace_chunk *published_chunk = NULL;
+ struct lttng_trace_chunk *published_chunk = nullptr;
struct cds_lfht_iter iter;
rcu_read_lock();
lttng_trace_chunk_registry_find_anonymous_chunk(const struct lttng_trace_chunk_registry *registry,
uint64_t session_id)
{
- return _lttng_trace_chunk_registry_find_chunk(registry, session_id, NULL);
+ return _lttng_trace_chunk_registry_find_chunk(registry, session_id, nullptr);
}
unsigned int
LTTNG_TRACE_CHUNK_COMMAND_TYPE_MAX,
};
-struct lttng_trace_chunk *lttng_trace_chunk_create_anonymous(void);
+struct lttng_trace_chunk *lttng_trace_chunk_create_anonymous();
struct lttng_trace_chunk *lttng_trace_chunk_create(
uint64_t chunk_id,
const struct lttng_buffer_view *value_view,
struct process_attr_value **_value)
{
- char *name = NULL;
+ char *name = nullptr;
enum lttng_error_code ret = LTTNG_OK;
struct process_attr_value *value = zmalloc<process_attr_value>();
}
value->value.user_name = name;
- name = NULL;
+ name = nullptr;
break;
default:
ERR("Invalid value type used for user ID process attribute");
}
value->value.group_name = name;
- name = NULL;
+ name = nullptr;
break;
default:
ERR("Invalid value type used for group ID process attribute");
}
*_value = value;
- value = NULL;
+ value = nullptr;
free(name);
return LTTNG_OK;
error:
process_attr_value_destroy(value);
}
-struct lttng_process_attr_values *lttng_process_attr_values_create(void)
+struct lttng_process_attr_values *lttng_process_attr_values_create()
{
struct lttng_process_attr_values *values = zmalloc<lttng_process_attr_values>();
.type = (int32_t) value->type,
.value = {},
};
- const char *name = NULL;
+ const char *name = nullptr;
switch (value->type) {
case LTTNG_PROCESS_ATTR_VALUE_TYPE_PID:
struct process_attr_value *process_attr_value_copy(const struct process_attr_value *value)
{
- struct process_attr_value *new_value = NULL;
+ struct process_attr_value *new_value = nullptr;
if (!value) {
goto end;
return new_value;
error:
free(new_value);
- return NULL;
+ return nullptr;
}
unsigned long process_attr_value_hash(const struct process_attr_value *a)
const char *lttng_process_attr_to_string(enum lttng_process_attr process_attr);
-struct lttng_process_attr_values *lttng_process_attr_values_create(void);
+struct lttng_process_attr_values *lttng_process_attr_values_create();
/* Prefixed with '_' since the name conflicts with a public API. */
unsigned int _lttng_process_attr_values_get_count(
struct lttng_trigger *lttng_trigger_create(struct lttng_condition *condition,
struct lttng_action *action)
{
- struct lttng_trigger *trigger = NULL;
+ struct lttng_trigger *trigger = nullptr;
if (!condition || !action) {
goto end;
lttng_action_get(action);
trigger->action = action;
- pthread_mutex_init(&trigger->lock, NULL);
+ pthread_mutex_init(&trigger->lock, nullptr);
trigger->registered = false;
end:
*/
struct lttng_condition *lttng_trigger_get_condition(struct lttng_trigger *trigger)
{
- return trigger ? trigger->condition : NULL;
+ return trigger ? trigger->condition : nullptr;
}
const struct lttng_condition *lttng_trigger_get_const_condition(const struct lttng_trigger *trigger)
{
- return trigger ? trigger->condition : NULL;
+ return trigger ? trigger->condition : nullptr;
}
/*
*/
struct lttng_action *lttng_trigger_get_action(struct lttng_trigger *trigger)
{
- return trigger ? trigger->action : NULL;
+ return trigger ? trigger->action : nullptr;
}
const struct lttng_action *lttng_trigger_get_const_action(const struct lttng_trigger *trigger)
{
- return trigger ? trigger->action : NULL;
+ return trigger ? trigger->action : nullptr;
}
static void trigger_destroy_ref(struct urcu_ref *ref)
struct lttng_trigger **_trigger)
{
ssize_t ret, offset = 0, condition_size, action_size, name_size = 0;
- struct lttng_condition *condition = NULL;
- struct lttng_action *action = NULL;
+ struct lttng_condition *condition = nullptr;
+ struct lttng_action *action = nullptr;
const struct lttng_trigger_comm *trigger_comm;
- const char *name = NULL;
+ const char *name = nullptr;
struct lttng_credentials creds = {
.uid = LTTNG_OPTIONAL_INIT_UNSET,
.gid = LTTNG_OPTIONAL_INIT_UNSET,
};
- struct lttng_trigger *trigger = NULL;
+ struct lttng_trigger *trigger = nullptr;
const struct lttng_payload_view trigger_comm_view =
lttng_payload_view_from_view(src_view, 0, sizeof(*trigger_comm));
* objects.
*/
lttng_condition_put(condition);
- condition = NULL;
+ condition = nullptr;
lttng_action_put(action);
- action = NULL;
+ action = nullptr;
if (name) {
const enum lttng_trigger_status status = lttng_trigger_set_name(trigger, name);
size_t header_offset, size_before_payload, size_name;
struct lttng_trigger_comm trigger_comm = {};
struct lttng_trigger_comm *header;
- const struct lttng_credentials *creds = NULL;
+ const struct lttng_credentials *creds = nullptr;
creds = lttng_trigger_get_credentials(trigger);
LTTNG_ASSERT(creds);
trigger_comm.uid = LTTNG_OPTIONAL_GET(creds->uid);
- if (trigger->name != NULL) {
+ if (trigger->name != nullptr) {
size_name = strlen(trigger->name) + 1;
} else {
size_name = 0;
enum lttng_trigger_status lttng_trigger_set_name(struct lttng_trigger *trigger, const char *name)
{
- char *name_copy = NULL;
+ char *name_copy = nullptr;
enum lttng_trigger_status status = LTTNG_TRIGGER_STATUS_OK;
if (!trigger) {
free(trigger->name);
trigger->name = name_copy;
- name_copy = NULL;
+ name_copy = nullptr;
end:
return status;
}
int lttng_trigger_generate_name(struct lttng_trigger *trigger, uint64_t unique_id)
{
int ret = 0;
- char *generated_name = NULL;
+ char *generated_name = nullptr;
ret = asprintf(&generated_name, "trigger%" PRIu64 "", unique_id);
if (ret < 0) {
lttng_trigger_put(trigger);
}
-struct lttng_triggers *lttng_triggers_create(void)
+struct lttng_triggers *lttng_triggers_create()
{
- struct lttng_triggers *triggers = NULL;
+ struct lttng_triggers *triggers = nullptr;
triggers = zmalloc<lttng_triggers>();
if (!triggers) {
struct lttng_trigger *lttng_triggers_borrow_mutable_at_index(const struct lttng_triggers *triggers,
unsigned int index)
{
- struct lttng_trigger *trigger = NULL;
+ struct lttng_trigger *trigger = nullptr;
LTTNG_ASSERT(triggers);
if (index >= lttng_dynamic_pointer_array_get_count(&triggers->array)) {
ssize_t ret, offset = 0, triggers_size = 0;
unsigned int i;
const struct lttng_triggers_comm *triggers_comm;
- struct lttng_triggers *local_triggers = NULL;
+ struct lttng_triggers *local_triggers = nullptr;
if (!src_view || !triggers) {
ret = -1;
}
for (i = 0; i < triggers_comm->count; i++) {
- struct lttng_trigger *trigger = NULL;
+ struct lttng_trigger *trigger = nullptr;
struct lttng_payload_view trigger_view =
lttng_payload_view_from_view(src_view, offset, -1);
ssize_t trigger_size;
/* Pass ownership to caller. */
*triggers = local_triggers;
- local_triggers = NULL;
+ local_triggers = nullptr;
ret = offset;
error:
uid_t *uid)
{
enum lttng_trigger_status ret = LTTNG_TRIGGER_STATUS_OK;
- const struct lttng_credentials *creds = NULL;
+ const struct lttng_credentials *creds = nullptr;
if (!trigger || !uid) {
ret = LTTNG_TRIGGER_STATUS_INVALID;
const struct lttng_credentials *creds)
{
enum lttng_error_code ret;
- struct lttng_condition *condition = NULL;
+ struct lttng_condition *condition = nullptr;
condition = lttng_trigger_get_condition(trigger);
if (!condition) {
{
int ret;
struct lttng_payload copy_buffer;
- struct lttng_condition *condition_copy = NULL;
- struct lttng_action *action_copy = NULL;
- struct lttng_trigger *copy = NULL;
+ struct lttng_condition *condition_copy = nullptr;
+ struct lttng_action *action_copy = nullptr;
+ struct lttng_trigger *copy = nullptr;
enum lttng_trigger_status trigger_status;
const char *trigger_name;
uid_t trigger_owner_uid;
error_cleanup_trigger:
lttng_trigger_destroy(copy);
- copy = NULL;
+ copy = nullptr;
end:
lttng_condition_put(condition_copy);
lttng_action_put(action_copy);
int ret;
enum lttng_error_code ret_code;
enum lttng_trigger_status trigger_status;
- const struct lttng_condition *condition = NULL;
- const struct lttng_action *action = NULL;
+ const struct lttng_condition *condition = nullptr;
+ const struct lttng_action *action = nullptr;
struct lttng_dynamic_array action_path_indexes;
uid_t owner_uid;
LTTNG_ASSERT(trigger);
LTTNG_ASSERT(writer);
- lttng_dynamic_array_init(&action_path_indexes, sizeof(uint64_t), NULL);
+ lttng_dynamic_array_init(&action_path_indexes, sizeof(uint64_t), nullptr);
/* Open trigger element. */
ret = mi_lttng_writer_open_element(writer, mi_lttng_element_trigger);
}
if (error_query_callbacks && error_query_callbacks->trigger_cb) {
- struct lttng_error_query_results *results = NULL;
+ struct lttng_error_query_results *results = nullptr;
ret_code = error_query_callbacks->trigger_cb(trigger, &results);
if (ret_code != LTTNG_OK) {
* Sort trigger by name to ensure an order at the MI level and ignore
* any anonymous trigger present.
*/
- lttng_dynamic_pointer_array_init(&sorted_triggers, NULL);
+ lttng_dynamic_pointer_array_init(&sorted_triggers, nullptr);
status = lttng_triggers_get_count(triggers, &count);
LTTNG_ASSERT(status == LTTNG_TRIGGER_STATUS_OK);
struct lttng_dynamic_array raw_fds;
const int fd_count = lttng_payload_view_get_fd_handle_count(view);
- lttng_dynamic_array_init(&raw_fds, sizeof(int), NULL);
+ lttng_dynamic_array_init(&raw_fds, sizeof(int), nullptr);
if (fd_count < 0) {
ret = -LTTNG_ERR_INVALID;
* need to expect a cmsg of the SCM_CREDENTIALS as the first control
* message.
*/
- for (cmsg = CMSG_FIRSTHDR(&msg); cmsg != NULL; cmsg = CMSG_NXTHDR(&msg, cmsg)) {
+ for (cmsg = CMSG_FIRSTHDR(&msg); cmsg != nullptr; cmsg = CMSG_NXTHDR(&msg, cmsg)) {
if (cmsg->cmsg_level != SOL_SOCKET) {
fprintf(stderr, "Error: The socket needs to be of type SOL_SOCKET\n");
ret = -1;
* need to expect a cmsg of the SCM_CREDENTIALS as the first control
* message.
*/
- for (cmsg = CMSG_FIRSTHDR(&msg); cmsg != NULL; cmsg = CMSG_NXTHDR(&msg, cmsg)) {
+ for (cmsg = CMSG_FIRSTHDR(&msg); cmsg != nullptr; cmsg = CMSG_NXTHDR(&msg, cmsg)) {
if (cmsg->cmsg_level != SOL_SOCKET) {
fprintf(stderr, "Error: The socket needs to be of type SOL_SOCKET\n");
ret = -1;
}
cmptr = CMSG_FIRSTHDR(&msg);
- if (cmptr == NULL) {
+ if (cmptr == nullptr) {
fprintf(stderr, "Error: Invalid control message header\n");
ret = -1;
goto end;
static inline const char *strpbrk_or_eos(const char *s, const char *accept)
{
char *p = (char *) strpbrk(s, accept);
- if (p == NULL) {
+ if (p == nullptr) {
p = (char *) strchr(s, '\0');
}
*/
static const struct uri_proto *get_uri_proto(const char *uri_str)
{
- const struct uri_proto *supported = NULL;
+ const struct uri_proto *supported = nullptr;
/* Safety net */
- if (uri_str == NULL) {
+ if (uri_str == nullptr) {
goto end;
}
- for (supported = &proto_uri[0]; supported->leading_string != NULL; ++supported) {
+ for (supported = &proto_uri[0]; supported->leading_string != nullptr; ++supported) {
if (strncasecmp(uri_str,
supported->leading_string,
strlen(supported->leading_string)) == 0) {
}
/* Proto not found */
- return NULL;
+ return nullptr;
end:
return supported;
unsigned int ctrl_port = 0;
unsigned int data_port = 0;
struct lttng_uri *tmp_uris;
- char *addr_f = NULL;
+ char *addr_f = nullptr;
const struct uri_proto *proto;
- const char *purl, *addr_e, *addr_b, *subdir_b = NULL;
+ const char *purl, *addr_e, *addr_b, *subdir_b = nullptr;
const char *seps = ":/\0";
/*
DBG3("URI string: %s", str_uri);
proto = get_uri_proto(str_uri);
- if (proto == NULL) {
+ if (proto == nullptr) {
ERR("URI parse unknown protocol %s", str_uri);
goto error;
}
/* Allocate URI array */
tmp_uris = calloc<lttng_uri>(size);
- if (tmp_uris == NULL) {
+ if (tmp_uris == nullptr) {
PERROR("zmalloc uri");
goto error;
}
/* Address begins after '[' */
addr_b = purl + 1;
addr_e = strchr(addr_b, ']');
- if (addr_e == NULL || addr_b == addr_e) {
+ if (addr_e == nullptr || addr_b == addr_e) {
ERR("Broken IPv6 address %s", addr_b);
goto free_error;
}
/*
* The closing bracket must be followed by a seperator or NULL char.
*/
- if (strchr(seps, *purl) == NULL) {
+ if (strchr(seps, *purl) == nullptr) {
ERR("Unknown symbol after IPv6 address: %s", purl);
goto free_error;
}
}
addr_f = utils_strdupdelim(addr_b, addr_e);
- if (addr_f == NULL) {
+ if (addr_f == nullptr) {
goto free_error;
}
int port;
port_f = utils_strdupdelim(port_b, port_e);
- if (port_f == NULL) {
+ if (port_f == nullptr) {
goto free_error;
}
/* Add the "file://" size to the URL maximum size */
char url[PATH_MAX + 7];
ssize_t ctrl_uri_count = 0, data_uri_count = 0, uri_count;
- struct lttng_uri *ctrl_uris = NULL, *data_uris = NULL;
- struct lttng_uri *tmp_uris = NULL;
+ struct lttng_uri *ctrl_uris = nullptr, *data_uris = nullptr;
+ struct lttng_uri *tmp_uris = nullptr;
/* No URL(s) is allowed. This means that the consumer will be disabled. */
- if (ctrl_url == NULL && data_url == NULL) {
+ if (ctrl_url == nullptr && data_url == nullptr) {
return 0;
}
* The data_url and ctrl_url are equal and the ctrl_url
* contains a net:// protocol so we just skip the data part.
*/
- data_url = NULL;
+ data_url = nullptr;
}
}
}
}
tmp_uris = calloc<lttng_uri>(uri_count);
- if (tmp_uris == NULL) {
+ if (tmp_uris == nullptr) {
PERROR("zmalloc uris");
goto error;
}
struct lttng_userspace_probe_location_lookup_method *
lttng_userspace_probe_location_lookup_method_function_elf_create(void)
{
- struct lttng_userspace_probe_location_lookup_method *ret = NULL;
+ struct lttng_userspace_probe_location_lookup_method *ret = nullptr;
struct lttng_userspace_probe_location_lookup_method_elf *elf_method;
elf_method = zmalloc<lttng_userspace_probe_location_lookup_method_elf>();
struct lttng_userspace_probe_location_lookup_method *
lttng_userspace_probe_location_lookup_method_tracepoint_sdt_create(void)
{
- struct lttng_userspace_probe_location_lookup_method *ret = NULL;
+ struct lttng_userspace_probe_location_lookup_method *ret = nullptr;
struct lttng_userspace_probe_location_lookup_method_sdt *sdt_method;
sdt_method = zmalloc<lttng_userspace_probe_location_lookup_method_sdt>();
static void
lttng_userspace_probe_location_function_destroy(struct lttng_userspace_probe_location *location)
{
- struct lttng_userspace_probe_location_function *location_function = NULL;
+ struct lttng_userspace_probe_location_function *location_function = nullptr;
LTTNG_ASSERT(location);
static void
lttng_userspace_probe_location_tracepoint_destroy(struct lttng_userspace_probe_location *location)
{
- struct lttng_userspace_probe_location_tracepoint *location_tracepoint = NULL;
+ struct lttng_userspace_probe_location_tracepoint *location_tracepoint = nullptr;
LTTNG_ASSERT(location);
bool open_binary)
{
int binary_fd = -1;
- struct fd_handle *binary_fd_handle = NULL;
- char *function_name_copy = NULL, *binary_path_copy = NULL;
- struct lttng_userspace_probe_location *ret = NULL;
+ struct fd_handle *binary_fd_handle = nullptr;
+ char *function_name_copy = nullptr, *binary_path_copy = nullptr;
+ struct lttng_userspace_probe_location *ret = nullptr;
struct lttng_userspace_probe_location_function *location;
if (open_binary) {
location->function_name = function_name_copy;
location->binary_path = binary_path_copy;
location->binary_fd_handle = binary_fd_handle;
- binary_fd_handle = NULL;
+ binary_fd_handle = nullptr;
location->instrumentation_type =
LTTNG_USERSPACE_PROBE_LOCATION_FUNCTION_INSTRUMENTATION_TYPE_ENTRY;
bool open_binary)
{
int binary_fd = -1;
- struct fd_handle *binary_fd_handle = NULL;
- char *probe_name_copy = NULL;
- char *provider_name_copy = NULL;
- char *binary_path_copy = NULL;
- struct lttng_userspace_probe_location *ret = NULL;
+ struct fd_handle *binary_fd_handle = nullptr;
+ char *probe_name_copy = nullptr;
+ char *provider_name_copy = nullptr;
+ char *binary_path_copy = nullptr;
+ struct lttng_userspace_probe_location *ret = nullptr;
struct lttng_userspace_probe_location_tracepoint *location;
if (open_binary) {
location->provider_name = provider_name_copy;
location->binary_path = binary_path_copy;
location->binary_fd_handle = binary_fd_handle;
- binary_fd_handle = NULL;
+ binary_fd_handle = nullptr;
ret = &location->parent;
ret->lookup_method = lookup_method;
const char *function_name,
struct lttng_userspace_probe_location_lookup_method *lookup_method)
{
- struct lttng_userspace_probe_location *ret = NULL;
+ struct lttng_userspace_probe_location *ret = nullptr;
if (!binary_path || !function_name) {
ERR("Invalid argument(s) passed to '%s'", __FUNCTION__);
const char *probe_name,
struct lttng_userspace_probe_location_lookup_method *lookup_method)
{
- struct lttng_userspace_probe_location *ret = NULL;
+ struct lttng_userspace_probe_location *ret = nullptr;
if (!binary_path || !probe_name || !provider_name) {
ERR("Invalid argument(s) passed to '%s'", __FUNCTION__);
lttng_userspace_probe_location_lookup_method_function_elf_copy(
const struct lttng_userspace_probe_location_lookup_method *lookup_method)
{
- struct lttng_userspace_probe_location_lookup_method *parent = NULL;
+ struct lttng_userspace_probe_location_lookup_method *parent = nullptr;
struct lttng_userspace_probe_location_lookup_method_elf *elf_method;
LTTNG_ASSERT(lookup_method);
goto end;
error:
- parent = NULL;
+ parent = nullptr;
end:
return parent;
}
lttng_userspace_probe_location_lookup_method_tracepoint_sdt_copy(
struct lttng_userspace_probe_location_lookup_method *lookup_method)
{
- struct lttng_userspace_probe_location_lookup_method *parent = NULL;
+ struct lttng_userspace_probe_location_lookup_method *parent = nullptr;
struct lttng_userspace_probe_location_lookup_method_sdt *sdt_method;
LTTNG_ASSERT(lookup_method);
goto end;
error:
- parent = NULL;
+ parent = nullptr;
end:
return parent;
}
lttng_userspace_probe_location_function_copy(const struct lttng_userspace_probe_location *location)
{
enum lttng_userspace_probe_location_lookup_method_type lookup_type;
- struct lttng_userspace_probe_location *new_location = NULL;
- struct lttng_userspace_probe_location_lookup_method *lookup_method = NULL;
- const char *binary_path = NULL;
- const char *function_name = NULL;
+ struct lttng_userspace_probe_location *new_location = nullptr;
+ struct lttng_userspace_probe_location_lookup_method *lookup_method = nullptr;
+ const char *binary_path = nullptr;
+ const char *function_name = nullptr;
struct lttng_userspace_probe_location_function *function_location;
LTTNG_ASSERT(location);
destroy_lookup_method:
lttng_userspace_probe_location_lookup_method_destroy(lookup_method);
error:
- new_location = NULL;
+ new_location = nullptr;
end:
return new_location;
}
const struct lttng_userspace_probe_location *location)
{
enum lttng_userspace_probe_location_lookup_method_type lookup_type;
- struct lttng_userspace_probe_location *new_location = NULL;
- struct lttng_userspace_probe_location_lookup_method *lookup_method = NULL;
- const char *binary_path = NULL;
- const char *probe_name = NULL;
- const char *provider_name = NULL;
+ struct lttng_userspace_probe_location *new_location = nullptr;
+ struct lttng_userspace_probe_location_lookup_method *lookup_method = nullptr;
+ const char *binary_path = nullptr;
+ const char *probe_name = nullptr;
+ const char *provider_name = nullptr;
struct lttng_userspace_probe_location_tracepoint *tracepoint_location;
LTTNG_ASSERT(location);
destroy_lookup_method:
lttng_userspace_probe_location_lookup_method_destroy(lookup_method);
error:
- new_location = NULL;
+ new_location = nullptr;
end:
return new_location;
}
const char *lttng_userspace_probe_location_function_get_binary_path(
const struct lttng_userspace_probe_location *location)
{
- const char *ret = NULL;
+ const char *ret = nullptr;
struct lttng_userspace_probe_location_function *function_location;
if (!location ||
const char *lttng_userspace_probe_location_tracepoint_get_binary_path(
const struct lttng_userspace_probe_location *location)
{
- const char *ret = NULL;
+ const char *ret = nullptr;
struct lttng_userspace_probe_location_tracepoint *tracepoint_location;
if (!location ||
const char *lttng_userspace_probe_location_function_get_function_name(
const struct lttng_userspace_probe_location *location)
{
- const char *ret = NULL;
+ const char *ret = nullptr;
struct lttng_userspace_probe_location_function *function_location;
if (!location ||
const char *lttng_userspace_probe_location_tracepoint_get_probe_name(
const struct lttng_userspace_probe_location *location)
{
- const char *ret = NULL;
+ const char *ret = nullptr;
struct lttng_userspace_probe_location_tracepoint *tracepoint_location;
if (!location ||
const char *lttng_userspace_probe_location_tracepoint_get_provider_name(
const struct lttng_userspace_probe_location *location)
{
- const char *ret = NULL;
+ const char *ret = nullptr;
struct lttng_userspace_probe_location_tracepoint *tracepoint_location;
if (!location ||
lttng_userspace_probe_location_function_get_lookup_method(
const struct lttng_userspace_probe_location *location)
{
- struct lttng_userspace_probe_location_lookup_method *ret = NULL;
+ struct lttng_userspace_probe_location_lookup_method *ret = nullptr;
if (!location ||
lttng_userspace_probe_location_get_type(location) !=
lttng_userspace_probe_location_tracepoint_get_lookup_method(
const struct lttng_userspace_probe_location *location)
{
- struct lttng_userspace_probe_location_lookup_method *ret = NULL;
+ struct lttng_userspace_probe_location_lookup_method *ret = nullptr;
if (!location ||
lttng_userspace_probe_location_get_type(location) !=
lttng_userspace_probe_location_get_lookup_method(
const struct lttng_userspace_probe_location *location)
{
- struct lttng_userspace_probe_location_lookup_method *ret = NULL;
+ struct lttng_userspace_probe_location_lookup_method *ret = nullptr;
LTTNG_ASSERT(location);
switch (location->type) {
{
struct lttng_userspace_probe_location_function_comm *location_function_comm;
const char *function_name_src, *binary_path_src;
- char *function_name = NULL, *binary_path = NULL;
+ char *function_name = nullptr, *binary_path = nullptr;
int ret = 0;
size_t expected_size;
struct fd_handle *binary_fd_handle = lttng_payload_view_pop_fd_handle(view);
}
*location = lttng_userspace_probe_location_function_create_no_check(
- binary_path, function_name, NULL, false);
+ binary_path, function_name, nullptr, false);
if (!(*location)) {
ret = -LTTNG_ERR_INVALID;
goto end;
{
struct lttng_userspace_probe_location_tracepoint_comm *location_tracepoint_comm;
const char *probe_name_src, *provider_name_src, *binary_path_src;
- char *probe_name = NULL, *provider_name = NULL, *binary_path = NULL;
+ char *probe_name = nullptr, *provider_name = nullptr, *binary_path = nullptr;
int ret = 0;
size_t expected_size;
struct fd_handle *binary_fd_handle = lttng_payload_view_pop_fd_handle(view);
}
*location = lttng_userspace_probe_location_tracepoint_create_no_check(
- binary_path, provider_name, probe_name, NULL, false);
+ binary_path, provider_name, probe_name, nullptr, false);
if (!(*location)) {
ret = -LTTNG_ERR_INVALID;
goto end;
type = (enum lttng_userspace_probe_location_lookup_method_type) lookup_comm->type;
switch (type) {
case LTTNG_USERSPACE_PROBE_LOCATION_LOOKUP_METHOD_TYPE_FUNCTION_DEFAULT:
- *lookup_method = NULL;
+ *lookup_method = nullptr;
break;
case LTTNG_USERSPACE_PROBE_LOCATION_LOOKUP_METHOD_TYPE_FUNCTION_ELF:
*lookup_method = lttng_userspace_probe_location_lookup_method_function_elf_create();
LTTNG_ASSERT(view);
LTTNG_ASSERT(location);
- lookup_method = NULL;
+ lookup_method = nullptr;
if (!lttng_payload_view_is_valid(&probe_location_comm_view)) {
ret = -LTTNG_ERR_INVALID;
LTTNG_ASSERT(lookup_method);
(*location)->lookup_method = lookup_method;
- lookup_method = NULL;
+ lookup_method = nullptr;
ret += consumed;
end:
return ret;
*) (flat_probe_start + sizeof(flat_probe) + function_name_len +
binary_path_len + padding_needed);
} else {
- flat_probe.parent.lookup_method = NULL;
+ flat_probe.parent.lookup_method = nullptr;
}
flat_probe.function_name = flat_probe_start + sizeof(flat_probe);
flat_probe.binary_path = flat_probe.function_name + function_name_len;
- flat_probe.binary_fd_handle = NULL;
+ flat_probe.binary_fd_handle = nullptr;
ret = lttng_dynamic_buffer_append(buffer, &flat_probe, sizeof(flat_probe));
if (ret) {
goto end;
*) (flat_probe_start + sizeof(flat_probe) + probe_name_len +
provider_name_len + binary_path_len + padding_needed);
} else {
- flat_probe.parent.lookup_method = NULL;
+ flat_probe.parent.lookup_method = nullptr;
}
flat_probe.probe_name = flat_probe_start + sizeof(flat_probe);
flat_probe.provider_name = flat_probe.probe_name + probe_name_len;
flat_probe.binary_path = flat_probe.provider_name + provider_name_len;
- flat_probe.binary_fd_handle = NULL;
+ flat_probe.binary_fd_handle = nullptr;
ret = lttng_dynamic_buffer_append(buffer, &flat_probe, sizeof(flat_probe));
if (ret) {
goto end;
struct lttng_userspace_probe_location *
lttng_userspace_probe_location_copy(const struct lttng_userspace_probe_location *location)
{
- struct lttng_userspace_probe_location *new_location = NULL;
+ struct lttng_userspace_probe_location *new_location = nullptr;
enum lttng_userspace_probe_location_type type;
if (!location) {
}
break;
default:
- new_location = NULL;
+ new_location = nullptr;
goto err;
}
err:
int ret;
enum lttng_error_code ret_code;
- mi_fp mi_function = NULL;
+ mi_fp mi_function = nullptr;
LTTNG_ASSERT(location);
LTTNG_ASSERT(writer);
{
int ret;
enum lttng_error_code ret_code;
- const char *probe_name = NULL;
- const char *provider_name = NULL;
- const char *binary_path = NULL;
- const struct lttng_userspace_probe_location_lookup_method *lookup_method = NULL;
+ const char *probe_name = nullptr;
+ const char *provider_name = nullptr;
+ const char *binary_path = nullptr;
+ const struct lttng_userspace_probe_location_lookup_method *lookup_method = nullptr;
LTTNG_ASSERT(location);
LTTNG_ASSERT(writer);
{
int ret;
enum lttng_error_code ret_code;
- const char *function_name = NULL;
- const char *binary_path = NULL;
- const char *instrumentation_type_str = NULL;
+ const char *function_name = nullptr;
+ const char *binary_path = nullptr;
+ const char *instrumentation_type_str = nullptr;
enum lttng_userspace_probe_location_function_instrumentation_type instrumentation_type;
- const struct lttng_userspace_probe_location_lookup_method *lookup_method = NULL;
+ const struct lttng_userspace_probe_location_lookup_method *lookup_method = nullptr;
LTTNG_ASSERT(location);
LTTNG_ASSERT(writer);
LTTNG_ASSERT(channel);
LTTNG_ASSERT(ctx);
- if (ctx->on_recv_channel != NULL) {
+ if (ctx->on_recv_channel != nullptr) {
ret = ctx->on_recv_channel(channel);
if (ret == 0) {
ret = consumer_add_channel(channel, ctx);
int *_alloc_ret)
{
int alloc_ret;
- struct lttng_consumer_stream *stream = NULL;
+ struct lttng_consumer_stream *stream = nullptr;
LTTNG_ASSERT(channel);
LTTNG_ASSERT(ctx);
&alloc_ret,
channel->type,
channel->monitor);
- if (stream == NULL) {
+ if (stream == nullptr) {
switch (alloc_ret) {
case -ENOENT:
/*
int ret, cpu = 0;
struct lttng_ust_ctl_consumer_stream *ustream;
struct lttng_consumer_stream *stream;
- pthread_mutex_t *current_stream_lock = NULL;
+ pthread_mutex_t *current_stream_lock = nullptr;
LTTNG_ASSERT(channel);
LTTNG_ASSERT(ctx);
}
}
pthread_mutex_unlock(&stream->lock);
- current_stream_lock = NULL;
+ current_stream_lock = nullptr;
}
return 0;
}
/* Tell sessiond there is no more stream. */
- ret = lttng_ust_ctl_send_stream_to_sessiond(sock, NULL);
+ ret = lttng_ust_ctl_send_stream_to_sessiond(sock, nullptr);
if (ret < 0) {
goto error;
}
* the stream is still in the local stream list of the channel. This call
* will make sure to clean that list.
*/
- consumer_stream_destroy(metadata->metadata_stream, NULL);
- metadata->metadata_stream = NULL;
+ consumer_stream_destroy(metadata->metadata_stream, nullptr);
+ metadata->metadata_stream = nullptr;
send_streams_error:
error_no_stream:
end:
* Clean up the stream completely because the next snapshot will use a
* new metadata stream.
*/
- consumer_stream_destroy(metadata_stream, NULL);
- metadata_channel->metadata_stream = NULL;
+ consumer_stream_destroy(metadata_stream, nullptr);
+ metadata_channel->metadata_stream = nullptr;
error:
rcu_read_unlock();
* channel is under a snapshot session type. No need to update
* the stream position in that scenario.
*/
- if (channel->metadata_stream != NULL) {
+ if (channel->metadata_stream != nullptr) {
pthread_mutex_lock(&channel->metadata_stream->lock);
metadata_stream_reset_cache_consumed_position(channel->metadata_stream);
pthread_mutex_unlock(&channel->metadata_stream->lock);
int ret_func;
enum lttcomm_return_code ret_code = LTTCOMM_CONSUMERD_SUCCESS;
struct lttcomm_consumer_msg msg;
- struct lttng_consumer_channel *channel = NULL;
+ struct lttng_consumer_channel *channel = nullptr;
health_code_update();
/* Get relayd reference if exists. */
relayd = consumer_find_relayd(index);
- if (relayd == NULL) {
+ if (relayd == nullptr) {
DBG("Unable to find relayd %" PRIu64, index);
ret_code = LTTCOMM_CONSUMERD_RELAYD_FAIL;
}
channel = consumer_allocate_channel(
msg.u.ask_channel.key,
msg.u.ask_channel.session_id,
- msg.u.ask_channel.chunk_id.is_set ? &chunk_id : NULL,
+ msg.u.ask_channel.chunk_id.is_set ? &chunk_id : nullptr,
msg.u.ask_channel.pathname,
msg.u.ask_channel.name,
msg.u.ask_channel.relayd_id,
const uint64_t relayd_id = msg.u.create_trace_chunk.relayd_id.value;
const char *chunk_override_name = *msg.u.create_trace_chunk.override_name ?
msg.u.create_trace_chunk.override_name :
- NULL;
- struct lttng_directory_handle *chunk_directory_handle = NULL;
+ nullptr;
+ struct lttng_directory_handle *chunk_directory_handle = nullptr;
/*
* The session daemon will only provide a chunk directory file
}
ret_code = lttng_consumer_create_trace_chunk(
- !is_local_trace ? &relayd_id : NULL,
+ !is_local_trace ? &relayd_id : nullptr,
msg.u.create_trace_chunk.session_id,
msg.u.create_trace_chunk.chunk_id,
(time_t) msg.u.create_trace_chunk.creation_timestamp,
chunk_override_name,
- msg.u.create_trace_chunk.credentials.is_set ? &credentials : NULL,
+ msg.u.create_trace_chunk.credentials.is_set ? &credentials : nullptr,
chunk_directory_handle);
lttng_directory_handle_put(chunk_directory_handle);
goto end_msg_sessiond;
int ret;
ret_code = lttng_consumer_close_trace_chunk(
- msg.u.close_trace_chunk.relayd_id.is_set ? &relayd_id : NULL,
+ msg.u.close_trace_chunk.relayd_id.is_set ? &relayd_id : nullptr,
msg.u.close_trace_chunk.session_id,
msg.u.close_trace_chunk.chunk_id,
(time_t) msg.u.close_trace_chunk.close_timestamp,
- msg.u.close_trace_chunk.close_command.is_set ? &close_command : NULL,
+ msg.u.close_trace_chunk.close_command.is_set ? &close_command : nullptr,
closed_trace_chunk_path);
reply.ret_code = ret_code;
reply.path_length = strlen(closed_trace_chunk_path) + 1;
const uint64_t relayd_id = msg.u.trace_chunk_exists.relayd_id.value;
ret_code = lttng_consumer_trace_chunk_exists(
- msg.u.trace_chunk_exists.relayd_id.is_set ? &relayd_id : NULL,
+ msg.u.trace_chunk_exists.relayd_id.is_set ? &relayd_id : nullptr,
msg.u.trace_chunk_exists.session_id,
msg.u.trace_chunk_exists.chunk_id);
goto end_msg_sessiond;
{
int ret_send_status;
- ret_send_status = consumer_send_status_channel(sock, NULL);
+ ret_send_status = consumer_send_status_channel(sock, nullptr);
if (ret_send_status < 0) {
/* Stop everything if session daemon can not be notified. */
goto error_fatal;
subbuffer->buffer.buffer =
lttng_buffer_view_init(addr, 0, subbuffer->info.data.padded_subbuf_size);
- LTTNG_ASSERT(subbuffer->buffer.buffer.data != NULL);
+ LTTNG_ASSERT(subbuffer->buffer.buffer.data != nullptr);
end:
return ret;
}
#define PROC_MEMINFO_MEMAVAILABLE_LINE "MemAvailable:"
#define PROC_MEMINFO_MEMTOTAL_LINE "MemTotal:"
-/* The length of the longest field of `/proc/meminfo`. */
+/* The lnullptrh of the longest field of `/proc/meminfo`. */
#define PROC_MEMINFO_FIELD_MAX_NAME_LEN 20
#if (PROC_MEMINFO_FIELD_MAX_NAME_LEN == 20)
{
int ret;
- if (dst == NULL) {
+ if (dst == nullptr) {
return -1;
}
{
int ret, i;
- if (dst == NULL) {
+ if (dst == nullptr) {
return -1;
}
{
int ret, i;
- if (dst == NULL) {
+ if (dst == nullptr) {
return -1;
}
{
int i, ret;
- if (src == NULL) {
+ if (src == nullptr) {
return;
}
{
char *str = zmalloc<char>(end - begin + 1);
- if (str == NULL) {
+ if (str == nullptr) {
PERROR("zmalloc strdupdelim");
goto error;
}
int utils_create_pid_file(pid_t pid, const char *filepath)
{
int ret, fd = -1;
- FILE *fp = NULL;
+ FILE *fp = nullptr;
LTTNG_ASSERT(filepath);
}
fp = fdopen(fd, "w");
- if (fp == NULL) {
+ if (fp == nullptr) {
PERROR("fdopen file %s", filepath);
ret = -1;
if (close(fd)) {
.gid = LTTNG_OPTIONAL_INIT_VALUE((gid_t) gid),
};
- handle = lttng_directory_handle_create(NULL);
+ handle = lttng_directory_handle_create(nullptr);
if (!handle) {
ret = -1;
goto end;
}
ret = lttng_directory_handle_create_subdirectory_as_user(
- handle, path, mode, (uid >= 0 || gid >= 0) ? &creds : NULL);
+ handle, path, mode, (uid >= 0 || gid >= 0) ? &creds : nullptr);
end:
lttng_directory_handle_put(handle);
return ret;
.gid = LTTNG_OPTIONAL_INIT_VALUE((gid_t) gid),
};
- handle = lttng_directory_handle_create(NULL);
+ handle = lttng_directory_handle_create(nullptr);
if (!handle) {
ret = -1;
goto end;
}
ret = lttng_directory_handle_create_subdirectory_recursive_as_user(
- handle, path, mode, (uid >= 0 || gid >= 0) ? &creds : NULL);
+ handle, path, mode, (uid >= 0 || gid >= 0) ? &creds : nullptr);
end:
lttng_directory_handle_put(handle);
return ret;
}
/* strtoull will accept a negative number, but we don't want to. */
- if (strchr(str, '-') != NULL) {
+ if (strchr(str, '-') != nullptr) {
DBG("utils_parse_size_suffix: invalid size string, should not contain '-'.");
ret = -1;
goto end;
}
/* strtoull will accept a negative number, but we don't want to. */
- if (strchr(str, '-') != NULL) {
+ if (strchr(str, '-') != nullptr) {
DBG("utils_parse_time_suffix: invalid time string, should not contain '-'.");
ret = -1;
goto end;
* Obtain the value of LTTNG_HOME environment variable, if exists.
* Otherwise returns the value of HOME.
*/
-const char *utils_get_home_dir(void)
+const char *utils_get_home_dir()
{
- char *val = NULL;
+ char *val = nullptr;
struct passwd *pwd;
val = lttng_secure_getenv(DEFAULT_LTTNG_HOME_ENV_VAR);
- if (val != NULL) {
+ if (val != nullptr) {
goto end;
}
val = lttng_secure_getenv(DEFAULT_LTTNG_FALLBACK_HOME_ENV_VAR);
- if (val != NULL) {
+ if (val != nullptr) {
goto end;
}
{
struct passwd pwd;
struct passwd *result;
- char *home_dir = NULL;
- char *buf = NULL;
+ char *home_dir = nullptr;
+ char *buf = nullptr;
long buflen;
int ret;
int ret;
struct lttng_directory_handle *handle;
- handle = lttng_directory_handle_create(NULL);
+ handle = lttng_directory_handle_create(nullptr);
if (!handle) {
ret = -1;
goto end;
return ret;
}
-static const char *get_man_bin_path(void)
+static const char *get_man_bin_path()
{
char *env_man_path = lttng_secure_getenv(DEFAULT_MAN_BIN_PATH_ENV);
struct passwd p, *pres;
int ret;
enum lttng_error_code ret_val = LTTNG_OK;
- char *buf = NULL;
+ char *buf = nullptr;
ssize_t buflen;
buflen = sysconf(_SC_GETPW_R_SIZE_MAX);
switch (ret) {
case 0:
- if (pres == NULL) {
+ if (pres == nullptr) {
ret_val = LTTNG_ERR_USER_NOT_FOUND;
} else {
*uid = p.pw_uid;
struct group g, *gres;
int ret;
enum lttng_error_code ret_val = LTTNG_OK;
- char *buf = NULL;
+ char *buf = nullptr;
ssize_t buflen;
buflen = sysconf(_SC_GETGR_R_SIZE_MAX);
switch (ret) {
case 0:
- if (gres == NULL) {
+ if (gres == nullptr) {
ret_val = LTTNG_ERR_GROUP_NOT_FOUND;
} else {
*gid = g.gr_gid;
int utils_parse_time_suffix(char const * const str, uint64_t * const time_us);
int utils_get_count_order_u32(uint32_t x);
int utils_get_count_order_u64(uint64_t x);
-const char *utils_get_home_dir(void);
+const char *utils_get_home_dir();
char *utils_get_user_home_dir(uid_t uid);
size_t utils_get_current_time_str(const char *format, char *dst, size_t len)
caa_cpu_relax();
}
while (uatomic_read(&waiter->state) == WAITER_WAITING) {
- if (!futex_noasync(&waiter->state, FUTEX_WAIT, WAITER_WAITING, NULL, NULL, 0)) {
+ if (!futex_noasync(
+ &waiter->state, FUTEX_WAIT, WAITER_WAITING, nullptr, nullptr, 0)) {
/*
* Prior queued wakeups queued by unrelated code
* using the same address can cause futex wait to
caa_cpu_relax();
}
while (!(uatomic_read(&waiter->state) & WAITER_TEARDOWN)) {
- poll(NULL, 0, 10);
+ poll(nullptr, 0, 10);
}
LTTNG_ASSERT(uatomic_read(&waiter->state) & WAITER_TEARDOWN);
DBG("End of waiter wait period");
LTTNG_ASSERT(uatomic_read(&waiter->state) == WAITER_WAITING);
uatomic_set(&waiter->state, WAITER_WOKEN_UP);
if (!(uatomic_read(&waiter->state) & WAITER_RUNNING)) {
- if (futex_noasync(&waiter->state, FUTEX_WAKE, 1, NULL, NULL, 0) < 0) {
+ if (futex_noasync(&waiter->state, FUTEX_WAKE, 1, nullptr, nullptr, 0) < 0) {
PERROR("futex_noasync");
abort();
}
create_notification_from_current_message(struct lttng_notification_channel *channel)
{
ssize_t ret;
- struct lttng_notification *notification = NULL;
+ struct lttng_notification *notification = nullptr;
if (channel->reception_payload.buffer.size <=
sizeof(struct lttng_notification_channel_message)) {
channel->reception_payload.buffer.size -
sizeof(struct lttng_notification_channel_message)) {
lttng_notification_destroy(notification);
- notification = NULL;
+ notification = nullptr;
goto end;
}
end:
{
int fd, ret;
bool is_in_tracing_group = false, is_root = false;
- char *sock_path = NULL;
- struct lttng_notification_channel *channel = NULL;
+ char *sock_path = nullptr;
+ struct lttng_notification_channel *channel = nullptr;
if (!endpoint || endpoint != lttng_session_daemon_notification_endpoint) {
goto end;
goto end;
}
channel->socket = -1;
- pthread_mutex_init(&channel->lock, NULL);
+ pthread_mutex_init(&channel->lock, nullptr);
lttng_payload_init(&channel->reception_payload);
CDS_INIT_LIST_HEAD(&channel->pending_notifications.list);
return channel;
error:
lttng_notification_channel_destroy(channel);
- channel = NULL;
+ channel = nullptr;
goto end;
}
struct lttng_notification **_notification)
{
int ret;
- struct lttng_notification *notification = NULL;
+ struct lttng_notification *notification = nullptr;
enum lttng_notification_channel_status status = LTTNG_NOTIFICATION_CHANNEL_STATUS_OK;
struct lttng_poll_event events;
* that notifications were dropped at this point.
*/
lttng_notification_destroy(pending_notification->notification);
- pending_notification->notification = NULL;
+ pending_notification->notification = nullptr;
goto end;
}
return handle;
error:
lttng_clear_handle_destroy(handle);
- return NULL;
+ return nullptr;
}
static int handle_state_transition(struct lttng_clear_handle *handle)
struct lttng_clear_handle **_handle)
{
enum lttng_error_code ret_code = LTTNG_OK;
- struct lttng_clear_handle *handle = NULL;
+ struct lttng_clear_handle *handle = nullptr;
struct lttcomm_session_msg lsm = {
.cmd_type = LTTCOMM_SESSIOND_COMMAND_CLEAR_SESSION,
.session = {},
ssize_t comm_ret;
int ret;
- if (session_name == NULL) {
+ if (session_name == nullptr) {
ret_code = LTTNG_ERR_INVALID;
goto error;
}
/* Transfer the handle to the caller. */
if (_handle) {
*_handle = handle;
- handle = NULL;
+ handle = nullptr;
}
if (sessiond_socket >= 0) {
ret = close(sessiond_socket);
return handle;
error:
lttng_destruction_handle_destroy(handle);
- return NULL;
+ return nullptr;
}
static int handle_state_transition(struct lttng_destruction_handle *handle)
.fd_count = 0,
};
int sessiond_socket = -1;
- struct lttng_destruction_handle *handle = NULL;
+ struct lttng_destruction_handle *handle = nullptr;
if (!session_name) {
ret_code = LTTNG_ERR_INVALID;
/* Transfer the handle to the caller. */
if (_handle) {
*_handle = handle;
- handle = NULL;
+ handle = nullptr;
}
error:
if (sessiond_socket >= 0) {
return event;
error:
free(event);
- event = NULL;
+ event = nullptr;
goto end;
}
* This can happen since the lttng_event structure is
* used for other tasks where this pointer is never set.
*/
- *filter_expression = NULL;
+ *filter_expression = nullptr;
goto end;
}
const struct lttng_userspace_probe_location *
lttng_event_get_userspace_probe_location(const struct lttng_event *event)
{
- struct lttng_userspace_probe_location *probe_location = NULL;
+ struct lttng_userspace_probe_location *probe_location = nullptr;
struct lttng_event_extended *event_extended;
if (!event) {
const char *lttng_load_session_attr_get_session_name(struct lttng_load_session_attr *attr)
{
- const char *ret = NULL;
+ const char *ret = nullptr;
if (attr && attr->session_name[0]) {
ret = attr->session_name;
const char *lttng_load_session_attr_get_input_url(struct lttng_load_session_attr *attr)
{
- const char *ret = NULL;
+ const char *ret = nullptr;
if (attr && attr->input_url[0]) {
ret = attr->input_url;
const char *lttng_load_session_attr_get_override_ctrl_url(struct lttng_load_session_attr *attr)
{
- const char *ret = NULL;
+ const char *ret = nullptr;
if (!attr || !attr->override_attr) {
goto end;
const char *lttng_load_session_attr_get_override_data_url(struct lttng_load_session_attr *attr)
{
- const char *ret = NULL;
+ const char *ret = nullptr;
if (!attr || !attr->override_attr) {
goto end;
const char *lttng_load_session_attr_get_override_url(struct lttng_load_session_attr *attr)
{
- const char *ret = NULL;
+ const char *ret = nullptr;
if (!attr || !attr->override_attr) {
goto end;
const char *lttng_load_session_attr_get_override_session_name(struct lttng_load_session_attr *attr)
{
- const char *ret = NULL;
+ const char *ret = nullptr;
if (!attr || !attr->override_attr) {
goto end;
int ret = 0;
size_t len;
ssize_t size;
- struct lttng_uri *uris = NULL;
+ struct lttng_uri *uris = nullptr;
if (!attr) {
ret = -LTTNG_ERR_INVALID;
goto error;
}
- size = uri_parse_str_urls(url, NULL, &uris);
+ size = uri_parse_str_urls(url, nullptr, &uris);
if (size <= 0 || uris[0].dtype != LTTNG_DST_PATH) {
ret = -LTTNG_ERR_INVALID;
goto error;
{
int ret = 0;
ssize_t ret_size;
- struct lttng_uri *uri = NULL;
- char *url_str = NULL;
- char *raw_str = NULL;
+ struct lttng_uri *uri = nullptr;
+ char *url_str = nullptr;
+ char *raw_str = nullptr;
if (!attr) {
ret = -LTTNG_ERR_INVALID;
attr->raw_override_ctrl_url = raw_str;
/* Ownership passed to attr. */
- url_str = NULL;
- raw_str = NULL;
+ url_str = nullptr;
+ raw_str = nullptr;
end:
free(raw_str);
{
int ret = 0;
ssize_t ret_size;
- struct lttng_uri *uri = NULL;
- char *url_str = NULL;
- char *raw_str = NULL;
+ struct lttng_uri *uri = nullptr;
+ char *url_str = nullptr;
+ char *raw_str = nullptr;
if (!attr) {
ret = -LTTNG_ERR_INVALID;
attr->raw_override_data_url = raw_str;
/* Ownership passed to attr. */
- url_str = NULL;
- raw_str = NULL;
+ url_str = nullptr;
+ raw_str = nullptr;
end:
free(raw_str);
free(url_str);
{
int ret = 0;
ssize_t ret_size;
- struct lttng_uri *uri = NULL;
- char *raw_url_str = NULL;
- char *raw_path_str = NULL;
- char *path_str = NULL;
- char *raw_ctrl_str = NULL;
- char *ctrl_str = NULL;
- char *raw_data_str = NULL;
- char *data_str = NULL;
+ struct lttng_uri *uri = nullptr;
+ char *raw_url_str = nullptr;
+ char *raw_path_str = nullptr;
+ char *path_str = nullptr;
+ char *raw_ctrl_str = nullptr;
+ char *ctrl_str = nullptr;
+ char *raw_data_str = nullptr;
+ char *data_str = nullptr;
char buffer[PATH_MAX];
if (!attr || !url || strlen(url) >= PATH_MAX) {
* type to validate "url". For now only check the parsing goes through;
* it will fail later on.
*/
- ret_size = uri_parse_str_urls(url, NULL, &uri);
+ ret_size = uri_parse_str_urls(url, nullptr, &uri);
if (ret_size < 0 || ret_size > 2) {
/* Unexpected URL format. */
ret = -LTTNG_ERR_INVALID;
attr->raw_override_data_url = raw_data_str;
/* Pass data ownership to attr. */
- raw_url_str = NULL;
- raw_path_str = NULL;
- path_str = NULL;
- raw_ctrl_str = NULL;
- ctrl_str = NULL;
- raw_data_str = NULL;
- data_str = NULL;
+ raw_url_str = nullptr;
+ raw_path_str = nullptr;
+ path_str = nullptr;
+ raw_ctrl_str = nullptr;
+ ctrl_str = nullptr;
+ raw_data_str = nullptr;
+ data_str = nullptr;
end:
free(raw_path_str);
goto end;
}
- url = attr->input_url[0] != '\0' ? attr->input_url : NULL;
- session_name = attr->session_name[0] != '\0' ? attr->session_name : NULL;
+ url = attr->input_url[0] != '\0' ? attr->input_url : nullptr;
+ session_name = attr->session_name[0] != '\0' ? attr->session_name : nullptr;
ret = config_load_session(url, session_name, attr->overwrite, 0, attr->override_attr);
* required size (excluding closing null).
*/
home = utils_get_home_dir();
- if (home == NULL) {
+ if (home == nullptr) {
/* Fallback in /tmp */
home = "/tmp";
}
lh = zmalloc<lttng_health>(sizeof(*lh) + sizeof(lh->thread[0]) * nr_threads);
if (!lh) {
- return NULL;
+ return nullptr;
}
lh->component = hc;
lh = lttng_health_create(HEALTH_COMPONENT_SESSIOND, NR_HEALTH_SESSIOND_TYPES);
if (!lh) {
- return NULL;
+ return nullptr;
}
return lh;
}
lh = lttng_health_create(HEALTH_COMPONENT_CONSUMERD, NR_HEALTH_CONSUMERD_TYPES);
if (!lh) {
- return NULL;
+ return nullptr;
}
lh->consumerd_type = consumerd;
return lh;
struct lttng_health *lttng_health_create_relayd(const char *path)
{
int ret;
- struct lttng_health *lh = NULL;
+ struct lttng_health *lh = nullptr;
if (!path) {
goto error;
error:
free(lh);
- return NULL;
+ return nullptr;
}
void lttng_health_destroy(struct lttng_health *lh)
unsigned int nth_thread)
{
if (!health || nth_thread >= health->nr_threads) {
- return NULL;
+ return nullptr;
}
return &health->thread[nth_thread];
}
unsigned int nr;
if (!thread) {
- return NULL;
+ return nullptr;
}
nr = thread - &thread->p->thread[0];
return get_thread_name(thread->p->component, nr);
*
* If yes return 1, else return -1.
*/
-int lttng_check_tracing_group(void)
+int lttng_check_tracing_group()
{
gid_t *grp_list, tracing_gid;
int grp_list_size, grp_id, i;
}
/* Get number of supplementary group IDs */
- grp_list_size = getgroups(0, NULL);
+ grp_list_size = getgroups(0, nullptr);
if (grp_list_size < 0) {
PERROR("getgroups");
goto end;
* Returns 0 on success, negative value on failure (the sessiond socket path
* is somehow too long or ENOMEM).
*/
-static int set_session_daemon_path(void)
+static int set_session_daemon_path()
{
int in_tgroup = 0; /* In tracing group. */
uid_t uid;
*
* On success, return the socket's file descriptor. On error, return -1.
*/
-int connect_sessiond(void)
+int connect_sessiond()
{
int ret;
return -1;
}
-static void reset_global_sessiond_connection_state(void)
+static void reset_global_sessiond_connection_state()
{
sessiond_socket = -1;
connected = 0;
*
* On success, return 0. On error, return -1.
*/
-static int disconnect_sessiond(void)
+static int disconnect_sessiond()
{
int ret = 0;
static int recv_sessiond_optional_data(size_t len, void **user_buf, size_t *user_len)
{
int ret = 0;
- char *buf = NULL;
+ char *buf = nullptr;
if (len) {
if (!user_len) {
/* Move ownership of command header buffer to user. */
*user_buf = buf;
- buf = NULL;
+ buf = nullptr;
*user_len = len;
} else {
/* No command header. */
}
if (user_buf) {
- *user_buf = NULL;
+ *user_buf = nullptr;
}
}
struct lttng_handle *lttng_create_handle(const char *session_name, struct lttng_domain *domain)
{
int ret;
- struct lttng_handle *handle = NULL;
+ struct lttng_handle *handle = nullptr;
handle = zmalloc<lttng_handle>();
- if (handle == NULL) {
+ if (handle == nullptr) {
PERROR("malloc handle");
goto end;
}
return handle;
error:
free(handle);
- return NULL;
+ return nullptr;
}
/*
int ret;
struct lttcomm_session_msg lsm;
- if (handle == NULL || socket_path == NULL) {
+ if (handle == nullptr || socket_path == nullptr) {
ret = -LTTNG_ERR_INVALID;
goto end;
}
goto end;
}
- ret = lttng_ctl_ask_sessiond(&lsm, NULL);
+ ret = lttng_ctl_ask_sessiond(&lsm, nullptr);
end:
return ret;
}
int ret;
struct lttcomm_session_msg lsm;
- if (session_name == NULL) {
+ if (session_name == nullptr) {
ret = -LTTNG_ERR_INVALID;
goto end;
}
goto end;
}
- ret = lttng_ctl_ask_sessiond(&lsm, NULL);
+ ret = lttng_ctl_ask_sessiond(&lsm, nullptr);
end:
return ret;
}
int ret, data_ret;
struct lttcomm_session_msg lsm;
- if (session_name == NULL) {
+ if (session_name == nullptr) {
ret = -LTTNG_ERR_INVALID;
goto error;
}
goto error;
}
- ret = lttng_ctl_ask_sessiond(&lsm, NULL);
+ ret = lttng_ctl_ask_sessiond(&lsm, nullptr);
if (ret < 0 && ret != -LTTNG_ERR_TRACE_ALREADY_STOPPED) {
goto error;
}
lttng_payload_init(&payload);
/* Safety check. Both are mandatory. */
- if (handle == NULL || ctx == NULL) {
+ if (handle == nullptr || ctx == nullptr) {
ret = -LTTNG_ERR_INVALID;
goto end;
}
struct lttng_event *ev,
const char *channel_name)
{
- return lttng_enable_event_with_exclusions(handle, ev, channel_name, NULL, 0, NULL);
+ return lttng_enable_event_with_exclusions(handle, ev, channel_name, nullptr, 0, nullptr);
}
/*
const char *filter_expression)
{
return lttng_enable_event_with_exclusions(
- handle, event, channel_name, filter_expression, 0, NULL);
+ handle, event, channel_name, filter_expression, 0, nullptr);
}
/*
static char *set_agent_filter(const char *filter, struct lttng_event *ev)
{
int err;
- char *agent_filter = NULL;
+ char *agent_filter = nullptr;
LTTNG_ASSERT(ev);
return agent_filter;
error:
free(agent_filter);
- return NULL;
+ return nullptr;
}
/*
struct lttng_payload payload;
int ret = 0;
unsigned int free_filter_expression = 0;
- struct filter_parser_ctx *ctx = NULL;
+ struct filter_parser_ctx *ctx = nullptr;
size_t bytecode_len = 0;
/*
*/
char *filter_expression = (char *) original_filter_expression;
- if (handle == NULL || ev == NULL) {
+ if (handle == nullptr || ev == nullptr) {
ret = -LTTNG_ERR_INVALID;
goto error;
}
}
/* Parse filter expression. */
- if (filter_expression != NULL || handle->domain.type == LTTNG_DOMAIN_JUL ||
+ if (filter_expression != nullptr || handle->domain.type == LTTNG_DOMAIN_JUL ||
handle->domain.type == LTTNG_DOMAIN_LOG4J ||
handle->domain.type == LTTNG_DOMAIN_PYTHON) {
if (handle->domain.type == LTTNG_DOMAIN_JUL ||
exclusion_list,
filter_expression,
bytecode_len,
- (ctx && bytecode_len) ? &ctx->bytecode->b : NULL,
+ (ctx && bytecode_len) ? &ctx->bytecode->b : nullptr,
&payload);
if (ret) {
ret = -LTTNG_ERR_INVALID;
lsm.fd_count = fd_count;
ret = lttng_ctl_ask_sessiond_fds_varlen(&lsm,
- fd_count ? &fd_to_send : NULL,
+ fd_count ? &fd_to_send : nullptr,
fd_count,
- view.buffer.size ? view.buffer.data : NULL,
+ view.buffer.size ? view.buffer.data :
+ nullptr,
view.buffer.size,
- NULL,
- NULL,
- 0);
+ nullptr,
+ nullptr,
+ nullptr);
}
error:
struct lttng_payload payload;
int ret = 0;
unsigned int free_filter_expression = 0;
- struct filter_parser_ctx *ctx = NULL;
+ struct filter_parser_ctx *ctx = nullptr;
size_t bytecode_len = 0;
/*
*/
char *filter_expression = (char *) original_filter_expression;
- if (handle == NULL || ev == NULL) {
+ if (handle == nullptr || ev == nullptr) {
ret = -LTTNG_ERR_INVALID;
goto error;
}
}
/* Parse filter expression. */
- if (filter_expression != NULL || handle->domain.type == LTTNG_DOMAIN_JUL ||
+ if (filter_expression != nullptr || handle->domain.type == LTTNG_DOMAIN_JUL ||
handle->domain.type == LTTNG_DOMAIN_LOG4J ||
handle->domain.type == LTTNG_DOMAIN_PYTHON) {
if (handle->domain.type == LTTNG_DOMAIN_JUL ||
serialize:
ret = lttng_event_serialize(ev,
0,
- NULL,
+ nullptr,
filter_expression,
bytecode_len,
- (ctx && bytecode_len) ? &ctx->bytecode->b : NULL,
+ (ctx && bytecode_len) ? &ctx->bytecode->b : nullptr,
&payload);
if (ret) {
ret = -LTTNG_ERR_INVALID;
}
ret = lttng_ctl_ask_sessiond_fds_varlen(&lsm,
- fd_count ? &fd_to_send : NULL,
+ fd_count ? &fd_to_send : nullptr,
fd_count,
- view.buffer.size ? view.buffer.data : NULL,
+ view.buffer.size ? view.buffer.data :
+ nullptr,
view.buffer.size,
- NULL,
- NULL,
- 0);
+ nullptr,
+ nullptr,
+ nullptr);
}
error:
goto end;
}
- ret = lttng_disable_event_ext(handle, &ev, channel_name, NULL);
+ ret = lttng_disable_event_ext(handle, &ev, channel_name, nullptr);
end:
return ret;
}
struct lttng_channel *lttng_channel_create(struct lttng_domain *domain)
{
- struct lttng_channel *channel = NULL;
+ struct lttng_channel *channel = nullptr;
if (!domain) {
goto end;
struct lttng_dynamic_buffer buffer;
struct lttcomm_session_msg lsm;
uint64_t total_buffer_size_needed_per_cpu = 0;
- struct lttng_channel *channel = NULL;
+ struct lttng_channel *channel = nullptr;
lttng_dynamic_buffer_init(&buffer);
/* NULL arguments are forbidden. No default values. */
- if (handle == NULL || in_chan == NULL) {
+ if (handle == nullptr || in_chan == nullptr) {
ret = -LTTNG_ERR_INVALID;
goto end;
}
lsm.u.channel.length = buffer.size;
- ret = lttng_ctl_ask_sessiond_varlen_no_cmd_header(&lsm, buffer.data, buffer.size, NULL);
+ ret = lttng_ctl_ask_sessiond_varlen_no_cmd_header(&lsm, buffer.data, buffer.size, nullptr);
end:
lttng_channel_destroy(channel);
lttng_dynamic_buffer_reset(&buffer);
struct lttcomm_session_msg lsm;
/* Safety check. Both are mandatory. */
- if (handle == NULL || name == NULL) {
+ if (handle == nullptr || name == nullptr) {
return -LTTNG_ERR_INVALID;
}
goto end;
}
- ret = lttng_ctl_ask_sessiond(&lsm, NULL);
+ ret = lttng_ctl_ask_sessiond(&lsm, nullptr);
end:
return ret;
}
{
enum lttng_error_code ret_code;
int ret, total_payload_received;
- char *reception_buffer = NULL;
+ char *reception_buffer = nullptr;
struct lttcomm_session_msg lsm = {
.cmd_type = LTTCOMM_SESSIOND_COMMAND_LIST_TRACEPOINTS,
.session = {},
.u = {},
.fd_count = 0,
};
- struct lttcomm_list_command_header *cmd_header = NULL;
+ struct lttcomm_list_command_header *cmd_header = nullptr;
size_t cmd_header_len;
unsigned int nb_events = 0;
- if (handle == NULL) {
+ if (handle == nullptr) {
ret = -LTTNG_ERR_INVALID;
goto end;
}
COPY_DOMAIN_PACKED(lsm.domain, handle->domain);
ret = lttng_ctl_ask_sessiond_fds_varlen(&lsm,
- NULL,
+ nullptr,
0,
- NULL,
+ nullptr,
0,
(void **) &reception_buffer,
(void **) &cmd_header,
enum lttng_error_code ret_code;
int ret;
struct lttcomm_session_msg lsm;
- const struct lttcomm_list_command_header *cmd_header = NULL;
+ const struct lttcomm_list_command_header *cmd_header = nullptr;
unsigned int nb_event_fields = 0;
struct lttng_payload reply;
lttng_payload_init(&reply);
- if (handle == NULL) {
+ if (handle == nullptr) {
ret = -LTTNG_ERR_INVALID;
goto end;
}
{
enum lttng_error_code ret_code;
int ret, total_payload_received;
- char *reception_buffer = NULL;
+ char *reception_buffer = nullptr;
struct lttcomm_session_msg lsm = {};
- struct lttcomm_list_command_header *cmd_header = NULL;
+ struct lttcomm_list_command_header *cmd_header = nullptr;
size_t cmd_header_len;
uint32_t nb_events = 0;
lsm.domain.type = LTTNG_DOMAIN_KERNEL;
ret = lttng_ctl_ask_sessiond_fds_varlen(&lsm,
- NULL,
+ nullptr,
0,
- NULL,
+ nullptr,
0,
(void **) &reception_buffer,
(void **) &cmd_header,
.u = {},
.fd_count = 0,
};
- void *reply = NULL;
+ void *reply = nullptr;
struct lttng_buffer_view reply_view;
int reply_ret;
bool sessiond_must_generate_ouput;
struct lttng_dynamic_buffer payload;
int ret;
size_t descriptor_size;
- struct lttng_session_descriptor *descriptor_reply = NULL;
+ struct lttng_session_descriptor *descriptor_reply = nullptr;
lttng_dynamic_buffer_init(&payload);
if (!session_descriptor) {
{
int ret;
ssize_t size;
- struct lttng_uri *uris = NULL;
- struct lttng_session_descriptor *descriptor = NULL;
+ struct lttng_uri *uris = nullptr;
+ struct lttng_session_descriptor *descriptor = nullptr;
enum lttng_error_code ret_code;
if (!name) {
goto end;
}
- size = uri_parse_str_urls(url, NULL, &uris);
+ size = uri_parse_str_urls(url, nullptr, &uris);
if (size < 0) {
ret = -LTTNG_ERR_INVALID;
goto end;
descriptor = lttng_session_descriptor_local_create(name, uris[0].dst.path);
break;
case 2:
- descriptor = lttng_session_descriptor_network_create(name, url, NULL);
+ descriptor = lttng_session_descriptor_network_create(name, url, nullptr);
break;
default:
ret = -LTTNG_ERR_INVALID;
int ret;
enum lttng_error_code ret_code;
ssize_t size;
- struct lttng_uri *uris = NULL;
- struct lttng_session_descriptor *descriptor = NULL;
+ struct lttng_uri *uris = nullptr;
+ struct lttng_session_descriptor *descriptor = nullptr;
if (!name) {
ret = -LTTNG_ERR_INVALID;
goto end;
}
- size = uri_parse_str_urls(snapshot_url, NULL, &uris);
+ size = uri_parse_str_urls(snapshot_url, nullptr, &uris);
if (size < 0) {
ret = -LTTNG_ERR_INVALID;
goto end;
descriptor = lttng_session_descriptor_snapshot_local_create(name, uris[0].dst.path);
break;
case 2:
- descriptor =
- lttng_session_descriptor_snapshot_network_create(name, snapshot_url, NULL);
+ descriptor = lttng_session_descriptor_snapshot_network_create(
+ name, snapshot_url, nullptr);
break;
default:
ret = -LTTNG_ERR_INVALID;
{
int ret;
enum lttng_error_code ret_code;
- struct lttng_session_descriptor *descriptor = NULL;
+ struct lttng_session_descriptor *descriptor = nullptr;
if (!name) {
ret = -LTTNG_ERR_INVALID;
if (url) {
descriptor = lttng_session_descriptor_live_network_create(
- name, url, NULL, timer_interval);
+ name, url, nullptr, timer_interval);
} else {
descriptor = lttng_session_descriptor_live_create(name, timer_interval);
}
int ret;
enum lttng_error_code ret_code;
enum lttng_destruction_handle_status status;
- struct lttng_destruction_handle *handle = NULL;
+ struct lttng_destruction_handle *handle = nullptr;
/*
* Stop the tracing and wait for the data to be
{
enum lttng_error_code ret_code;
- ret_code = lttng_destroy_session_ext(session_name, NULL);
+ ret_code = lttng_destroy_session_ext(session_name, nullptr);
return ret_code == LTTNG_OK ? 0 : -ret_code;
}
sizeof(struct lttng_session) + sizeof(struct lttng_session_extended);
size_t session_count, i;
struct lttng_session_extended *sessions_extended_begin;
- struct lttng_session *sessions = NULL;
+ struct lttng_session *sessions = nullptr;
memset(&lsm, 0, sizeof(lsm));
lsm.cmd_type = LTTCOMM_SESSIOND_COMMAND_LIST_SESSIONS;
* lttng_list_sessions returns 0, thus allowing *out_sessions to
* be subsequently freed.
*/
- *out_sessions = NULL;
+ *out_sessions = nullptr;
ret = lttng_ctl_ask_sessiond(&lsm, (void **) &sessions);
if (ret <= 0) {
goto end;
int ret;
struct lttcomm_session_msg lsm;
- if (session_name == NULL) {
+ if (session_name == nullptr) {
return -LTTNG_ERR_INVALID;
}
goto end;
}
- ret = lttng_ctl_ask_sessiond(&lsm, NULL);
+ ret = lttng_ctl_ask_sessiond(&lsm, nullptr);
end:
return ret;
}
int ret;
struct lttcomm_session_msg lsm;
- if (session_name == NULL) {
+ if (session_name == nullptr) {
ret = -LTTNG_ERR_INVALID;
goto error;
}
{
int ret, total_payload_received;
struct lttcomm_session_msg lsm;
- char *reception_buffer = NULL;
+ char *reception_buffer = nullptr;
size_t cmd_header_len = 0;
- struct lttcomm_list_command_header *cmd_header = NULL;
+ struct lttcomm_list_command_header *cmd_header = nullptr;
struct lttng_dynamic_buffer tmp_buffer;
lttng_dynamic_buffer_init(&tmp_buffer);
- if (handle == NULL) {
+ if (handle == nullptr) {
ret = -LTTNG_ERR_INVALID;
goto end;
}
COPY_DOMAIN_PACKED(lsm.domain, handle->domain);
ret = lttng_ctl_ask_sessiond_fds_varlen(&lsm,
- NULL,
+ nullptr,
0,
- NULL,
+ nullptr,
0,
(void **) &reception_buffer,
(void **) &cmd_header,
lttng_payload_init(&reply);
/* Safety check. An handle and channel name are mandatory. */
- if (handle == NULL || channel_name == NULL) {
+ if (handle == nullptr || channel_name == nullptr) {
ret = -LTTNG_ERR_INVALID;
goto end;
}
}
{
- const struct lttcomm_list_command_header *cmd_reply_header = NULL;
+ const struct lttcomm_list_command_header *cmd_reply_header = nullptr;
const lttng_payload_view cmd_reply_header_view =
lttng_payload_view_from_payload(&reply, 0, sizeof(*cmd_reply_header));
int ret = 0;
char *new_group;
- if (name == NULL) {
+ if (name == nullptr) {
ret = -LTTNG_ERR_INVALID;
goto end;
}
free(tracing_group);
tracing_group = new_group;
- new_group = NULL;
+ new_group = nullptr;
end:
return ret;
struct lttng_channel_extended *extended;
/* Safety check */
- if (attr == NULL || domain == NULL) {
+ if (attr == nullptr || domain == nullptr) {
return;
}
int ret;
ssize_t size;
struct lttcomm_session_msg lsm;
- struct lttng_uri *uris = NULL;
+ struct lttng_uri *uris = nullptr;
- if (handle == NULL || (control_url == NULL && data_url == NULL)) {
+ if (handle == nullptr || (control_url == nullptr && data_url == nullptr)) {
ret = -LTTNG_ERR_INVALID;
goto error;
}
lsm.u.uri.size = size;
ret = lttng_ctl_ask_sessiond_varlen_no_cmd_header(
- &lsm, uris, sizeof(struct lttng_uri) * size, NULL);
+ &lsm, uris, sizeof(struct lttng_uri) * size, nullptr);
free(uris);
error:
{
int ret;
struct lttcomm_session_msg lsm;
- uint8_t *pending = NULL;
+ uint8_t *pending = nullptr;
- if (session_name == NULL) {
+ if (session_name == nullptr) {
return -LTTNG_ERR_INVALID;
}
goto end;
}
- ret = lttng_ctl_ask_sessiond(&lsm, NULL);
+ ret = lttng_ctl_ask_sessiond(&lsm, nullptr);
if (ret < 0) {
goto end;
}
goto end;
}
- ret = lttng_ctl_ask_sessiond(&lsm, NULL);
+ ret = lttng_ctl_ask_sessiond(&lsm, nullptr);
if (ret < 0) {
goto end;
}
struct lttcomm_session_msg *message_lsm;
struct lttng_payload message;
struct lttng_payload reply;
- struct lttng_trigger *reply_trigger = NULL;
+ struct lttng_trigger *reply_trigger = nullptr;
enum lttng_domain_type domain_type;
const struct lttng_credentials user_creds = {
.uid = LTTNG_OPTIONAL_INIT_VALUE(geteuid()),
.gid = LTTNG_OPTIONAL_INIT_UNSET,
};
- const char *unused_trigger_name = NULL;
+ const char *unused_trigger_name = nullptr;
enum lttng_trigger_status trigger_status;
lttng_payload_init(&message);
goto end;
end_unset_name:
- trigger_status = lttng_trigger_set_name(trigger, NULL);
+ trigger_status = lttng_trigger_set_name(trigger, nullptr);
if (trigger_status != LTTNG_TRIGGER_STATUS_OK) {
ret = -LTTNG_ERR_UNK;
}
int lttng_register_trigger(struct lttng_trigger *trigger)
{
/* Register an anonymous trigger. */
- return _lttng_register_trigger(trigger, NULL, false);
+ return _lttng_register_trigger(trigger, nullptr, false);
}
enum lttng_error_code lttng_register_trigger_with_name(struct lttng_trigger *trigger,
struct lttcomm_session_msg *message_lsm;
struct lttng_payload message;
struct lttng_payload reply;
- struct lttng_trigger *copy = NULL;
+ struct lttng_trigger *copy = nullptr;
const struct lttng_credentials user_creds = {
.uid = LTTNG_OPTIONAL_INIT_VALUE(geteuid()),
.gid = LTTNG_OPTIONAL_INIT_UNSET,
.u = {},
.fd_count = 0,
};
- struct lttng_triggers *local_triggers = NULL;
+ struct lttng_triggers *local_triggers = nullptr;
struct lttng_payload reply;
struct lttng_payload_view lsm_view =
lttng_payload_view_init_from_buffer((const char *) &lsm, 0, sizeof(lsm));
}
*triggers = local_triggers;
- local_triggers = NULL;
+ local_triggers = nullptr;
end:
lttng_payload_reset(&reply);
lttng_triggers_destroy(local_triggers);
/*
* lib constructor.
*/
-static void __attribute__((constructor)) init(void)
+static void __attribute__((constructor)) init()
{
/* Set default session group */
lttng_set_tracing_group(DEFAULT_TRACING_GROUP);
/*
* lib destructor.
*/
-static void __attribute__((destructor)) lttng_ctl_exit(void)
+static void __attribute__((destructor)) lttng_ctl_exit()
{
free(tracing_group);
}
info->location.relay.relative_path);
break;
default:
- location = NULL;
+ location = nullptr;
break;
}
return location;
enum lttng_rotation_state *state)
{
enum lttng_rotation_status status = LTTNG_ROTATION_STATUS_OK;
- struct lttng_rotation_get_info_return *info = NULL;
+ struct lttng_rotation_get_info_return *info = nullptr;
if (!rotation_handle || !state) {
status = LTTNG_ROTATION_STATUS_INVALID;
const struct lttng_trace_archive_location **location)
{
enum lttng_rotation_status status = LTTNG_ROTATION_STATUS_OK;
- struct lttng_rotation_get_info_return *info = NULL;
+ struct lttng_rotation_get_info_return *info = nullptr;
if (!rotation_handle || !location) {
status = LTTNG_ROTATION_STATUS_INVALID;
struct lttng_rotation_handle **rotation_handle)
{
struct lttcomm_session_msg lsm;
- struct lttng_rotate_session_return *rotate_return = NULL;
+ struct lttng_rotate_session_return *rotate_return = nullptr;
int ret;
size_t session_name_len;
ret = lttng_ctl_ask_sessiond(&lsm, (void **) &rotate_return);
if (ret <= 0) {
- *rotation_handle = NULL;
+ *rotation_handle = nullptr;
goto end;
}
goto end;
}
- ret = lttng_ctl_ask_sessiond(&lsm, NULL);
+ ret = lttng_ctl_ask_sessiond(&lsm, nullptr);
if (ret >= 0) {
goto end;
}
return status;
}
-static struct lttng_rotation_schedules *lttng_rotation_schedules_create(void)
+static struct lttng_rotation_schedules *lttng_rotation_schedules_create()
{
return zmalloc<lttng_rotation_schedules>();
}
{
int ret;
struct lttcomm_session_msg lsm;
- struct lttng_session_list_schedules_return *schedules_comm = NULL;
- struct lttng_rotation_schedules *schedules = NULL;
- struct lttng_rotation_schedule *periodic = NULL, *size = NULL;
+ struct lttng_session_list_schedules_return *schedules_comm = nullptr;
+ struct lttng_rotation_schedules *schedules = nullptr;
+ struct lttng_rotation_schedule *periodic = nullptr, *size = nullptr;
if (!session_name) {
ret = -LTTNG_ERR_INVALID;
}
lttng_schedules_add(schedules, periodic);
- periodic = NULL;
+ periodic = nullptr;
}
if (schedules_comm->size.set == 1) {
}
lttng_schedules_add(schedules, size);
- size = NULL;
+ size = nullptr;
}
ret = LTTNG_OK;
lttng_rotation_schedules_get_at_index(const struct lttng_rotation_schedules *schedules,
unsigned int index)
{
- const struct lttng_rotation_schedule *schedule = NULL;
+ const struct lttng_rotation_schedule *schedule = nullptr;
if (!schedules || index >= schedules->count) {
goto end;
const char *lttng_save_session_attr_get_session_name(struct lttng_save_session_attr *attr)
{
- const char *ret = NULL;
+ const char *ret = nullptr;
if (attr && attr->session_name[0]) {
ret = attr->session_name;
const char *lttng_save_session_attr_get_output_url(struct lttng_save_session_attr *attr)
{
- const char *ret = NULL;
+ const char *ret = nullptr;
if (attr && attr->configuration_url[0]) {
ret = attr->configuration_url;
int ret = 0;
size_t len;
ssize_t size;
- struct lttng_uri *uris = NULL;
+ struct lttng_uri *uris = nullptr;
if (!attr) {
ret = -LTTNG_ERR_INVALID;
goto error;
}
- size = uri_parse_str_urls(url, NULL, &uris);
+ size = uri_parse_str_urls(url, nullptr, &uris);
if (size <= 0 || uris[0].dtype != LTTNG_DST_PATH) {
ret = -LTTNG_ERR_INVALID;
goto error;
lsm.cmd_type = LTTCOMM_SESSIOND_COMMAND_SAVE_SESSION;
memcpy(&lsm.u.save_session.attr, attr, sizeof(struct lttng_save_session_attr));
- ret = lttng_ctl_ask_sessiond(&lsm, NULL);
+ ret = lttng_ctl_ask_sessiond(&lsm, nullptr);
end:
return ret;
}
memcpy(&lsm.u.snapshot_output.output, output, sizeof(lsm.u.snapshot_output.output));
- ret = lttng_ctl_ask_sessiond(&lsm, NULL);
+ ret = lttng_ctl_ask_sessiond(&lsm, nullptr);
end:
return ret;
}
{
int ret;
struct lttcomm_session_msg lsm;
- struct lttng_snapshot_output_list *new_list = NULL;
+ struct lttng_snapshot_output_list *new_list = nullptr;
if (!session_name || !list) {
ret = -LTTNG_ERR_INVALID;
struct lttng_snapshot_output *
lttng_snapshot_output_list_get_next(struct lttng_snapshot_output_list *list)
{
- struct lttng_snapshot_output *output = NULL;
+ struct lttng_snapshot_output *output = nullptr;
if (!list) {
goto error;
}
/* The wait param is ignored. */
- ret = lttng_ctl_ask_sessiond(&lsm, NULL);
+ ret = lttng_ctl_ask_sessiond(&lsm, nullptr);
end:
return ret;
}
int lttng_snapshot_output_set_local_path(const char *path, struct lttng_snapshot_output *output)
{
int ret;
- struct lttng_uri *uris = NULL;
+ struct lttng_uri *uris = nullptr;
ssize_t num_uris;
if (!path || !output) {
goto end;
}
- num_uris = uri_parse_str_urls(path, NULL, &uris);
+ num_uris = uri_parse_str_urls(path, nullptr, &uris);
if (num_uris != 1) {
ret = -LTTNG_ERR_INVALID;
goto end;
int lttng_snapshot_output_set_network_url(const char *url, struct lttng_snapshot_output *output)
{
int ret;
- struct lttng_uri *uris = NULL;
+ struct lttng_uri *uris = nullptr;
ssize_t num_uris;
if (!url || !output) {
goto end;
}
- num_uris = uri_parse_str_urls(url, NULL, &uris);
+ num_uris = uri_parse_str_urls(url, nullptr, &uris);
if (num_uris != 2) {
ret = -LTTNG_ERR_INVALID;
goto end;
struct lttng_snapshot_output *output)
{
int ret;
- struct lttng_uri *uris = NULL;
+ struct lttng_uri *uris = nullptr;
ssize_t num_uris;
if (!ctrl_url || !data_url || !output) {
struct lttng_process_attr_tracker_handle **out_tracker_handle)
{
enum lttng_error_code ret_code = LTTNG_OK;
- struct lttng_process_attr_tracker_handle *handle = NULL;
+ struct lttng_process_attr_tracker_handle *handle = nullptr;
enum lttng_process_attr_tracker_handle_status status;
enum lttng_tracking_policy policy;
enum lttng_process_attr_tracker_handle_status lttng_process_attr_tracker_handle_get_tracking_policy(
const struct lttng_process_attr_tracker_handle *tracker, enum lttng_tracking_policy *policy)
{
- void *reply = NULL;
+ void *reply = nullptr;
int reply_ret, copy_ret;
enum lttng_process_attr_tracker_handle_status status =
LTTNG_PROCESS_ATTR_TRACKER_HANDLE_STATUS_OK;
(int32_t) tracker->process_attr;
/* Command returns a session descriptor on success. */
- reply_ret = lttng_ctl_ask_sessiond_varlen_no_cmd_header(&lsm, NULL, 0, &reply);
+ reply_ret = lttng_ctl_ask_sessiond_varlen_no_cmd_header(&lsm, nullptr, 0, &reply);
if (reply_ret != sizeof(uint32_t)) {
if (reply_ret == -LTTNG_ERR_SESSION_NOT_EXIST ||
reply_ret == -LTTNG_ERR_SESS_NOT_FOUND) {
lsm.u.process_attr_tracker_set_tracking_policy.tracking_policy = (int32_t) policy;
/* Command returns a session descriptor on success. */
- reply_ret = lttng_ctl_ask_sessiond(&lsm, NULL);
+ reply_ret = lttng_ctl_ask_sessiond(&lsm, nullptr);
if (reply_ret < 0) {
if (reply_ret == -LTTNG_ERR_SESSION_NOT_EXIST) {
status = LTTNG_PROCESS_ATTR_TRACKER_HANDLE_STATUS_SESSION_DOES_NOT_EXIST;
struct lttng_process_attr_tracker_handle *tracker,
const struct lttng_process_attr_values **values)
{
- char *reply = NULL;
+ char *reply = nullptr;
int reply_ret, copy_ret;
enum lttng_process_attr_tracker_handle_status status =
LTTNG_PROCESS_ATTR_TRACKER_HANDLE_STATUS_OK;
}
lttng_process_attr_values_destroy(tracker->inclusion_set);
- tracker->inclusion_set = NULL;
+ tracker->inclusion_set = nullptr;
copy_ret = lttng_strncpy(lsm.session.name, tracker->session_name, sizeof(lsm.session.name));
if (copy_ret) {
(int32_t) tracker->process_attr;
/* Command returns a session descriptor on success. */
- reply_ret = lttng_ctl_ask_sessiond_varlen_no_cmd_header(&lsm, NULL, 0, (void **) &reply);
+ reply_ret = lttng_ctl_ask_sessiond_varlen_no_cmd_header(&lsm, nullptr, 0, (void **) &reply);
if (reply_ret < 0) {
if (reply_ret == -LTTNG_ERR_SESSION_NOT_EXIST) {
status = LTTNG_PROCESS_ATTR_TRACKER_HANDLE_STATUS_SESSION_DOES_NOT_EXIST;
int lttng_track_pid(struct lttng_handle *handle, int pid)
{
enum lttng_error_code ret_code;
- struct lttng_process_attr_tracker_handle *tracker_handle = NULL;
+ struct lttng_process_attr_tracker_handle *tracker_handle = nullptr;
enum lttng_process_attr_tracker_handle_status handle_status;
enum lttng_tracking_policy policy;
enum lttng_process_attr process_attr;
int lttng_untrack_pid(struct lttng_handle *handle, int pid)
{
enum lttng_error_code ret_code;
- struct lttng_process_attr_tracker_handle *tracker_handle = NULL;
+ struct lttng_process_attr_tracker_handle *tracker_handle = nullptr;
enum lttng_process_attr_tracker_handle_status handle_status;
enum lttng_tracking_policy policy;
enum lttng_process_attr process_attr;
size_t *_nr_pids)
{
enum lttng_error_code ret_code;
- struct lttng_process_attr_tracker_handle *tracker_handle = NULL;
+ struct lttng_process_attr_tracker_handle *tracker_handle = nullptr;
enum lttng_process_attr_tracker_handle_status handle_status;
const struct lttng_process_attr_values *values;
enum lttng_tracking_policy policy;
unsigned int pid_count, i;
- int32_t *pid_array = NULL;
+ int32_t *pid_array = nullptr;
if (!handle || !_enabled || !_pids || !_nr_pids) {
ret_code = LTTNG_ERR_INVALID;
}
*_nr_pids = (size_t) pid_count;
*_pids = pid_array;
- pid_array = NULL;
+ pid_array = nullptr;
end:
lttng_process_attr_tracker_handle_destroy(tracker_handle);
free(pid_array);
};
} /* namespace */
-static void test_select_big(void)
+static void test_select_big()
{
fd_set rfds, wfds, exfds;
struct timeval tv;
if (timeout > 0) {
ret = select(fd2 + 1, &rfds, &wfds, &exfds, &tv);
} else {
- ret = select(fd2 + 1, &rfds, &wfds, &exfds, NULL);
+ ret = select(fd2 + 1, &rfds, &wfds, &exfds, nullptr);
}
if (ret == -1) {
return;
}
-static void test_pselect(void)
+static void test_pselect()
{
fd_set rfds;
struct timespec tv;
tv.tv_nsec = timeout * MSEC_PER_NSEC;
if (timeout > 0) {
- ret = pselect(1, &rfds, NULL, NULL, &tv, NULL);
+ ret = pselect(1, &rfds, nullptr, nullptr, &tv, nullptr);
} else {
- ret = pselect(1, &rfds, NULL, NULL, NULL, NULL);
+ ret = pselect(1, &rfds, nullptr, nullptr, nullptr, nullptr);
}
if (ret == -1) {
}
}
-static void test_select(void)
+static void test_select()
{
fd_set rfds;
struct timeval tv;
tv.tv_usec = timeout * MSEC_PER_USEC;
if (timeout > 0) {
- ret = select(1, &rfds, NULL, NULL, &tv);
+ ret = select(1, &rfds, nullptr, nullptr, &tv);
} else {
- ret = select(1, &rfds, NULL, NULL, NULL);
+ ret = select(1, &rfds, nullptr, nullptr, nullptr);
}
if (ret == -1) {
}
}
-static void test_poll(void)
+static void test_poll()
{
struct pollfd ufds[NB_FD];
char buf[BUF_SIZE];
}
}
-static void test_ppoll(void)
+static void test_ppoll()
{
struct pollfd ufds[NB_FD];
char buf[BUF_SIZE];
if (timeout > 0) {
ts.tv_sec = 0;
ts.tv_nsec = timeout * MSEC_PER_NSEC;
- ret = ppoll(ufds, 1, &ts, NULL);
+ ret = ppoll(ufds, 1, &ts, nullptr);
} else {
- ret = ppoll(ufds, 1, NULL, NULL);
+ ret = ppoll(ufds, 1, nullptr, nullptr);
}
if (ret < 0) {
ufds[i].events = POLLIN | POLLPRI;
}
- ret = ppoll(ufds, MAX_FDS, NULL, NULL);
+ ret = ppoll(ufds, MAX_FDS, nullptr, nullptr);
if (ret < 0) {
PERROR("ppoll");
}
if (timeout > 0) {
- ret = epoll_pwait(epollfd, &epoll_event, 1, timeout, NULL);
+ ret = epoll_pwait(epollfd, &epoll_event, 1, timeout, nullptr);
} else {
- ret = epoll_pwait(epollfd, &epoll_event, 1, -1, NULL);
+ ret = epoll_pwait(epollfd, &epoll_event, 1, -1, nullptr);
}
if (ret == 1) {
usleep(100);
}
- return NULL;
+ return nullptr;
}
static void do_ppoll(int *fds, struct pollfd *ufds)
ufds[i].events = POLLIN | POLLPRI;
}
- ret = ppoll(ufds, MAX_FDS, &ts, NULL);
+ ret = ppoll(ufds, MAX_FDS, &ts, nullptr);
if (ret < 0) {
PERROR("ppoll");
thread_data.value = value;
stop_thread = 0;
- ret = pthread_create(&writer, NULL, &ppoll_writer, (void *) &thread_data);
+ ret = pthread_create(&writer, nullptr, &ppoll_writer, (void *) &thread_data);
if (ret != 0) {
fprintf(stderr, "[error] pthread_create\n");
goto end;
do_ppoll(fds, ufds);
}
stop_thread = 1;
- ret = pthread_join(writer, NULL);
+ ret = pthread_join(writer, nullptr);
if (ret) {
fprintf(stderr, "[error] pthread_join\n");
goto end;
static void *epoll_pwait_writer(void *addr)
{
- srand(time(NULL));
+ srand(time(nullptr));
while (!stop_thread) {
usleep(rand() % 30);
munmap(addr, MAX_FDS * sizeof(struct epoll_event));
}
- return NULL;
+ return nullptr;
}
/*
goto error;
}
- epoll_event = (struct epoll_event *) mmap(NULL,
+ epoll_event = (struct epoll_event *) mmap(nullptr,
MAX_FDS * sizeof(struct epoll_event),
PROT_READ | PROT_WRITE,
MAP_PRIVATE | MAP_ANONYMOUS,
}
}
stop_thread = 0;
- ret = pthread_create(&writer, NULL, &epoll_pwait_writer, (void *) epoll_event);
+ ret = pthread_create(&writer, nullptr, &epoll_pwait_writer, (void *) epoll_event);
if (ret != 0) {
fprintf(stderr, "[error] pthread_create\n");
goto error_unmap;
}
- ret = epoll_pwait(epollfd, epoll_event, 1, 1, NULL);
+ ret = epoll_pwait(epollfd, epoll_event, 1, 1, nullptr);
if (ret == 1) {
ret = read(wait_fd, buf, BUF_SIZE);
}
stop_thread = 1;
- ret = pthread_join(writer, NULL);
+ ret = pthread_join(writer, nullptr);
if (ret) {
fprintf(stderr, "[error] pthread_join\n");
goto error_unmap;
return;
}
-static void print_list(void)
+static void print_list()
{
fprintf(stderr, "Test list (-t X):\n");
fprintf(stderr,
int c, ret, test = -1;
poptContext optCon;
struct rlimit open_lim;
- FILE *test_validation_output_file = NULL;
- const char *test_validation_output_file_path = NULL;
+ FILE *test_validation_output_file = nullptr;
+ const char *test_validation_output_file_path = nullptr;
struct poptOption optionsTable[] = {
- { "test", 't', POPT_ARG_INT, &test, 0, "Test to run", NULL },
- { "list", 'l', 0, 0, 'l', "List of tests (-t X)", NULL },
+ { "test", 't', POPT_ARG_INT, &test, 0, "Test to run", nullptr },
+ { "list", 'l', 0, nullptr, 'l', "List of tests (-t X)", nullptr },
{ "validation-file",
'o',
POPT_ARG_STRING,
&test_validation_output_file_path,
0,
"Test case output",
- NULL },
- POPT_AUTOHELP{ NULL, 0, 0, NULL, 0, NULL, NULL }
+ nullptr },
+ POPT_AUTOHELP{ nullptr, 0, 0, nullptr, 0, nullptr, nullptr }
};
const struct test_case *test_case;
- optCon = poptGetContext(NULL, argc, argv, optionsTable, 0);
+ optCon = poptGetContext(nullptr, argc, argv, optionsTable, 0);
if (argc < 2) {
poptPrintUsage(optCon, stderr, 0);
* for the validation, disabling the buffering on the validation file
* works.
*/
- setbuf(test_validation_output_file, NULL);
+ setbuf(test_validation_output_file, nullptr);
wait_fd = STDIN_FILENO;
/* Test case id is 1-based. */
return ret;
}
-static int establish_connection(void)
+static int establish_connection()
{
struct lttng_viewer_cmd cmd;
struct lttng_viewer_connect connect;
return -1;
}
-static int create_viewer_session(void)
+static int create_viewer_session()
{
struct lttng_viewer_cmd cmd;
struct lttng_viewer_create_session_response resp;
session->streams[i].ctf_trace_id = be64toh(stream.ctf_trace_id);
session->streams[i].first_read = 1;
- session->streams[i].mmap_base = mmap(
- NULL, mmap_size, PROT_READ | PROT_WRITE, MAP_PRIVATE | MAP_ANONYMOUS, -1, 0);
+ session->streams[i].mmap_base = mmap(nullptr,
+ mmap_size,
+ PROT_READ | PROT_WRITE,
+ MAP_PRIVATE | MAP_ANONYMOUS,
+ -1,
+ 0);
if (session->streams[i].mmap_base == MAP_FAILED) {
diag("mmap error");
goto error;
return -1;
}
-static int get_metadata(void)
+static int get_metadata()
{
struct lttng_viewer_cmd cmd;
struct lttng_viewer_get_metadata rq;
ssize_t ret_len;
int ret;
uint64_t i;
- char *data = NULL;
+ char *data = nullptr;
uint64_t len = 0;
int metadata_stream_id = -1;
return -1;
}
-static int get_next_index(void)
+static int get_next_index()
{
struct lttng_viewer_cmd cmd;
struct lttng_viewer_get_next_index rq;
return ret;
}
-int main(void)
+int main()
{
int ret;
uint64_t session_id;
int lttng_opt_mi;
int lttng_opt_quiet;
-static void __attribute__((destructor)) pause_pipe_fini(void)
+static void __attribute__((destructor)) pause_pipe_fini()
{
int ret;
* dynamically would not allow this shared object to be LD_PRELOAD-ed
* when launching the session daemon.
*/
- data_consumption_state = (int *) dlsym(NULL, "data_consumption_paused");
+ data_consumption_state = (int *) dlsym(nullptr, "data_consumption_paused");
LTTNG_ASSERT(data_consumption_state);
- lttng_consumer_get_type = (lttng_consumer_type(*)()) dlsym(NULL, "lttng_consumer_get_type");
+ lttng_consumer_get_type =
+ (lttng_consumer_type(*)()) dlsym(nullptr, "lttng_consumer_get_type");
LTTNG_ASSERT(lttng_consumer_get_type);
switch (lttng_consumer_get_type()) {
/*
* Return the default pipe buffer size or a negative error.
*/
-int get_pipe_size(void)
+int get_pipe_size()
{
int ret;
/*
#endif
} /* namespace */
-int main(void)
+int main()
{
int ret;
int nb_args = 0;
int named_pipe_args_start = 0;
pid_t app_pid = 0;
-const char *app_state_file = NULL;
+const char *app_state_file = nullptr;
enum field_type {
FIELD_TYPE_PAYLOAD,
static int validate_string(const struct lttng_event_field_value *event_field, const char *expect)
{
int ret;
- const char *value = NULL;
+ const char *value = nullptr;
enum lttng_event_field_value_status status;
ret = validate_type(event_field, LTTNG_EVENT_FIELD_VALUE_TYPE_STRING);
}
struct capture_base_field_tuple test_capture_base_fields[] = {
- { "DOESNOTEXIST", FIELD_TYPE_PAYLOAD, false, false, NULL, NULL },
+ { "DOESNOTEXIST", FIELD_TYPE_PAYLOAD, false, false, nullptr, nullptr },
{ "intfield",
FIELD_TYPE_PAYLOAD,
true,
static const char *get_notification_trigger_name(struct lttng_notification *notification)
{
- const char *trigger_name = NULL;
+ const char *trigger_name = nullptr;
enum lttng_trigger_status trigger_status;
const struct lttng_trigger *trigger;
LTTNG_ASSERT(trigger_name);
name = get_notification_trigger_name(notification);
- if (name == NULL) {
+ if (name == nullptr) {
ret = 1;
goto end;
}
* The file does not exist. wait a bit and
* continue looping until it does.
*/
- (void) poll(NULL, 0, 10);
+ (void) poll(nullptr, 0, 10);
continue;
}
return ret;
}
-static int suspend_application(void)
+static int suspend_application()
{
int ret;
struct stat buf;
return ret;
}
-static int resume_application(void)
+static int resume_application()
{
int ret;
struct stat buf;
}
/* Test lttng_register_trigger with null value */
- ok(lttng_register_trigger(NULL) == -LTTNG_ERR_INVALID,
+ ok(lttng_register_trigger(nullptr) == -LTTNG_ERR_INVALID,
"Registering a NULL trigger fails as expected");
/* Test: register a trigger */
for (i = 0; i < pow(2, test_vector_size); i++) {
int loop_ret = 0;
- char *test_tuple_string = NULL;
+ char *test_tuple_string = nullptr;
unsigned int mask_position = 0;
bool session_name_set = false;
bool channel_name_set = false;
bool threshold_byte_set = false;
bool domain_type_set = false;
- struct lttng_trigger *trigger = NULL;
- struct lttng_condition *condition = NULL;
+ struct lttng_trigger *trigger = nullptr;
+ struct lttng_condition *condition = nullptr;
/* Create base condition */
switch (condition_type) {
{
enum lttng_condition_status condition_status;
enum lttng_notification_channel_status nc_status;
- struct lttng_condition *dummy_condition = NULL;
- struct lttng_condition *dummy_invalid_condition = NULL;
- struct lttng_notification_channel *notification_channel = NULL;
+ struct lttng_condition *dummy_condition = nullptr;
+ struct lttng_condition *dummy_invalid_condition = nullptr;
+ struct lttng_notification_channel *notification_channel = nullptr;
int ret = 0;
notification_channel =
* Test subscription and unsubscription to/from a channel with invalid
* parameters.
*/
- nc_status = lttng_notification_channel_subscribe(NULL, NULL);
+ nc_status = lttng_notification_channel_subscribe(nullptr, nullptr);
ok(nc_status == LTTNG_NOTIFICATION_CHANNEL_STATUS_INVALID,
"Notification channel subscription is invalid: NULL, NULL");
- nc_status = lttng_notification_channel_subscribe(notification_channel, NULL);
+ nc_status = lttng_notification_channel_subscribe(notification_channel, nullptr);
ok(nc_status == LTTNG_NOTIFICATION_CHANNEL_STATUS_INVALID,
"Notification channel subscription is invalid: NON-NULL, NULL");
- nc_status = lttng_notification_channel_subscribe(NULL, dummy_condition);
+ nc_status = lttng_notification_channel_subscribe(nullptr, dummy_condition);
ok(nc_status == LTTNG_NOTIFICATION_CHANNEL_STATUS_INVALID,
"Notification channel subscription is invalid: NULL, NON-NULL");
struct lttng_trigger **trigger)
{
enum lttng_condition_status condition_status;
- struct lttng_action *tmp_action = NULL;
- struct lttng_condition *tmp_condition = NULL;
- struct lttng_trigger *tmp_trigger = NULL;
+ struct lttng_action *tmp_action = nullptr;
+ struct lttng_condition *tmp_condition = nullptr;
+ struct lttng_trigger *tmp_trigger = nullptr;
int ret = 0;
/* Set-up */
int ret = 0;
enum lttng_notification_channel_status nc_status;
- struct lttng_action *action = NULL;
- struct lttng_notification_channel *notification_channel = NULL;
- struct lttng_trigger *trigger = NULL;
+ struct lttng_action *action = nullptr;
+ struct lttng_notification_channel *notification_channel = nullptr;
+ struct lttng_trigger *trigger = nullptr;
- struct lttng_condition *condition = NULL;
+ struct lttng_condition *condition = nullptr;
ret = register_buffer_usage_notify_trigger(session_name,
channel_name,
int ret = 0;
enum lttng_notification_channel_status nc_status;
- struct lttng_action *low_action = NULL;
- struct lttng_action *high_action = NULL;
- struct lttng_notification *notification = NULL;
- struct lttng_notification_channel *notification_channel = NULL;
- struct lttng_trigger *low_trigger = NULL;
- struct lttng_trigger *high_trigger = NULL;
+ struct lttng_action *low_action = nullptr;
+ struct lttng_action *high_action = nullptr;
+ struct lttng_notification *notification = nullptr;
+ struct lttng_notification_channel *notification_channel = nullptr;
+ struct lttng_trigger *low_trigger = nullptr;
+ struct lttng_trigger *high_trigger = nullptr;
- struct lttng_condition *low_condition = NULL;
- struct lttng_condition *high_condition = NULL;
+ struct lttng_condition *low_condition = nullptr;
+ struct lttng_condition *high_condition = nullptr;
const double low_ratio = 0.0;
const double high_ratio = 0.90;
LTTNG_CONDITION_TYPE_BUFFER_USAGE_HIGH,
"High notification received after intermediary communication");
lttng_notification_destroy(notification);
- notification = NULL;
+ notification = nullptr;
suspend_application();
lttng_stop_tracing_no_wait(session_name);
LTTNG_CONDITION_TYPE_BUFFER_USAGE_LOW,
"Low notification received after intermediary communication");
lttng_notification_destroy(notification);
- notification = NULL;
+ notification = nullptr;
/* Stop consumer to force a high notification */
stop_consumer(argv);
LTTNG_CONDITION_TYPE_BUFFER_USAGE_HIGH,
"High notification received after intermediary communication");
lttng_notification_destroy(notification);
- notification = NULL;
+ notification = nullptr;
suspend_application();
lttng_stop_tracing_no_wait(session_name);
LTTNG_CONDITION_TYPE_BUFFER_USAGE_LOW,
"Low notification received after re-subscription");
lttng_notification_destroy(notification);
- notification = NULL;
+ notification = nullptr;
stop_consumer(argv);
resume_application();
LTTNG_CONDITION_TYPE_BUFFER_USAGE_HIGH,
"High notification");
lttng_notification_destroy(notification);
- notification = NULL;
+ notification = nullptr;
suspend_application();
enum lttng_event_rule_status (*)(struct lttng_event_rule *, const char *);
enum lttng_event_rule_status event_rule_status;
- struct lttng_action *tmp_action = NULL;
- struct lttng_event_rule *event_rule = NULL;
- struct lttng_condition *tmp_condition = NULL;
- struct lttng_trigger *tmp_trigger = NULL;
+ struct lttng_action *tmp_action = nullptr;
+ struct lttng_event_rule *event_rule = nullptr;
+ struct lttng_condition *tmp_condition = nullptr;
+ struct lttng_trigger *tmp_trigger = nullptr;
int ret;
enum lttng_error_code ret_code;
event_rule_create create;
create = lttng_event_rule_kernel_tracepoint_create;
set_name_pattern = lttng_event_rule_kernel_tracepoint_set_name_pattern;
set_filter = lttng_event_rule_kernel_tracepoint_set_filter;
- add_name_pattern_exclusion = NULL;
+ add_name_pattern_exclusion = nullptr;
break;
default:
abort();
bool success = true;
LTTNG_ASSERT(domain_type == LTTNG_DOMAIN_UST);
- LTTNG_ASSERT(add_name_pattern_exclusion != NULL);
+ LTTNG_ASSERT(add_name_pattern_exclusion != nullptr);
LTTNG_ASSERT(exclusion_count > 0);
for (i = 0; i < exclusion_count; i++) {
static struct lttng_notification *
get_next_notification(struct lttng_notification_channel *notification_channel)
{
- struct lttng_notification *local_notification = NULL;
+ struct lttng_notification *local_notification = nullptr;
enum lttng_notification_channel_status status;
/* Receive the next notification. */
break;
case LTTNG_NOTIFICATION_CHANNEL_STATUS_NOTIFICATIONS_DROPPED:
fail("Notifications have been dropped");
- local_notification = NULL;
+ local_notification = nullptr;
break;
default:
/* Unhandled conditions / errors. */
fail("Failed to get next notification (unknown notification channel status): status = %d",
(int) status);
- local_notification = NULL;
+ local_notification = nullptr;
break;
}
int ret;
const int notification_count = 3;
enum lttng_notification_channel_status nc_status;
- struct lttng_action *action = NULL;
- struct lttng_condition *condition = NULL;
- struct lttng_notification_channel *notification_channel = NULL;
- struct lttng_trigger *trigger = NULL;
+ struct lttng_action *action = nullptr;
+ struct lttng_condition *condition = nullptr;
+ struct lttng_notification_channel *notification_channel = nullptr;
+ struct lttng_trigger *trigger = nullptr;
const char *const trigger_name = "my_precious";
const char *pattern;
pattern = "lttng_test_filter_event";
}
- create_tracepoint_event_rule_trigger(
- pattern, trigger_name, NULL, 0, NULL, domain_type, NULL, &condition, &trigger);
+ create_tracepoint_event_rule_trigger(pattern,
+ trigger_name,
+ nullptr,
+ 0,
+ nullptr,
+ domain_type,
+ nullptr,
+ &condition,
+ &trigger);
notification_channel =
lttng_notification_channel_create(lttng_session_daemon_notification_endpoint);
ok(notification, "Received notification (%d/%d)", i + 1, notification_count);
/* Error. */
- if (notification == NULL) {
+ if (notification == nullptr) {
goto end;
}
int i;
const int notification_count = 3;
enum lttng_notification_channel_status nc_status;
- struct lttng_condition *ctrl_condition = NULL, *condition = NULL;
- struct lttng_notification_channel *notification_channel = NULL;
- struct lttng_trigger *ctrl_trigger = NULL, *trigger = NULL;
+ struct lttng_condition *ctrl_condition = nullptr, *condition = nullptr;
+ struct lttng_notification_channel *notification_channel = nullptr;
+ struct lttng_trigger *ctrl_trigger = nullptr, *trigger = nullptr;
const char *const ctrl_trigger_name = "control_trigger";
const char *const trigger_name = "trigger";
const char *pattern;
create_tracepoint_event_rule_trigger(pattern,
ctrl_trigger_name,
- NULL,
+ nullptr,
0,
- NULL,
+ nullptr,
domain_type,
- NULL,
+ nullptr,
&ctrl_condition,
&ctrl_trigger);
trigger_name,
"(intfield & 1) == 0",
0,
- NULL,
+ nullptr,
domain_type,
- NULL,
+ nullptr,
&condition,
&trigger);
ok(notification, "Received notification (%d/%d)", i + 1, notification_count);
/* Error. */
- if (notification == NULL) {
+ if (notification == nullptr) {
goto end;
}
name = get_notification_trigger_name(notification);
- if (name == NULL) {
+ if (name == nullptr) {
lttng_notification_destroy(notification);
goto end;
}
static void test_tracepoint_event_rule_notification_exclusion(enum lttng_domain_type domain_type)
{
enum lttng_notification_channel_status nc_status;
- struct lttng_condition *ctrl_condition = NULL, *condition = NULL;
- struct lttng_notification_channel *notification_channel = NULL;
- struct lttng_trigger *ctrl_trigger = NULL, *trigger = NULL;
+ struct lttng_condition *ctrl_condition = nullptr, *condition = nullptr;
+ struct lttng_notification_channel *notification_channel = nullptr;
+ struct lttng_trigger *ctrl_trigger = nullptr, *trigger = nullptr;
int ctrl_count = 0, count = 0, i;
const int notification_count = 6;
const char *const ctrl_trigger_name = "control_exclusion_trigger";
create_tracepoint_event_rule_trigger(pattern,
ctrl_trigger_name,
- NULL,
+ nullptr,
0,
- NULL,
+ nullptr,
domain_type,
- NULL,
+ nullptr,
&ctrl_condition,
&ctrl_trigger);
ok(nc_status == LTTNG_NOTIFICATION_CHANNEL_STATUS_OK,
"Subscribe to tracepoint event rule condition");
- create_tracepoint_event_rule_trigger(
- pattern, trigger_name, NULL, 4, exclusions, domain_type, NULL, &condition, &trigger);
+ create_tracepoint_event_rule_trigger(pattern,
+ trigger_name,
+ nullptr,
+ 4,
+ exclusions,
+ domain_type,
+ nullptr,
+ &condition,
+ &trigger);
nc_status = lttng_notification_channel_subscribe(notification_channel, condition);
ok(nc_status == LTTNG_NOTIFICATION_CHANNEL_STATUS_OK,
ok(notification, "Received notification (%d/%d)", i + 1, notification_count);
/* Error. */
- if (notification == NULL) {
+ if (notification == nullptr) {
goto end;
}
name = get_notification_trigger_name(notification);
- if (name == NULL) {
+ if (name == nullptr) {
lttng_notification_destroy(notification);
goto end;
}
return;
}
-static void test_kprobe_event_rule_notification(void)
+static void test_kprobe_event_rule_notification()
{
int i, ret;
enum lttng_error_code ret_code;
const int notification_count = 3;
enum lttng_notification_channel_status nc_status;
enum lttng_event_rule_status event_rule_status;
- struct lttng_notification_channel *notification_channel = NULL;
- struct lttng_condition *condition = NULL;
- struct lttng_kernel_probe_location *location = NULL;
- struct lttng_event_rule *event_rule = NULL;
- struct lttng_action *action = NULL;
- struct lttng_trigger *trigger = NULL;
+ struct lttng_notification_channel *notification_channel = nullptr;
+ struct lttng_condition *condition = nullptr;
+ struct lttng_kernel_probe_location *location = nullptr;
+ struct lttng_event_rule *event_rule = nullptr;
+ struct lttng_action *action = nullptr;
+ struct lttng_trigger *trigger = nullptr;
const char *const trigger_name = "kprobe_trigger";
const char *const symbol_name = "lttng_test_filter_event_write";
ok(notification, "Received notification (%d/%d)", i + 1, notification_count);
/* Error. */
- if (notification == NULL) {
+ if (notification == nullptr) {
goto end;
}
const int notification_count = 3;
enum lttng_notification_channel_status nc_status;
enum lttng_event_rule_status event_rule_status;
- struct lttng_notification_channel *notification_channel = NULL;
- struct lttng_userspace_probe_location *probe_location = NULL;
- struct lttng_userspace_probe_location_lookup_method *lookup_method = NULL;
- struct lttng_condition *condition = NULL;
- struct lttng_event_rule *event_rule = NULL;
- struct lttng_action *action = NULL;
- struct lttng_trigger *trigger = NULL;
+ struct lttng_notification_channel *notification_channel = nullptr;
+ struct lttng_userspace_probe_location *probe_location = nullptr;
+ struct lttng_userspace_probe_location_lookup_method *lookup_method = nullptr;
+ struct lttng_condition *condition = nullptr;
+ struct lttng_event_rule *event_rule = nullptr;
+ struct lttng_action *action = nullptr;
+ struct lttng_trigger *trigger = nullptr;
const char *const trigger_name = "uprobe_trigger";
action = lttng_action_notify_create();
ok(notification, "Received notification (%d/%d)", i + 1, notification_count);
/* Error. */
- if (notification == NULL) {
+ if (notification == nullptr) {
goto end;
}
return;
}
-static void test_syscall_event_rule_notification(void)
+static void test_syscall_event_rule_notification()
{
int i, ret;
enum lttng_error_code ret_code;
const int notification_count = 3;
enum lttng_notification_channel_status nc_status;
enum lttng_event_rule_status event_rule_status;
- struct lttng_notification_channel *notification_channel = NULL;
- struct lttng_condition *condition = NULL;
- struct lttng_event_rule *event_rule = NULL;
- struct lttng_action *action = NULL;
- struct lttng_trigger *trigger = NULL;
+ struct lttng_notification_channel *notification_channel = nullptr;
+ struct lttng_condition *condition = nullptr;
+ struct lttng_event_rule *event_rule = nullptr;
+ struct lttng_action *action = nullptr;
+ struct lttng_trigger *trigger = nullptr;
const char *const trigger_name = "syscall_trigger";
const char *const syscall_name = "openat";
ok(notification, "Received notification (%d/%d)", i + 1, notification_count);
/* Error. */
- if (notification == NULL) {
+ if (notification == nullptr) {
goto end;
}
return;
}
-static void test_syscall_event_rule_notification_filter(void)
+static void test_syscall_event_rule_notification_filter()
{
int i, ret;
enum lttng_error_code ret_code;
const int notification_count = 3;
enum lttng_notification_channel_status nc_status;
enum lttng_event_rule_status event_rule_status;
- struct lttng_notification_channel *notification_channel = NULL;
- struct lttng_condition *condition = NULL;
- struct lttng_event_rule *event_rule = NULL;
- struct lttng_action *action = NULL;
- struct lttng_trigger *trigger = NULL;
+ struct lttng_notification_channel *notification_channel = nullptr;
+ struct lttng_condition *condition = nullptr;
+ struct lttng_event_rule *event_rule = nullptr;
+ struct lttng_action *action = nullptr;
+ struct lttng_trigger *trigger = nullptr;
const char *const trigger_name = "syscall_trigger";
const char *const syscall_name = "openat";
const char *const filter_pattern = "filename == \"/proc/cpuinfo\"";
ok(notification, "Received notification (%d/%d)", i + 1, notification_count);
/* Error. */
- if (notification == NULL) {
+ if (notification == nullptr) {
goto end;
}
static int generate_capture_descr(struct lttng_condition *condition)
{
int ret, i;
- struct lttng_event_expr *expr = NULL;
+ struct lttng_event_expr *expr = nullptr;
const unsigned int basic_field_count =
sizeof(test_capture_base_fields) / sizeof(*test_capture_base_fields);
enum lttng_condition_status cond_status;
int nb_matches;
unsigned int index;
char field_name[FIELD_NAME_MAX_LEN];
- struct lttng_event_expr *array_expr = NULL;
+ struct lttng_event_expr *array_expr = nullptr;
nb_matches = sscanf(test_capture_base_fields[i].field_name,
"%[^[][%u]",
goto end;
}
- if (expr == NULL) {
+ if (expr == nullptr) {
fail("Failed to create capture expression");
ret = -1;
goto end;
bool at_least_one_error = false;
evaluation = lttng_notification_get_evaluation(notification);
- if (evaluation == NULL) {
+ if (evaluation == nullptr) {
fail("Failed to get evaluation from notification during trigger capture test");
ret = 1;
goto end;
}
for (i = 0; i < capture_count; i++) {
- const struct lttng_event_field_value *captured_field = NULL;
+ const struct lttng_event_field_value *captured_field = nullptr;
validate_cb validate;
bool expected;
enum lttng_notification_channel_status nc_status;
int i, ret;
- struct lttng_condition *condition = NULL;
- struct lttng_notification_channel *notification_channel = NULL;
- struct lttng_trigger *trigger = NULL;
+ struct lttng_condition *condition = nullptr;
+ struct lttng_notification_channel *notification_channel = nullptr;
+ struct lttng_trigger *trigger = nullptr;
const char *trigger_name = "my_precious";
const char *pattern;
create_tracepoint_event_rule_trigger(pattern,
trigger_name,
- NULL,
+ nullptr,
0,
- NULL,
+ nullptr,
domain_type,
generate_capture_descr,
&condition,
ok(notification, "Received notification");
/* Error */
- if (notification == NULL) {
+ if (notification == nullptr) {
goto end;
}
int main(int argc, const char *argv[])
{
int test_scenario;
- const char *domain_type_string = NULL;
+ const char *domain_type_string = nullptr;
enum lttng_domain_type domain_type = LTTNG_DOMAIN_NONE;
if (argc < 5) {
int lttng_opt_mi;
int lttng_opt_quiet;
-static void __attribute__((destructor)) pause_pipe_fini(void)
+static void __attribute__((destructor)) pause_pipe_fini()
{
int ret;
goto end;
}
- notifier_notif_consumption_state = (int *) dlsym(NULL, "notifier_consumption_paused");
+ notifier_notif_consumption_state = (int *) dlsym(nullptr, "notifier_consumption_paused");
LTTNG_ASSERT(notifier_notif_consumption_state);
ret = asprintf(&pause_pipe_path, "%s", pause_pipe_path_prefix);
#define TEST_SESSION_NAME "test_session"
#define TEST_CHANNEL_NAME "test_channel"
-static int get_registered_triggers_count(void)
+static int get_registered_triggers_count()
{
int ret;
enum lttng_error_code ret_code;
enum lttng_trigger_status trigger_status;
- struct lttng_triggers *triggers = NULL;
+ struct lttng_triggers *triggers = nullptr;
unsigned int trigger_count;
ret_code = lttng_list_triggers(&triggers);
static int setup_session_with_size_rotation_schedule(const char *session_output_path)
{
int ret;
- struct lttng_session_descriptor *session_desriptor = NULL;
+ struct lttng_session_descriptor *session_desriptor = nullptr;
enum lttng_error_code ret_code;
struct lttng_handle ust_channel_handle = { TEST_SESSION_NAME,
{
channel_cfg.attr.output = LTTNG_EVENT_MMAP;
enum lttng_rotation_status rotation_status;
- struct lttng_rotation_schedule *rotation_schedule = NULL;
+ struct lttng_rotation_schedule *rotation_schedule = nullptr;
session_desriptor =
lttng_session_descriptor_local_create(TEST_SESSION_NAME, session_output_path);
* Returns a negative error code on error, else the number of unregistered
* triggers.
*/
-static int unregister_all_triggers(void)
+static int unregister_all_triggers()
{
int ret;
enum lttng_error_code ret_code;
enum lttng_trigger_status trigger_status;
- struct lttng_triggers *triggers = NULL;
+ struct lttng_triggers *triggers = nullptr;
unsigned int trigger_count, i, unregistered_trigger_count = 0;
ret_code = lttng_list_triggers(&triggers);
return ret;
}
-static int get_registered_triggers_count(void)
+static int get_registered_triggers_count()
{
int ret;
enum lttng_error_code ret_code;
enum lttng_trigger_status trigger_status;
- struct lttng_triggers *triggers = NULL;
+ struct lttng_triggers *triggers = nullptr;
unsigned int trigger_count;
ret_code = lttng_list_triggers(&triggers);
*/
static struct lttng_trigger *create_trigger(uint64_t threshold)
{
- struct lttng_condition *condition = NULL;
- struct lttng_action *action = NULL;
- struct lttng_trigger *trigger = NULL;
+ struct lttng_condition *condition = nullptr;
+ struct lttng_action *action = nullptr;
+ struct lttng_trigger *trigger = nullptr;
enum lttng_condition_status condition_status;
const char *const session_name = "test session";
struct lttng_trigger *trigger = create_trigger(0xbadc0ffee);
enum lttng_trigger_status trigger_status;
const char *trigger_name;
- struct lttng_triggers *triggers = NULL;
+ struct lttng_triggers *triggers = nullptr;
unsigned int trigger_count, i;
enum lttng_error_code ret_code;
struct lttng_trigger *trigger = create_trigger(0xbadc0ffee);
enum lttng_trigger_status trigger_status;
const char *returned_trigger_name;
- struct lttng_triggers *triggers = NULL;
+ struct lttng_triggers *triggers = nullptr;
unsigned int trigger_count, i;
enum lttng_error_code ret_code;
const char *const trigger_name = "some name that is hopefully unique";
struct lttng_trigger *trigger = create_trigger(0xbadc0ffee);
enum lttng_trigger_status trigger_status;
const char *returned_trigger_name;
- struct lttng_triggers *triggers = NULL;
+ struct lttng_triggers *triggers = nullptr;
unsigned int trigger_count, i;
enum lttng_error_code ret_code;
{
int ret;
struct lttng_trigger *trigger = create_trigger(0xbadc0ffee);
- struct lttng_triggers *triggers = NULL;
+ struct lttng_triggers *triggers = nullptr;
diag("Register duplicate anonymous trigger (Unregistration performed with the trigger instance %s)",
unregistration_trigger_instance_name(unregistration_trigger));
int ret;
struct lttng_trigger *trigger_a = create_trigger(0xbadc0ffee);
struct lttng_trigger *trigger_b = create_trigger(0xbadc0ffee);
- struct lttng_triggers *triggers = NULL;
+ struct lttng_triggers *triggers = nullptr;
const char *const trigger_name = "a unique trigger name";
enum lttng_error_code ret_code;
int ret;
struct lttng_trigger *trigger_a = create_trigger(0xbadc0ffee);
struct lttng_trigger *trigger_b = create_trigger(0xbadc0ffee);
- struct lttng_triggers *triggers = NULL;
+ struct lttng_triggers *triggers = nullptr;
enum lttng_error_code ret_code;
diag("Register duplicate automatic name trigger (Unregistration performed with the trigger instance %s)",
lttng_trigger_destroy(trigger_b);
}
-static void register_multiple_anonymous_triggers(void)
+static void register_multiple_anonymous_triggers()
{
int ret;
struct lttng_trigger *trigger_a = create_trigger(0xbadc0ffee);
double_register_named_trigger, double_register_automatic_name_trigger,
};
-int main(void)
+int main()
{
size_t i;
return condition;
}
-static void test_session_consumed_size_condition(void)
+static void test_session_consumed_size_condition()
{
register_trigger_action_list_notify(
"trigger-with-session-consumed-size-condition",
return condition;
}
-static void test_buffer_usage_conditions(void)
+static void test_buffer_usage_conditions()
{
register_trigger_action_list_notify(
"trigger-with-buffer-usage-high-bytes-condition",
return condition;
}
-static void test_session_rotation_conditions(void)
+static void test_session_rotation_conditions()
{
register_trigger_action_list_notify(
"trigger-with-session-rotation-ongoing-condition",
static struct {
const char *name;
- void (*callback)(void);
+ void (*callback)();
} tests[] = {
{
"test_session_consumed_size_condition",
{ "test_session_rotation_conditions", test_session_rotation_conditions },
};
-static void show_known_tests(void)
+static void show_known_tests()
{
size_t i;
int main(int argc, char **argv)
{
- char *path = NULL;
+ char *path = nullptr;
int ret;
struct state state = {};
plan_no_plan();
ret = config_get_section_entries(
- path, NULL, (config_entry_handler_cb) entry_handler, &state);
+ path, nullptr, (config_entry_handler_cb) entry_handler, &state);
ok(ret == 0, "Successfully opened a config file, registered to all sections");
ok(state.section_1 && state.section_2 && state.section_3 && state.section_global,
"Processed entries from each sections");
#define NUM_TESTS 60
-static void test_action_notify(void)
+static void test_action_notify()
{
int ret;
enum lttng_action_status status;
- struct lttng_action *notify_action = NULL, *notify_action_from_buffer = NULL;
- struct lttng_rate_policy *policy = NULL, *default_policy;
+ struct lttng_action *notify_action = nullptr, *notify_action_from_buffer = nullptr;
+ struct lttng_rate_policy *policy = nullptr, *default_policy;
struct lttng_payload payload;
lttng_payload_init(&payload);
/* Validate the default policy for a notify action. */
{
- const struct lttng_rate_policy *cur_policy = NULL;
+ const struct lttng_rate_policy *cur_policy = nullptr;
status = lttng_action_notify_get_rate_policy(notify_action, &cur_policy);
ok(status == LTTNG_ACTION_STATUS_OK &&
lttng_rate_policy_is_equal(default_policy, cur_policy),
/* Validate the custom policy for a notify action. */
{
- const struct lttng_rate_policy *cur_policy = NULL;
+ const struct lttng_rate_policy *cur_policy = nullptr;
status = lttng_action_notify_get_rate_policy(notify_action, &cur_policy);
ok(status == LTTNG_ACTION_STATUS_OK &&
lttng_rate_policy_is_equal(policy, cur_policy),
lttng_payload_reset(&payload);
}
-static void test_action_rotate_session(void)
+static void test_action_rotate_session()
{
int ret;
enum lttng_action_status status;
- struct lttng_action *rotate_session_action = NULL,
- *rotate_session_action_from_buffer = NULL;
- struct lttng_rate_policy *policy = NULL, *default_policy;
+ struct lttng_action *rotate_session_action = nullptr,
+ *rotate_session_action_from_buffer = nullptr;
+ struct lttng_rate_policy *policy = nullptr, *default_policy;
struct lttng_payload payload;
const char *session_name = "my_session_name";
const char *get_session_name;
"Action has type LTTNG_ACTION_TYPE_ROTATE_SESSION");
/* Session name setter. */
- status = lttng_action_rotate_session_set_session_name(NULL, NULL);
+ status = lttng_action_rotate_session_set_session_name(nullptr, nullptr);
ok(status == LTTNG_ACTION_STATUS_INVALID, "Set session name (NULL,NULL) expect invalid");
- status = lttng_action_rotate_session_set_session_name(rotate_session_action, NULL);
+ status = lttng_action_rotate_session_set_session_name(rotate_session_action, nullptr);
ok(status == LTTNG_ACTION_STATUS_INVALID, "Set session name (object,NULL) expect invalid");
- status = lttng_action_rotate_session_set_session_name(NULL, session_name);
+ status = lttng_action_rotate_session_set_session_name(nullptr, session_name);
ok(status == LTTNG_ACTION_STATUS_INVALID, "Set session name (NULL,object) expect invalid");
/* Set the session name */
/* Validate the default policy for a rotate_session action. */
{
- const struct lttng_rate_policy *cur_policy = NULL;
+ const struct lttng_rate_policy *cur_policy = nullptr;
status = lttng_action_rotate_session_get_rate_policy(rotate_session_action,
&cur_policy);
ok(status == LTTNG_ACTION_STATUS_OK &&
/* Validate the custom policy for a rotate_session action. */
{
- const struct lttng_rate_policy *cur_policy = NULL;
+ const struct lttng_rate_policy *cur_policy = nullptr;
status = lttng_action_rotate_session_get_rate_policy(rotate_session_action,
&cur_policy);
ok(status == LTTNG_ACTION_STATUS_OK &&
lttng_payload_reset(&payload);
}
-static void test_action_start_session(void)
+static void test_action_start_session()
{
int ret;
enum lttng_action_status status;
- struct lttng_action *start_session_action = NULL, *start_session_action_from_buffer = NULL;
- struct lttng_rate_policy *policy = NULL, *default_policy;
+ struct lttng_action *start_session_action = nullptr,
+ *start_session_action_from_buffer = nullptr;
+ struct lttng_rate_policy *policy = nullptr, *default_policy;
struct lttng_payload payload;
const char *session_name = "my_session_name";
const char *get_session_name;
"Action has type LTTNG_ACTION_TYPE_START_SESSION");
/* Session name setter. */
- status = lttng_action_start_session_set_session_name(NULL, NULL);
+ status = lttng_action_start_session_set_session_name(nullptr, nullptr);
ok(status == LTTNG_ACTION_STATUS_INVALID, "Set session name (NULL,NULL) expect invalid");
- status = lttng_action_start_session_set_session_name(start_session_action, NULL);
+ status = lttng_action_start_session_set_session_name(start_session_action, nullptr);
ok(status == LTTNG_ACTION_STATUS_INVALID, "Set session name (object,NULL) expect invalid");
- status = lttng_action_start_session_set_session_name(NULL, session_name);
+ status = lttng_action_start_session_set_session_name(nullptr, session_name);
ok(status == LTTNG_ACTION_STATUS_INVALID, "Set session name (NULL,object) expect invalid");
/* Set the session name */
/* Validate the default policy for a start_session action. */
{
- const struct lttng_rate_policy *cur_policy = NULL;
+ const struct lttng_rate_policy *cur_policy = nullptr;
status = lttng_action_start_session_get_rate_policy(start_session_action,
&cur_policy);
ok(status == LTTNG_ACTION_STATUS_OK &&
/* Validate the custom policy for a start_session action. */
{
- const struct lttng_rate_policy *cur_policy = NULL;
+ const struct lttng_rate_policy *cur_policy = nullptr;
status = lttng_action_start_session_get_rate_policy(start_session_action,
&cur_policy);
ok(status == LTTNG_ACTION_STATUS_OK &&
lttng_payload_reset(&payload);
}
-static void test_action_stop_session(void)
+static void test_action_stop_session()
{
int ret;
enum lttng_action_status status;
- struct lttng_action *stop_session_action = NULL, *stop_session_action_from_buffer = NULL;
- struct lttng_rate_policy *policy = NULL, *default_policy;
+ struct lttng_action *stop_session_action = nullptr,
+ *stop_session_action_from_buffer = nullptr;
+ struct lttng_rate_policy *policy = nullptr, *default_policy;
struct lttng_payload payload;
const char *session_name = "my_session_name";
const char *get_session_name;
"Action has type LTTNG_ACTION_TYPE_STOP_SESSION");
/* Session name setter. */
- status = lttng_action_stop_session_set_session_name(NULL, NULL);
+ status = lttng_action_stop_session_set_session_name(nullptr, nullptr);
ok(status == LTTNG_ACTION_STATUS_INVALID, "Set session name (NULL,NULL) expect invalid");
- status = lttng_action_stop_session_set_session_name(stop_session_action, NULL);
+ status = lttng_action_stop_session_set_session_name(stop_session_action, nullptr);
ok(status == LTTNG_ACTION_STATUS_INVALID, "Set session name (object,NULL) expect invalid");
- status = lttng_action_stop_session_set_session_name(NULL, session_name);
+ status = lttng_action_stop_session_set_session_name(nullptr, session_name);
ok(status == LTTNG_ACTION_STATUS_INVALID, "Set session name (NULL,object) expect invalid");
/* Set the session name */
/* Validate the default policy for a stop_session action. */
{
- const struct lttng_rate_policy *cur_policy = NULL;
+ const struct lttng_rate_policy *cur_policy = nullptr;
status =
lttng_action_stop_session_get_rate_policy(stop_session_action, &cur_policy);
ok(status == LTTNG_ACTION_STATUS_OK &&
/* Validate the custom policy for a stop_session action. */
{
- const struct lttng_rate_policy *cur_policy = NULL;
+ const struct lttng_rate_policy *cur_policy = nullptr;
status =
lttng_action_stop_session_get_rate_policy(stop_session_action, &cur_policy);
ok(status == LTTNG_ACTION_STATUS_OK &&
lttng_payload_reset(&payload);
}
-static void test_action_snapshot_session(void)
+static void test_action_snapshot_session()
{
int ret;
enum lttng_action_status status;
- struct lttng_action *snapshot_session_action = NULL,
- *snapshot_session_action_from_buffer = NULL;
- struct lttng_rate_policy *policy = NULL, *default_policy;
+ struct lttng_action *snapshot_session_action = nullptr,
+ *snapshot_session_action_from_buffer = nullptr;
+ struct lttng_rate_policy *policy = nullptr, *default_policy;
struct lttng_payload payload;
const char *session_name = "my_session_name";
const char *get_session_name;
"Action has type LTTNG_ACTION_TYPE_SNAPSHOT_SESSION");
/* Session name setter. */
- status = lttng_action_snapshot_session_set_session_name(NULL, NULL);
+ status = lttng_action_snapshot_session_set_session_name(nullptr, nullptr);
ok(status == LTTNG_ACTION_STATUS_INVALID, "Set session name (NULL,NULL) expect invalid");
- status = lttng_action_snapshot_session_set_session_name(snapshot_session_action, NULL);
+ status = lttng_action_snapshot_session_set_session_name(snapshot_session_action, nullptr);
ok(status == LTTNG_ACTION_STATUS_INVALID, "Set session name (object,NULL) expect invalid");
- status = lttng_action_snapshot_session_set_session_name(NULL, session_name);
+ status = lttng_action_snapshot_session_set_session_name(nullptr, session_name);
ok(status == LTTNG_ACTION_STATUS_INVALID, "Set session name (NULL,object) expect invalid");
/* Set the session name */
/* Validate the default policy for a snapshot_session action. */
{
- const struct lttng_rate_policy *cur_policy = NULL;
+ const struct lttng_rate_policy *cur_policy = nullptr;
status = lttng_action_snapshot_session_get_rate_policy(snapshot_session_action,
&cur_policy);
ok(status == LTTNG_ACTION_STATUS_OK &&
/* Validate the custom policy for a snapshot_session action. */
{
- const struct lttng_rate_policy *cur_policy = NULL;
+ const struct lttng_rate_policy *cur_policy = nullptr;
status = lttng_action_snapshot_session_get_rate_policy(snapshot_session_action,
&cur_policy);
ok(status == LTTNG_ACTION_STATUS_OK &&
lttng_payload_reset(&payload);
}
-int main(void)
+int main()
{
plan_tests(NUM_TESTS);
test_action_notify();
int lttng_opt_verbose;
int lttng_opt_mi;
-static void test_contains_string(void)
+static void test_contains_string()
{
const char buf[] = { 'A', 'l', 'l', 'o', '\0' };
struct lttng_buffer_view view = lttng_buffer_view_init(buf, 0, 5);
ok1(!lttng_buffer_view_contains_string(&view_minus_one, buf, 5));
}
-int main(void)
+int main()
{
plan_tests(TEST_COUNT);
#define NUM_TESTS 13
-static void test_condition_event_rule(void)
+static void test_condition_event_rule()
{
int ret, i;
- struct lttng_event_rule *tracepoint = NULL;
- const struct lttng_event_rule *tracepoint_tmp = NULL;
+ struct lttng_event_rule *tracepoint = nullptr;
+ const struct lttng_event_rule *tracepoint_tmp = nullptr;
enum lttng_event_rule_status status;
- struct lttng_condition *condition = NULL;
- struct lttng_condition *condition_from_buffer = NULL;
+ struct lttng_condition *condition = nullptr;
+ struct lttng_condition *condition_from_buffer = nullptr;
enum lttng_condition_status condition_status;
const char *pattern = "my_event_*";
const char *filter = "msg_id == 23 && size >= 2048";
const char *exclusions[] = { "my_event_test1", "my_event_test2", "my_event_test3" };
- struct lttng_log_level_rule *log_level_rule_at_least_as_severe = NULL;
+ struct lttng_log_level_rule *log_level_rule_at_least_as_severe = nullptr;
struct lttng_payload buffer;
lttng_payload_init(&buffer);
lttng_log_level_rule_destroy(log_level_rule_at_least_as_severe);
}
-int main(void)
+int main()
{
plan_tests(NUM_TESTS);
test_condition_event_rule();
int ret;
const int file_flags = O_WRONLY | O_CREAT | O_TRUNC;
const mode_t file_mode = S_IRUSR | S_IWUSR | S_IRGRP | S_IWGRP;
- char *branch_name = NULL;
+ char *branch_name = nullptr;
ret = asprintf(&branch_name, "%s/%s", test_root_name, "a/b/c/d");
if (ret < 0) {
const char *test_root_name)
{
int ret;
- char *file_name = NULL;
+ char *file_name = nullptr;
ret = asprintf(&file_name, "%s/%s", test_root_name, "a/b/e/file1");
if (ret < 0) {
{
int ret, tests_ran = 0;
struct lttng_directory_handle *test_dir_handle;
- char *created_dir = NULL;
+ char *created_dir = nullptr;
const char test_root_name[] = "fail_non_empty";
- char *test_dir_path = NULL;
+ char *test_dir_path = nullptr;
diag("rmdir (fail if non-empty)");
{
int ret, tests_ran = 0;
struct lttng_directory_handle *test_dir_handle;
- char *created_dir = NULL;
+ char *created_dir = nullptr;
const char test_root_name[] = "skip_non_empty";
- char *test_dir_path = NULL;
+ char *test_dir_path = nullptr;
diag("rmdir (skip if non-empty)");
return ret == 0 ? tests_ran : ret;
}
-int main(void)
+int main()
{
int ret;
char test_dir[] = "/tmp/lttng-XXXXXX";
#define NR_TESTS 4
-static void test_event_payload_field(void)
+static void test_event_payload_field()
{
struct lttng_event_expr *event_expr;
- struct lttng_bytecode *bytecode = NULL;
+ struct lttng_bytecode *bytecode = nullptr;
int ret;
event_expr = lttng_event_expr_event_payload_field_create("tourlou");
free(bytecode);
}
-static void test_channel_context_field(void)
+static void test_channel_context_field()
{
struct lttng_event_expr *event_expr;
- struct lttng_bytecode *bytecode = NULL;
+ struct lttng_bytecode *bytecode = nullptr;
int ret;
event_expr = lttng_event_expr_channel_context_field_create("tourlou");
free(bytecode);
}
-static void test_app_specific_context_field(void)
+static void test_app_specific_context_field()
{
struct lttng_event_expr *event_expr;
- struct lttng_bytecode *bytecode = NULL;
+ struct lttng_bytecode *bytecode = nullptr;
int ret;
event_expr = lttng_event_expr_app_specific_context_field_create("Bob", "Leponge");
free(bytecode);
}
-static void test_array_field_element(void)
+static void test_array_field_element()
{
struct lttng_event_expr *event_expr;
- struct lttng_bytecode *bytecode = NULL;
+ struct lttng_bytecode *bytecode = nullptr;
int ret;
event_expr = lttng_event_expr_event_payload_field_create("allo");
free(bytecode);
}
-int main(void)
+int main()
{
plan_tests(NR_TESTS);
using event_rule_set_log_level = enum lttng_event_rule_status (*)(
struct lttng_event_rule *, const struct lttng_log_level_rule *);
-static void test_event_rule_kernel_tracepoint(void)
+static void test_event_rule_kernel_tracepoint()
{
- struct lttng_event_rule *tracepoint = NULL;
- struct lttng_event_rule *tracepoint_from_buffer = NULL;
+ struct lttng_event_rule *tracepoint = nullptr;
+ struct lttng_event_rule *tracepoint_from_buffer = nullptr;
enum lttng_event_rule_status status;
const char *pattern = "my_event_*";
const char *filter = "msg_id == 23 && size >= 2048";
lttng_event_rule_destroy(tracepoint_from_buffer);
}
-static void test_event_rule_user_tracepoint(void)
+static void test_event_rule_user_tracepoint()
{
int i;
unsigned int count;
- struct lttng_event_rule *tracepoint = NULL;
- struct lttng_event_rule *tracepoint_from_buffer = NULL;
+ struct lttng_event_rule *tracepoint = nullptr;
+ struct lttng_event_rule *tracepoint_from_buffer = nullptr;
enum lttng_event_rule_status status;
const char *pattern = "my_event_*";
const char *filter = "msg_id == 23 && size >= 2048";
const char *name_pattern_exclusions[] = { "my_event_test1",
"my_event_test2",
"my_event_test3" };
- struct lttng_log_level_rule *log_level_rule = NULL;
- const struct lttng_log_level_rule *log_level_rule_return = NULL;
+ struct lttng_log_level_rule *log_level_rule = nullptr;
+ const struct lttng_log_level_rule *log_level_rule_return = nullptr;
struct lttng_payload payload;
diag("Testing lttng_event_rule_user_tracepoint.");
lttng_log_level_rule_destroy(log_level_rule);
}
-static void test_event_rule_syscall(void)
+static void test_event_rule_syscall()
{
- struct lttng_event_rule *syscall = NULL;
- struct lttng_event_rule *syscall_from_buffer = NULL;
+ struct lttng_event_rule *syscall = nullptr;
+ struct lttng_event_rule *syscall_from_buffer = nullptr;
enum lttng_event_rule_status status;
const char *pattern = "my_event_*";
const char *filter = "msg_id == 23 && size >= 2048";
lttng_event_rule_destroy(syscall_from_buffer);
}
-static void test_event_rule_jul_logging(void)
+static void test_event_rule_jul_logging()
{
- struct lttng_event_rule *jul_logging = NULL;
- struct lttng_event_rule *jul_logging_from_buffer = NULL;
+ struct lttng_event_rule *jul_logging = nullptr;
+ struct lttng_event_rule *jul_logging_from_buffer = nullptr;
enum lttng_event_rule_status status;
const char *pattern = "my_event_*";
const char *filter = "msg_id == 23 && size >= 2048";
const char *tmp;
- struct lttng_log_level_rule *log_level_rule = NULL;
- const struct lttng_log_level_rule *log_level_rule_return = NULL;
+ struct lttng_log_level_rule *log_level_rule = nullptr;
+ const struct lttng_log_level_rule *log_level_rule_return = nullptr;
struct lttng_payload payload;
diag("Testing lttng_event_rule_user_jul_logging.");
lttng_log_level_rule_destroy(log_level_rule);
}
-static void test_event_rule_log4j_logging(void)
+static void test_event_rule_log4j_logging()
{
- struct lttng_event_rule *log4j_logging = NULL;
- struct lttng_event_rule *log4j_logging_from_buffer = NULL;
+ struct lttng_event_rule *log4j_logging = nullptr;
+ struct lttng_event_rule *log4j_logging_from_buffer = nullptr;
enum lttng_event_rule_status status;
const char *pattern = "my_event_*";
const char *filter = "msg_id == 23 && size >= 2048";
const char *tmp;
- struct lttng_log_level_rule *log_level_rule = NULL;
- const struct lttng_log_level_rule *log_level_rule_return = NULL;
+ struct lttng_log_level_rule *log_level_rule = nullptr;
+ const struct lttng_log_level_rule *log_level_rule_return = nullptr;
struct lttng_payload payload;
diag("Testing lttng_event_rule_user_log4j_logging.");
lttng_log_level_rule_destroy(log_level_rule);
}
-static void test_event_rule_python_logging(void)
+static void test_event_rule_python_logging()
{
- struct lttng_event_rule *python_logging = NULL;
- struct lttng_event_rule *python_logging_from_buffer = NULL;
+ struct lttng_event_rule *python_logging = nullptr;
+ struct lttng_event_rule *python_logging_from_buffer = nullptr;
enum lttng_event_rule_status status;
const char *pattern = "my_event_*";
const char *filter = "msg_id == 23 && size >= 2048";
const char *tmp;
- struct lttng_log_level_rule *log_level_rule = NULL;
- const struct lttng_log_level_rule *log_level_rule_return = NULL;
+ struct lttng_log_level_rule *log_level_rule = nullptr;
+ const struct lttng_log_level_rule *log_level_rule_return = nullptr;
struct lttng_payload payload;
diag("Testing lttng_event_rule_user_python_logging.");
}
#ifdef __linux__
-static void test_event_rule_userspace_probe(void)
+static void test_event_rule_userspace_probe()
{
- struct lttng_event_rule *uprobe = NULL;
- struct lttng_event_rule *uprobe_from_buffer = NULL;
- struct lttng_userspace_probe_location_lookup_method *lookup_method = NULL;
- struct lttng_userspace_probe_location *probe_location = NULL;
- const struct lttng_userspace_probe_location *probe_location_tmp = NULL;
+ struct lttng_event_rule *uprobe = nullptr;
+ struct lttng_event_rule *uprobe_from_buffer = nullptr;
+ struct lttng_userspace_probe_location_lookup_method *lookup_method = nullptr;
+ struct lttng_userspace_probe_location *probe_location = nullptr;
+ const struct lttng_userspace_probe_location *probe_location_tmp = nullptr;
enum lttng_event_rule_status status;
const char *probe_name = "my_probe.";
}
/* Ownership transferred to the probe location function object. */
- lookup_method = NULL;
+ lookup_method = nullptr;
lttng_payload_init(&payload);
static void
test_event_rule_kernel_probe_by_location(const struct lttng_kernel_probe_location *location)
{
- struct lttng_event_rule *kprobe = NULL;
- struct lttng_event_rule *kprobe_from_buffer = NULL;
+ struct lttng_event_rule *kprobe = nullptr;
+ struct lttng_event_rule *kprobe_from_buffer = nullptr;
enum lttng_event_rule_status status;
const struct lttng_kernel_probe_location *_location;
lttng_event_rule_destroy(kprobe_from_buffer);
}
-static void test_event_rule_kernel_probe(void)
+static void test_event_rule_kernel_probe()
{
- struct lttng_kernel_probe_location *address_location = NULL;
- struct lttng_kernel_probe_location *symbol_location = NULL;
+ struct lttng_kernel_probe_location *address_location = nullptr;
+ struct lttng_kernel_probe_location *symbol_location = nullptr;
address_location = lttng_kernel_probe_location_address_create(50);
symbol_location = lttng_kernel_probe_location_symbol_create("une_bonne", 50);
lttng_event_rule_destroy(rule);
}
-static void test_event_rule_log_level_ust(void)
+static void test_event_rule_log_level_ust()
{
const int tagged_log_level_values[] = {
LTTNG_LOGLEVEL_EMERG, LTTNG_LOGLEVEL_ALERT,
lttng_event_rule_user_tracepoint_set_log_level_rule,
tagged_log_level_values,
ARRAY_SIZE(tagged_log_level_values),
- NULL,
+ nullptr,
0,
invalid_log_level_values,
ARRAY_SIZE(invalid_log_level_values));
}
-static void test_event_rule_log_level_jul(void)
+static void test_event_rule_log_level_jul()
{
const int tagged_log_level_values[] = {
LTTNG_LOGLEVEL_JUL_OFF, LTTNG_LOGLEVEL_JUL_SEVERE, LTTNG_LOGLEVEL_JUL_WARNING,
ARRAY_SIZE(tagged_log_level_values),
valid_log_level_values,
ARRAY_SIZE(valid_log_level_values),
- NULL,
+ nullptr,
0);
}
-static void test_event_rule_log_level_log4j(void)
+static void test_event_rule_log_level_log4j()
{
const int tagged_log_level_values[] = {
LTTNG_LOGLEVEL_LOG4J_OFF, LTTNG_LOGLEVEL_LOG4J_FATAL, LTTNG_LOGLEVEL_LOG4J_ERROR,
ARRAY_SIZE(tagged_log_level_values),
valid_log_level_values,
ARRAY_SIZE(valid_log_level_values),
- NULL,
+ nullptr,
0);
}
-static void test_event_rule_log_level_python(void)
+static void test_event_rule_log_level_python()
{
const int tagged_log_level_values[] = {
LTTNG_LOGLEVEL_PYTHON_CRITICAL, LTTNG_LOGLEVEL_PYTHON_ERROR,
ARRAY_SIZE(tagged_log_level_values),
valid_log_level_values,
ARRAY_SIZE(valid_log_level_values),
- NULL,
+ nullptr,
0);
}
-int main(void)
+int main()
{
plan_tests(NUM_TESTS);
test_event_rule_kernel_tracepoint();
}
}
-static int fd_count(void)
+static int fd_count()
{
DIR *dir;
struct dirent *entry;
goto end;
}
- while ((entry = readdir(dir)) != NULL) {
+ while ((entry = readdir(dir)) != nullptr) {
if (!strcmp(entry->d_name, ".") || !strcmp(entry->d_name, "..")) {
continue;
}
for (i = 0; i < sizeof(files) / sizeof(*files); i++) {
int fd = files[i].fd;
int ret = fd_tracker_close_unsuspendable_fd(
- tracker, &files[i].fd, 1, noop_close, NULL);
+ tracker, &files[i].fd, 1, noop_close, nullptr);
ok(ret == 0, "Untrack unsuspendable fd %d (%s)", fd, files[i].name);
}
/*
* Basic test opening and closing three unsuspendable fds.
*/
-static void test_unsuspendable_basic(void)
+static void test_unsuspendable_basic()
{
int ret;
struct fd_tracker *tracker;
- char *test_directory = NULL, *unlinked_files_directory = NULL;
+ char *test_directory = nullptr, *unlinked_files_directory = nullptr;
get_temporary_directories(&test_directory, &unlinked_files_directory);
* Validate that user callback return values are returned to the
* caller of the fd tracker.
*/
-static void test_unsuspendable_cb_return(void)
+static void test_unsuspendable_cb_return()
{
int ret, stdout_fd = fileno(stdout), out_fd = 42;
struct fd_tracker *tracker;
int expected_error = -ENETDOWN;
- char *test_directory = NULL, *unlinked_files_directory = NULL;
+ char *test_directory = nullptr, *unlinked_files_directory = nullptr;
get_temporary_directories(&test_directory, &unlinked_files_directory);
/* The error_open callback should fail and return 'expected_error'. */
ret = fd_tracker_open_unsuspendable_fd(
- tracker, &out_fd, NULL, 1, error_open, &expected_error);
+ tracker, &out_fd, nullptr, 1, error_open, &expected_error);
ok(ret == expected_error,
"fd_tracker_open_unsuspendable_fd() forwards the user callback's error code");
ok(out_fd == 42,
* Track a valid fd since we don't want the tracker to fail with an
* invalid fd error for this test.
*/
- ret = fd_tracker_open_unsuspendable_fd(tracker, &out_fd, NULL, 1, noop_open, &stdout_fd);
+ ret = fd_tracker_open_unsuspendable_fd(tracker, &out_fd, nullptr, 1, noop_open, &stdout_fd);
ok(out_fd == stdout_fd,
"fd_tracker_open_unsuspendable_fd() sets the output fd parameter to the newly-tracked fd's value");
LTTNG_ASSERT(!ret);
* Validate that the tracker refuses to track two identical unsuspendable
* file descriptors.
*/
-static void test_unsuspendable_duplicate(void)
+static void test_unsuspendable_duplicate()
{
int ret, stdout_fd = fileno(stdout), out_fd;
struct fd_tracker *tracker;
- char *test_directory = NULL, *unlinked_files_directory = NULL;
+ char *test_directory = nullptr, *unlinked_files_directory = nullptr;
get_temporary_directories(&test_directory, &unlinked_files_directory);
tracker = fd_tracker_create(unlinked_files_directory, TRACKER_FD_LIMIT);
LTTNG_ASSERT(tracker);
- ret = fd_tracker_open_unsuspendable_fd(tracker, &out_fd, NULL, 1, noop_open, &stdout_fd);
+ ret = fd_tracker_open_unsuspendable_fd(tracker, &out_fd, nullptr, 1, noop_open, &stdout_fd);
LTTNG_ASSERT(!ret);
- ret = fd_tracker_open_unsuspendable_fd(tracker, &out_fd, NULL, 1, noop_open, &stdout_fd);
+ ret = fd_tracker_open_unsuspendable_fd(tracker, &out_fd, nullptr, 1, noop_open, &stdout_fd);
ok(ret == -EEXIST, "EEXIST reported on open of an already tracked file descriptor");
- ret = fd_tracker_close_unsuspendable_fd(tracker, &stdout_fd, 1, noop_close, NULL);
+ ret = fd_tracker_close_unsuspendable_fd(tracker, &stdout_fd, 1, noop_close, nullptr);
LTTNG_ASSERT(!ret);
fd_tracker_destroy(tracker);
* Validate that the tracker enforces the open file descriptor limit
* when unsuspendable file descriptors are being opened.
*/
-static void test_unsuspendable_limit(void)
+static void test_unsuspendable_limit()
{
struct fd_tracker *tracker;
int ret, stdout_fd = fileno(stdout), out_fd;
int fds[TRACKER_FD_LIMIT];
- char *test_directory = NULL, *unlinked_files_directory = NULL;
+ char *test_directory = nullptr, *unlinked_files_directory = nullptr;
get_temporary_directories(&test_directory, &unlinked_files_directory);
LTTNG_ASSERT(tracker);
ret = fd_tracker_open_unsuspendable_fd(
- tracker, fds, NULL, TRACKER_FD_LIMIT, open_pipes, NULL);
+ tracker, fds, nullptr, TRACKER_FD_LIMIT, open_pipes, nullptr);
ok(ret == 0,
"File descriptor tracker allowed the user to meet its limit with unsuspendable file descriptors (%d)",
TRACKER_FD_LIMIT);
- ret = fd_tracker_open_unsuspendable_fd(tracker, &out_fd, NULL, 1, noop_open, &stdout_fd);
+ ret = fd_tracker_open_unsuspendable_fd(tracker, &out_fd, nullptr, 1, noop_open, &stdout_fd);
ok(ret == -EMFILE,
"EMFILE reported when exceeding the file descriptor limit while opening an unsuspendable fd");
- ret = fd_tracker_close_unsuspendable_fd(tracker, fds, TRACKER_FD_LIMIT, close_pipes, NULL);
+ ret = fd_tracker_close_unsuspendable_fd(
+ tracker, fds, TRACKER_FD_LIMIT, close_pipes, nullptr);
LTTNG_ASSERT(!ret);
fd_tracker_destroy(tracker);
* Validate that the tracker refuses to track two identical unsuspendable
* file descriptors.
*/
-static void test_unsuspendable_close_untracked(void)
+static void test_unsuspendable_close_untracked()
{
int ret, stdout_fd = fileno(stdout), unknown_fds[2], out_fd;
struct fd_tracker *tracker;
- char *test_directory = NULL, *unlinked_files_directory = NULL;
+ char *test_directory = nullptr, *unlinked_files_directory = nullptr;
get_temporary_directories(&test_directory, &unlinked_files_directory);
ret = close(unknown_fds[1]);
LTTNG_ASSERT(ret == 0);
- ret = fd_tracker_open_unsuspendable_fd(tracker, &out_fd, NULL, 1, noop_open, &stdout_fd);
+ ret = fd_tracker_open_unsuspendable_fd(tracker, &out_fd, nullptr, 1, noop_open, &stdout_fd);
LTTNG_ASSERT(!ret);
- ret = fd_tracker_close_unsuspendable_fd(tracker, unknown_fds, 1, noop_close, NULL);
+ ret = fd_tracker_close_unsuspendable_fd(tracker, unknown_fds, 1, noop_close, nullptr);
ok(ret == -EINVAL, "EINVAL reported on close of an untracked file descriptor");
- ret = fd_tracker_close_unsuspendable_fd(tracker, &stdout_fd, 1, noop_close, NULL);
+ ret = fd_tracker_close_unsuspendable_fd(tracker, &stdout_fd, 1, noop_close, nullptr);
LTTNG_ASSERT(!ret);
fd_tracker_destroy(tracker);
return ret;
}
-static void test_suspendable_limit(void)
+static void test_suspendable_limit()
{
int ret;
const int files_to_create = TRACKER_FD_LIMIT * 10;
struct fd_tracker *tracker;
- char *test_directory = NULL, *unlinked_files_directory = NULL;
+ char *test_directory = nullptr, *unlinked_files_directory = nullptr;
char *output_files[files_to_create];
struct fs_handle *handles[files_to_create];
- struct lttng_directory_handle *dir_handle = NULL;
+ struct lttng_directory_handle *dir_handle = nullptr;
int dir_handle_fd_count;
memset(output_files, 0, sizeof(output_files));
free(unlinked_files_directory);
}
-static void test_mixed_limit(void)
+static void test_mixed_limit()
{
int ret;
const int files_to_create = TRACKER_FD_LIMIT;
struct fd_tracker *tracker;
- char *test_directory = NULL, *unlinked_files_directory = NULL;
+ char *test_directory = nullptr, *unlinked_files_directory = nullptr;
char *output_files[files_to_create];
struct fs_handle *handles[files_to_create];
- struct lttng_directory_handle *dir_handle = NULL;
+ struct lttng_directory_handle *dir_handle = nullptr;
int dir_handle_fd_count;
memset(output_files, 0, sizeof(output_files));
*
* The content of the files is also verified at the end.
*/
-static void test_suspendable_restore(void)
+static void test_suspendable_restore()
{
int ret;
const int files_to_create = TRACKER_FD_LIMIT * 10;
bool write_success = true;
bool fd_cap_respected = true;
bool content_ok = true;
- struct lttng_directory_handle *dir_handle = NULL;
+ struct lttng_directory_handle *dir_handle = nullptr;
int dir_handle_fd_count;
- char *test_directory = NULL, *unlinked_files_directory = NULL;
+ char *test_directory = nullptr, *unlinked_files_directory = nullptr;
memset(output_files, 0, sizeof(output_files));
memset(handles, 0, sizeof(handles));
free(unlinked_files_directory);
}
-static void test_unlink(void)
+static void test_unlink()
{
int ret;
struct fd_tracker *tracker;
const int handles_to_open = 2;
struct fs_handle *handles[handles_to_open];
- struct fs_handle *new_handle = NULL;
+ struct fs_handle *new_handle = nullptr;
struct stat statbuf;
- struct lttng_directory_handle *dir_handle = NULL;
+ struct lttng_directory_handle *dir_handle = nullptr;
const char file_name[] = "my_file";
- char *test_directory = NULL, *unlinked_files_directory = NULL;
- char *unlinked_file_zero = NULL, *unlinked_file_one = NULL;
+ char *test_directory = nullptr, *unlinked_files_directory = nullptr;
+ char *unlinked_file_zero = nullptr, *unlinked_file_one = nullptr;
int fd;
get_temporary_directories(&test_directory, &unlinked_files_directory);
lttng_directory_handle_put(dir_handle);
}
-int main(void)
+int main()
{
plan_tests(NUM_TESTS);
diag("File descriptor tracker unit tests");
* Return random string of 10 characters.
* Not thread-safe.
*/
-static char *get_random_string(void)
+static char *get_random_string()
{
int i;
return random_string;
}
-static void test_create_one_kernel_session(void)
+static void test_create_one_kernel_session()
{
kern = trace_kernel_create_session();
- ok(kern != NULL, "Create kernel session");
+ ok(kern != nullptr, "Create kernel session");
if (!kern) {
skip(1, "Kernel session is null");
}
ok(kern->fd == -1 && kern->metadata_stream_fd == -1 && kern->consumer_fds_sent == 0 &&
kern->channel_count == 0 && kern->stream_count_global == 0 &&
- kern->metadata == NULL,
+ kern->metadata == nullptr,
"Validate kernel session");
}
-static void test_create_kernel_metadata(void)
+static void test_create_kernel_metadata()
{
- LTTNG_ASSERT(kern != NULL);
+ LTTNG_ASSERT(kern != nullptr);
kern->metadata = trace_kernel_create_metadata();
- ok(kern->metadata != NULL, "Create kernel metadata");
+ ok(kern->metadata != nullptr, "Create kernel metadata");
- ok(kern->metadata->fd == -1 && kern->metadata->conf != NULL &&
+ ok(kern->metadata->fd == -1 && kern->metadata->conf != nullptr &&
kern->metadata->conf->attr.overwrite == DEFAULT_METADATA_OVERWRITE &&
kern->metadata->conf->attr.subbuf_size == default_get_metadata_subbuf_size() &&
kern->metadata->conf->attr.num_subbuf == DEFAULT_METADATA_SUBBUF_NUM &&
trace_kernel_destroy_metadata(kern->metadata);
}
-static void test_create_kernel_channel(void)
+static void test_create_kernel_channel()
{
struct ltt_kernel_channel *chan;
struct lttng_channel attr;
attr.attr.extended.ptr = &extended;
chan = trace_kernel_create_channel(&attr);
- ok(chan != NULL, "Create kernel channel");
+ ok(chan != nullptr, "Create kernel channel");
if (!chan) {
skip(1, "Channel is null");
trace_kernel_destroy_channel(chan);
}
-static void test_create_kernel_event(void)
+static void test_create_kernel_event()
{
enum lttng_error_code ret;
struct ltt_kernel_event *event;
ev.type = LTTNG_EVENT_TRACEPOINT;
ev.loglevel_type = LTTNG_EVENT_LOGLEVEL_ALL;
- ret = trace_kernel_create_event(&ev, NULL, NULL, &event);
+ ret = trace_kernel_create_event(&ev, nullptr, nullptr, &event);
ok(ret == LTTNG_OK, "Create kernel event");
if (!event) {
trace_kernel_destroy_event(event);
}
-static void test_create_kernel_stream(void)
+static void test_create_kernel_stream()
{
struct ltt_kernel_stream *stream;
stream = trace_kernel_create_stream("stream1", 0);
- ok(stream != NULL, "Create kernel stream");
+ ok(stream != nullptr, "Create kernel stream");
if (!stream) {
skip(1, "Stream is null");
trace_kernel_destroy_stream(stream);
}
-int main(void)
+int main()
{
plan_tests(NUM_TESTS);
#define NUM_TESTS 24
-static void test_kernel_probe_location_address(void)
+static void test_kernel_probe_location_address()
{
- struct lttng_kernel_probe_location *location = NULL;
- struct lttng_kernel_probe_location *location_from_buffer = NULL;
+ struct lttng_kernel_probe_location *location = nullptr;
+ struct lttng_kernel_probe_location *location_from_buffer = nullptr;
enum lttng_kernel_probe_location_status status;
enum lttng_kernel_probe_location_type type;
uint64_t address = 50, _address;
lttng_kernel_probe_location_destroy(location_from_buffer);
}
-static void test_kernel_probe_location_symbol(void)
+static void test_kernel_probe_location_symbol()
{
- struct lttng_kernel_probe_location *location = NULL;
- struct lttng_kernel_probe_location *location_from_buffer = NULL;
+ struct lttng_kernel_probe_location *location = nullptr;
+ struct lttng_kernel_probe_location *location_from_buffer = nullptr;
enum lttng_kernel_probe_location_status status;
enum lttng_kernel_probe_location_type type;
uint64_t offset = 50, _offset;
lttng_kernel_probe_location_destroy(location_from_buffer);
}
-int main(void)
+int main()
{
plan_tests(NUM_TESTS);
test_kernel_probe_location_address();
#define NUM_TESTS 29
-static void test_log_level_rule_error(void)
+static void test_log_level_rule_error()
{
int level = 9000;
struct lttng_log_level_rule *exactly = lttng_log_level_rule_exactly_create(level);
struct lttng_log_level_rule *at_least_as_severe =
lttng_log_level_rule_at_least_as_severe_as_create(level);
- ok(lttng_log_level_rule_get_type(NULL) == LTTNG_LOG_LEVEL_RULE_TYPE_UNKNOWN,
+ ok(lttng_log_level_rule_get_type(nullptr) == LTTNG_LOG_LEVEL_RULE_TYPE_UNKNOWN,
"Get type on invalid pointer");
- ok(lttng_log_level_rule_exactly_get_level(NULL, NULL) ==
+ ok(lttng_log_level_rule_exactly_get_level(nullptr, nullptr) ==
LTTNG_LOG_LEVEL_RULE_STATUS_INVALID,
"lttng_log_level_rule_exactly_get_level (NULL, NULL) returns invalid");
- ok(lttng_log_level_rule_exactly_get_level(exactly, NULL) ==
+ ok(lttng_log_level_rule_exactly_get_level(exactly, nullptr) ==
LTTNG_LOG_LEVEL_RULE_STATUS_INVALID,
"lttng_log_level_rule_exactly_get_level (valid, NULL) returns invalid");
- ok(lttng_log_level_rule_exactly_get_level(NULL, &level) ==
+ ok(lttng_log_level_rule_exactly_get_level(nullptr, &level) ==
LTTNG_LOG_LEVEL_RULE_STATUS_INVALID,
"lttng_log_level_rule_exactly_get_level (NULL, valid) returns invalid");
- ok(lttng_log_level_rule_at_least_as_severe_as_get_level(NULL, NULL) ==
+ ok(lttng_log_level_rule_at_least_as_severe_as_get_level(nullptr, nullptr) ==
LTTNG_LOG_LEVEL_RULE_STATUS_INVALID,
"lttng_log_level_rule_at_least_as_severe_as_get_level (NULL, NULL) returns invalid");
- ok(lttng_log_level_rule_at_least_as_severe_as_get_level(exactly, NULL) ==
+ ok(lttng_log_level_rule_at_least_as_severe_as_get_level(exactly, nullptr) ==
LTTNG_LOG_LEVEL_RULE_STATUS_INVALID,
"lttng_log_level_rule_at_least_as_severe_as_get_level (valid, NULL) returns invalid");
- ok(lttng_log_level_rule_at_least_as_severe_as_get_level(NULL, &level) ==
+ ok(lttng_log_level_rule_at_least_as_severe_as_get_level(nullptr, &level) ==
LTTNG_LOG_LEVEL_RULE_STATUS_INVALID,
"lttng_log_level_rule_at_least_as_severe_as_get_level (NULL, valid) returns invalid");
static void test_log_level_rule_serialize_deserialize(const struct lttng_log_level_rule *rule)
{
- struct lttng_log_level_rule *log_level_rule_from_buffer = NULL;
+ struct lttng_log_level_rule *log_level_rule_from_buffer = nullptr;
struct lttng_payload payload;
lttng_payload_init(&payload);
lttng_payload_reset(&payload);
}
-static void test_log_level_rule_is_equal_exactly(void)
+static void test_log_level_rule_is_equal_exactly()
{
int level = 9000, no_eq_level = 420;
struct lttng_log_level_rule *a, *b, *different_level, *different_type;
lttng_log_level_rule_destroy(different_type);
}
-static void test_log_level_rule_is_equal_at_least_as_severe_as(void)
+static void test_log_level_rule_is_equal_at_least_as_severe_as()
{
int level = 9000, no_eq_level = 420;
struct lttng_log_level_rule *a, *b, *different_level, *different_type;
lttng_log_level_rule_destroy(different_type);
}
-static void test_log_level_rule_exactly(void)
+static void test_log_level_rule_exactly()
{
int level = 9000;
int _level;
- struct lttng_log_level_rule *exactly = NULL;
+ struct lttng_log_level_rule *exactly = nullptr;
enum lttng_log_level_rule_status status;
exactly = lttng_log_level_rule_exactly_create(level);
lttng_log_level_rule_destroy(exactly);
}
-static void test_log_level_rule_at_least_as_severe_as(void)
+static void test_log_level_rule_at_least_as_severe_as()
{
int level = 9000;
int _level;
- struct lttng_log_level_rule *at_least_as_severe_as = NULL;
+ struct lttng_log_level_rule *at_least_as_severe_as = nullptr;
enum lttng_log_level_rule_status status;
at_least_as_severe_as = lttng_log_level_rule_at_least_as_severe_as_create(level);
lttng_log_level_rule_destroy(at_least_as_severe_as);
}
-int main(void)
+int main()
{
plan_tests(NUM_TESTS);
test_log_level_rule_exactly();
static void test_condition_buffer_usage(struct lttng_condition *buffer_usage_condition)
{
enum lttng_condition_status status = LTTNG_CONDITION_STATUS_OK;
- const char *session_name = NULL;
- const char *channel_name = NULL;
+ const char *session_name = nullptr;
+ const char *channel_name = nullptr;
enum lttng_domain_type domain_type;
/* Start at a non zero value to validate initialization */
double threshold_ratio;
ok(status == LTTNG_CONDITION_STATUS_UNSET, "Domain name is unset");
diag("Testing session name set/get");
- status = lttng_condition_buffer_usage_set_session_name(NULL, "Test");
+ status = lttng_condition_buffer_usage_set_session_name(nullptr, "Test");
ok(status == LTTNG_CONDITION_STATUS_INVALID, "Set null condition on set session name");
- status = lttng_condition_buffer_usage_get_session_name(NULL, &session_name);
+ status = lttng_condition_buffer_usage_get_session_name(nullptr, &session_name);
ok(status == LTTNG_CONDITION_STATUS_INVALID, "Get session name with null condition");
ok(!session_name, "Session name is null");
status = lttng_condition_buffer_usage_get_session_name(buffer_usage_condition,
ok(status == LTTNG_CONDITION_STATUS_UNSET, "Session name is unset");
ok(!session_name, "Session name is null");
- status = lttng_condition_buffer_usage_set_session_name(buffer_usage_condition, NULL);
+ status = lttng_condition_buffer_usage_set_session_name(buffer_usage_condition, nullptr);
ok(status == LTTNG_CONDITION_STATUS_INVALID, "Set null session name");
status = lttng_condition_buffer_usage_get_session_name(buffer_usage_condition,
&session_name);
ok(strcmp("session420", session_name) == 0, "Session is still name is %s", "session420");
diag("Testing channel name set/get");
- status = lttng_condition_buffer_usage_set_channel_name(NULL, "Test");
+ status = lttng_condition_buffer_usage_set_channel_name(nullptr, "Test");
ok(status == LTTNG_CONDITION_STATUS_INVALID, "Set null condition on set channel name");
- status = lttng_condition_buffer_usage_get_channel_name(NULL, &channel_name);
+ status = lttng_condition_buffer_usage_get_channel_name(nullptr, &channel_name);
ok(status == LTTNG_CONDITION_STATUS_INVALID, "Get channel name with null condition");
status = lttng_condition_buffer_usage_get_channel_name(buffer_usage_condition,
&channel_name);
ok(status == LTTNG_CONDITION_STATUS_UNSET, "Channel name is unset");
ok(!channel_name, "Channel name is null");
- status = lttng_condition_buffer_usage_set_channel_name(buffer_usage_condition, NULL);
+ status = lttng_condition_buffer_usage_set_channel_name(buffer_usage_condition, nullptr);
ok(status == LTTNG_CONDITION_STATUS_INVALID, "Set null channel name");
status = lttng_condition_buffer_usage_get_channel_name(buffer_usage_condition,
&channel_name);
ok(strcmp("channel420", channel_name) == 0, "Channel is still name is %s", "channel420");
diag("Testing threshold ratio set/get");
- status = lttng_condition_buffer_usage_set_threshold_ratio(NULL, 0.420);
+ status = lttng_condition_buffer_usage_set_threshold_ratio(nullptr, 0.420);
ok(status == LTTNG_CONDITION_STATUS_INVALID, "Set threshold ratio with null condition");
- status = lttng_condition_buffer_usage_get_threshold_ratio(NULL, &threshold_ratio);
+ status = lttng_condition_buffer_usage_get_threshold_ratio(nullptr, &threshold_ratio);
ok(status == LTTNG_CONDITION_STATUS_INVALID, "Get threshold ratio with null condition");
status = lttng_condition_buffer_usage_get_threshold_ratio(buffer_usage_condition,
&threshold_ratio);
ok(threshold_ratio == 0.420, "Threshold ratio is 0.420");
diag("Testing threshold bytes set/get");
- status = lttng_condition_buffer_usage_set_threshold(NULL, 100000);
+ status = lttng_condition_buffer_usage_set_threshold(nullptr, 100000);
ok(status == LTTNG_CONDITION_STATUS_INVALID, "Set threshold with null condition");
- status = lttng_condition_buffer_usage_get_threshold(NULL, &threshold_bytes);
+ status = lttng_condition_buffer_usage_get_threshold(nullptr, &threshold_bytes);
ok(status == LTTNG_CONDITION_STATUS_INVALID, "Get threshold value with null condition ");
status = lttng_condition_buffer_usage_get_threshold(buffer_usage_condition,
&threshold_bytes);
ok(threshold_bytes == 420, "Threshold is untouched");
diag("Testing domain type set/get");
- status = lttng_condition_buffer_usage_set_domain_type(NULL, LTTNG_DOMAIN_UST);
+ status = lttng_condition_buffer_usage_set_domain_type(nullptr, LTTNG_DOMAIN_UST);
ok(status == LTTNG_CONDITION_STATUS_INVALID, "Set domain type with null condition");
- status = lttng_condition_buffer_usage_get_domain_type(NULL, &domain_type);
+ status = lttng_condition_buffer_usage_get_domain_type(nullptr, &domain_type);
ok(status == LTTNG_CONDITION_STATUS_INVALID, "Get domain type with null condition");
status = lttng_condition_buffer_usage_set_domain_type(buffer_usage_condition,
ok(domain_type == LTTNG_DOMAIN_UST, "Domain type is LTTNG_DOMAIN_UST");
}
-static void test_condition_buffer_usage_low(void)
+static void test_condition_buffer_usage_low()
{
- struct lttng_condition *buffer_usage_low = NULL;
+ struct lttng_condition *buffer_usage_low = nullptr;
diag("Testing lttng_condition_buffer_usage_low_create");
buffer_usage_low = lttng_condition_buffer_usage_low_create();
lttng_condition_destroy(buffer_usage_low);
}
-static void test_condition_buffer_usage_high(void)
+static void test_condition_buffer_usage_high()
{
- struct lttng_condition *buffer_usage_high = NULL;
+ struct lttng_condition *buffer_usage_high = nullptr;
diag("Testing lttng_condition_buffer_usage_high_create");
buffer_usage_high = lttng_condition_buffer_usage_high_create();
lttng_condition_destroy(buffer_usage_high);
}
-static void test_trigger(void)
+static void test_trigger()
{
- struct lttng_action *notify_action = NULL;
- struct lttng_condition *buffer_usage_high = NULL;
- struct lttng_trigger *trigger = NULL;
+ struct lttng_action *notify_action = nullptr;
+ struct lttng_condition *buffer_usage_high = nullptr;
+ struct lttng_trigger *trigger = nullptr;
notify_action = lttng_action_notify_create();
buffer_usage_high = lttng_condition_buffer_usage_high_create();
- trigger = lttng_trigger_create(NULL, NULL);
+ trigger = lttng_trigger_create(nullptr, nullptr);
ok(!trigger, "lttng_trigger_create(NULL, NULL) returns null");
- trigger = lttng_trigger_create(buffer_usage_high, NULL);
+ trigger = lttng_trigger_create(buffer_usage_high, nullptr);
ok(!trigger, "lttng_trigger_create(NON-NULL, NULL) returns null");
- trigger = lttng_trigger_create(NULL, notify_action);
+ trigger = lttng_trigger_create(nullptr, notify_action);
ok(!trigger, "lttng_trigger_create(NULL, NON-NULL) returns null");
trigger = lttng_trigger_create(buffer_usage_high, notify_action);
lttng_trigger_destroy(trigger);
}
-int main(void)
+int main()
{
plan_tests(NUM_TESTS);
test_condition_buffer_usage_low();
int lttng_opt_verbose;
int lttng_opt_mi;
-static void test_fd_push_pop_order(void)
+static void test_fd_push_pop_order()
{
int ret, i;
struct lttng_payload payload;
lttng_payload_reset(&payload);
}
-static void test_fd_push_pop_imbalance(void)
+static void test_fd_push_pop_imbalance()
{
int ret, i;
struct lttng_payload payload;
lttng_payload_reset(&payload);
}
-static void test_fd_pop_fd_root_views(void)
+static void test_fd_pop_fd_root_views()
{
int ret, i;
int fd = fcntl(STDOUT_FILENO, F_DUPFD, 0);
fd_handle_put(handle);
}
-static void test_fd_pop_fd_descendant_views(void)
+static void test_fd_pop_fd_descendant_views()
{
int ret;
const int fd1 = 42, fd2 = 1837;
struct fd_handle *handle1 = fd_handle_create(fd1);
struct fd_handle *handle2 = fd_handle_create(fd2);
- struct fd_handle *view_handle1 = NULL, *view_handle2 = NULL;
+ struct fd_handle *view_handle1 = nullptr, *view_handle2 = nullptr;
struct lttng_payload payload;
const char *const test_description =
"Different file descriptors returned when popping from descendant views";
fd_handle_put(view_handle2);
}
-int main(void)
+int main()
{
plan_tests(TEST_COUNT);
#define NUM_TESTS 42
-static void test_rate_policy_every_n(void)
+static void test_rate_policy_every_n()
{
enum lttng_rate_policy_status status;
- struct lttng_rate_policy *policy_a = NULL; /* Interval of 100. */
- struct lttng_rate_policy *policy_b = NULL; /* Interval of 100 */
- struct lttng_rate_policy *policy_c = NULL; /* Interval of 1 */
- struct lttng_rate_policy *policy_from_buffer = NULL;
+ struct lttng_rate_policy *policy_a = nullptr; /* Interval of 100. */
+ struct lttng_rate_policy *policy_b = nullptr; /* Interval of 100 */
+ struct lttng_rate_policy *policy_c = nullptr; /* Interval of 1 */
+ struct lttng_rate_policy *policy_from_buffer = nullptr;
uint64_t interval_a_b = 100;
uint64_t interval_c = 1;
uint64_t interval_query = 0;
policy_a = lttng_rate_policy_every_n_create(interval_a_b);
policy_b = lttng_rate_policy_every_n_create(interval_a_b);
policy_c = lttng_rate_policy_every_n_create(interval_c);
- ok(policy_a != NULL, "Rate policy every n A created: interval: %" PRIu64, interval_a_b);
- ok(policy_b != NULL, "Rate policy every n B created: interval: %" PRIu64, interval_a_b);
- ok(policy_c != NULL, "Rate policy every n C created: interval: %" PRIu64, interval_c);
+ ok(policy_a != nullptr, "Rate policy every n A created: interval: %" PRIu64, interval_a_b);
+ ok(policy_b != nullptr, "Rate policy every n B created: interval: %" PRIu64, interval_a_b);
+ ok(policy_c != nullptr, "Rate policy every n C created: interval: %" PRIu64, interval_c);
ok(LTTNG_RATE_POLICY_TYPE_EVERY_N == lttng_rate_policy_get_type(policy_a),
"Type is LTTNG_RATE_POLICY_TYPE_EVERY_N");
/* Getter tests */
- status = lttng_rate_policy_every_n_get_interval(NULL, NULL);
+ status = lttng_rate_policy_every_n_get_interval(nullptr, nullptr);
ok(status == LTTNG_RATE_POLICY_STATUS_INVALID, "Get interval returns INVALID");
- status = lttng_rate_policy_every_n_get_interval(NULL, &interval_query);
+ status = lttng_rate_policy_every_n_get_interval(nullptr, &interval_query);
ok(status == LTTNG_RATE_POLICY_STATUS_INVALID, "Get interval returns INVALID");
- status = lttng_rate_policy_every_n_get_interval(policy_a, NULL);
+ status = lttng_rate_policy_every_n_get_interval(policy_a, nullptr);
ok(status == LTTNG_RATE_POLICY_STATUS_INVALID, "Get interval returns INVALID");
status = lttng_rate_policy_every_n_get_interval(policy_a, &interval_query);
* lttng_condition_is_equal back in 2017 do we want to fix this and
* return true if both are NULL?
*/
- ok(false == lttng_rate_policy_is_equal(NULL, NULL), "is equal (NULL,NULL)");
- ok(false == lttng_rate_policy_is_equal(policy_a, NULL), "is equal (object, NULL)");
- ok(false == lttng_rate_policy_is_equal(NULL, policy_a), " is equal (NULL, object)");
+ ok(false == lttng_rate_policy_is_equal(nullptr, nullptr), "is equal (NULL,NULL)");
+ ok(false == lttng_rate_policy_is_equal(policy_a, nullptr), "is equal (object, NULL)");
+ ok(false == lttng_rate_policy_is_equal(nullptr, policy_a), " is equal (NULL, object)");
ok(true == lttng_rate_policy_is_equal(policy_a, policy_a), "is equal (object A, object A)");
ok(true == lttng_rate_policy_is_equal(policy_a, policy_b), "is equal (object A, object B");
struct lttng_payload_view view = lttng_payload_view_from_payload(&payload, 0, -1);
ok(lttng_rate_policy_create_from_payload(&view, &policy_from_buffer) > 0 &&
- policy_from_buffer != NULL,
+ policy_from_buffer != nullptr,
"Deserializing");
}
lttng_payload_reset(&payload);
}
-static void test_rate_policy_once_after_n(void)
+static void test_rate_policy_once_after_n()
{
enum lttng_rate_policy_status status;
- struct lttng_rate_policy *policy_a = NULL; /* Threshold of 100. */
- struct lttng_rate_policy *policy_b = NULL; /* threshold of 100 */
- struct lttng_rate_policy *policy_c = NULL; /* threshold of 1 */
- struct lttng_rate_policy *policy_from_buffer = NULL;
+ struct lttng_rate_policy *policy_a = nullptr; /* Threshold of 100. */
+ struct lttng_rate_policy *policy_b = nullptr; /* threshold of 100 */
+ struct lttng_rate_policy *policy_c = nullptr; /* threshold of 1 */
+ struct lttng_rate_policy *policy_from_buffer = nullptr;
uint64_t threshold_a_b = 100;
uint64_t threshold_c = 1;
uint64_t threshold_query = 0;
policy_a = lttng_rate_policy_once_after_n_create(threshold_a_b);
policy_b = lttng_rate_policy_once_after_n_create(threshold_a_b);
policy_c = lttng_rate_policy_once_after_n_create(threshold_c);
- ok(policy_a != NULL, "Rate policy every n A created: threshold: %" PRIu64, threshold_a_b);
- ok(policy_b != NULL, "Rate policy every n B created: threshold: %" PRIu64, threshold_a_b);
- ok(policy_c != NULL, "Rate policy every n C created: threshold: %" PRIu64, threshold_c);
+ ok(policy_a != nullptr,
+ "Rate policy every n A created: threshold: %" PRIu64,
+ threshold_a_b);
+ ok(policy_b != nullptr,
+ "Rate policy every n B created: threshold: %" PRIu64,
+ threshold_a_b);
+ ok(policy_c != nullptr, "Rate policy every n C created: threshold: %" PRIu64, threshold_c);
ok(LTTNG_RATE_POLICY_TYPE_ONCE_AFTER_N == lttng_rate_policy_get_type(policy_a),
"Type is LTTNG_RATE_POLICY_TYPE_once_after_n");
/* Getter tests */
- status = lttng_rate_policy_once_after_n_get_threshold(NULL, NULL);
+ status = lttng_rate_policy_once_after_n_get_threshold(nullptr, nullptr);
ok(status == LTTNG_RATE_POLICY_STATUS_INVALID, "Get threshold returns INVALID");
- status = lttng_rate_policy_once_after_n_get_threshold(NULL, &threshold_query);
+ status = lttng_rate_policy_once_after_n_get_threshold(nullptr, &threshold_query);
ok(status == LTTNG_RATE_POLICY_STATUS_INVALID, "Get threshold returns INVALID");
- status = lttng_rate_policy_once_after_n_get_threshold(policy_a, NULL);
+ status = lttng_rate_policy_once_after_n_get_threshold(policy_a, nullptr);
ok(status == LTTNG_RATE_POLICY_STATUS_INVALID, "Get threshold returns INVALID");
status = lttng_rate_policy_once_after_n_get_threshold(policy_a, &threshold_query);
" Getting threshold C");
/* is_equal tests */
- ok(false == lttng_rate_policy_is_equal(NULL, NULL), "is equal (NULL,NULL)");
- ok(false == lttng_rate_policy_is_equal(policy_a, NULL), "is equal (object, NULL)");
- ok(false == lttng_rate_policy_is_equal(NULL, policy_a), " is equal (NULL, object)");
+ ok(false == lttng_rate_policy_is_equal(nullptr, nullptr), "is equal (NULL,NULL)");
+ ok(false == lttng_rate_policy_is_equal(policy_a, nullptr), "is equal (object, NULL)");
+ ok(false == lttng_rate_policy_is_equal(nullptr, policy_a), " is equal (NULL, object)");
ok(true == lttng_rate_policy_is_equal(policy_a, policy_a), "is equal (object A, object A)");
ok(true == lttng_rate_policy_is_equal(policy_a, policy_b), "is equal (object A, object B");
struct lttng_payload_view view = lttng_payload_view_from_payload(&payload, 0, -1);
ok(lttng_rate_policy_create_from_payload(&view, &policy_from_buffer) > 0 &&
- policy_from_buffer != NULL,
+ policy_from_buffer != nullptr,
"Deserializing");
}
lttng_payload_reset(&payload);
}
-int main(void)
+int main()
{
plan_tests(NUM_TESTS);
test_rate_policy_every_n();
static char *craft_expected(struct test *test, time_t relay_session_creation_time)
{
int ret;
- char *result = NULL;
+ char *result = nullptr;
char relay_session_creation_datetime[DATETIME_STR_LEN];
ret = time_to_datetime_str(relay_session_creation_time,
relay_session_creation_datetime,
sizeof(relay_session_creation_datetime));
if (ret < 0) {
- result = NULL;
+ result = nullptr;
goto end;
}
test->extra_path[0] != '\0' ? "/" : "",
test->leftover);
if (ret < 0) {
- result = NULL;
+ result = nullptr;
goto end;
}
end:
return result;
}
-int main(void)
+int main()
{
int i;
int num_test = sizeof(tests) / sizeof(struct test);
- const time_t test_time = time(NULL);
+ const time_t test_time = time(nullptr);
plan_tests(NUM_TESTS_PER_TEST * num_test);
diag("Backward compatibility utils for lttng-relayd --group-by-session");
}
for (i = 0; i < num_test; i++) {
- char *expected = NULL;
- char *result = NULL;
+ char *expected = nullptr;
+ char *result = nullptr;
expected = craft_expected(&tests[i], test_time);
if (!expected) {
* Return random string of 10 characters.
* Not thread-safe.
*/
-static char *get_random_string(void)
+static char *get_random_string()
{
int i;
return -1;
}
-static int session_list_count(void)
+static int session_list_count()
{
int count = 0;
struct ltt_session *iter;
/*
* Empty session list manually.
*/
-static void empty_session_list(void)
+static void empty_session_list()
{
struct ltt_session *iter, *tmp;
{
int ret;
enum lttng_error_code ret_code;
- struct ltt_session *session = NULL;
+ struct ltt_session *session = nullptr;
session_lock_list();
ret_code = session_create(name, geteuid(), getegid(), &session);
* This test is supposed to fail at the second create call. If so, return 0 for
* test success, else -1.
*/
-static int two_session_same_name(void)
+static int two_session_same_name()
{
int ret;
struct ltt_session *sess;
return ret;
}
-static void test_session_list(void)
+static void test_session_list()
{
session_list = session_get_list();
- ok(session_list != NULL, "Session list: not NULL");
+ ok(session_list != nullptr, "Session list: not NULL");
}
-static void test_create_one_session(void)
+static void test_create_one_session()
{
ok(create_one_session(SESSION1) == 0, "Create session: %s", SESSION1);
}
-static void test_validate_session(void)
+static void test_validate_session()
{
struct ltt_session *tmp;
session_lock_list();
tmp = session_find_by_name(SESSION1);
- ok(tmp != NULL, "Validating session: session found");
+ ok(tmp != nullptr, "Validating session: session found");
if (tmp) {
- ok(tmp->kernel_session == NULL && strlen(tmp->name),
+ ok(tmp->kernel_session == nullptr && strlen(tmp->name),
"Validating session: basic sanity check");
} else {
skip(1, "Skipping session validation check as session was not found");
session_unlock_list();
}
-static void test_destroy_session(void)
+static void test_destroy_session()
{
struct ltt_session *tmp;
session_lock_list();
tmp = session_find_by_name(SESSION1);
- ok(tmp != NULL, "Destroying session: session found");
+ ok(tmp != nullptr, "Destroying session: session found");
if (tmp) {
ok(destroy_one_session(tmp) == 0, "Destroying session: %s destroyed", SESSION1);
session_unlock_list();
}
-static void test_duplicate_session(void)
+static void test_duplicate_session()
{
ok(two_session_same_name() == 0, "Duplicate session creation");
}
-static void test_session_name_generation(void)
+static void test_session_name_generation()
{
- struct ltt_session *session = NULL;
+ struct ltt_session *session = nullptr;
enum lttng_error_code ret_code;
const char *expected_session_name_prefix = DEFAULT_SESSION_NAME;
session_lock_list();
- ret_code = session_create(NULL, geteuid(), getegid(), &session);
+ ret_code = session_create(nullptr, geteuid(), getegid(), &session);
ok(ret_code == LTTNG_OK, "Create session with a NULL name (auto-generate a name)");
if (!session) {
skip(1, "Skipping session name generation tests as session_create() failed.");
session_unlock_list();
}
-static void test_large_session_number(void)
+static void test_large_session_number()
{
int ret, i, failed = 0;
struct ltt_session *iter, *tmp;
MAX_SESSIONS);
}
-int main(void)
+int main()
{
plan_tests(NUM_TESTS);
escape_delim);
}
-static void test_split(void)
+static void test_split()
{
test_one_split("a/b/c/d/e", '/', false, "a", "b", "c", "d", "e", NULL);
test_one_split("a/b//d/e", '/', false, "a", "b", "", "d", "e", NULL);
expected);
}
-static void test_is_star_at_the_end_only_glob_pattern(void)
+static void test_is_star_at_the_end_only_glob_pattern()
{
test_one_is_star_at_the_end_only_glob_pattern("allo*", true);
test_one_is_star_at_the_end_only_glob_pattern("allo\\\\*", true);
expected);
}
-static void test_is_star_glob_pattern(void)
+static void test_is_star_glob_pattern()
{
test_one_is_star_glob_pattern("allo*", true);
test_one_is_star_glob_pattern("*allo", true);
free(rw_pattern);
}
-static void test_normalize_star_glob_pattern(void)
+static void test_normalize_star_glob_pattern()
{
test_one_normalize_star_glob_pattern("salut", "salut");
test_one_normalize_star_glob_pattern("sal*ut", "sal*ut");
test_one_normalize_star_glob_pattern("**\\***", "*\\**");
}
-int main(void)
+int main()
{
plan_tests(NUM_TESTS);
diag("String utils unit tests");
lttng_payload_reset(&received_payload);
}
-static void test_creds_passing(void)
+static void test_creds_passing()
{
pid_t fork_ret = -1;
int ret, parent_socket = -1, child_connection_socket = -1;
}
}
-int main(void)
+int main()
{
plan_tests(TEST_COUNT);
/* Number of TAP tests in this file */
#define NUM_TESTS 11
-static void test_uri_parsing(void)
+static void test_uri_parsing()
{
ssize_t size;
const char *s_uri1;
- struct lttng_uri *uri = NULL;
+ struct lttng_uri *uri = nullptr;
s_uri1 = "net://localhost";
if (uri) {
uri_free(uri);
- uri = NULL;
+ uri = nullptr;
}
s_uri1 = "net://localhost:8989:4242/my/test/path";
if (uri) {
uri_free(uri);
- uri = NULL;
+ uri = nullptr;
}
s_uri1 = "net://localhost:8989:4242";
if (uri) {
uri_free(uri);
- uri = NULL;
+ uri = nullptr;
}
s_uri1 = "net6://[::1]:8989";
if (uri) {
uri_free(uri);
- uri = NULL;
+ uri = nullptr;
}
s_uri1 = "tcp://42.42.42.42/my/test/path";
if (uri) {
uri_free(uri);
- uri = NULL;
+ uri = nullptr;
}
s_uri1 = "tcp6://[fe80::f66d:4ff:fe53:d220]/my/test/path";
if (uri) {
uri_free(uri);
- uri = NULL;
+ uri = nullptr;
}
s_uri1 = "file:///my/test/path";
if (uri) {
uri_free(uri);
- uri = NULL;
+ uri = nullptr;
}
/* FIXME: Noisy on stdout */
LTTNG_ASSERT(!uri);
}
-static void test_uri_cmp(void)
+static void test_uri_cmp()
{
struct lttng_uri *uri1, *uri2;
const char *s_uri1 = "net://localhost";
uri_free(uri2);
}
-int main(void)
+int main()
{
plan_tests(NUM_TESTS);
* Return random string of 10 characters.
* Not thread-safe.
*/
-static char *get_random_string(void)
+static char *get_random_string()
{
int i;
return random_string;
}
-static void test_create_one_ust_session(void)
+static void test_create_one_ust_session()
{
struct ltt_ust_session *usess = trace_ust_create_session(42);
- ok(usess != NULL, "Create UST session");
+ ok(usess != nullptr, "Create UST session");
if (!usess) {
skip(1, "UST session is null");
return;
}
- ok(usess->id == 42 && usess->active == 0 && usess->domain_global.channels != NULL &&
+ ok(usess->id == 42 && usess->active == 0 && usess->domain_global.channels != nullptr &&
usess->uid == 0 && usess->gid == 0,
"Validate UST session");
trace_ust_free_session(usess);
}
-static void test_create_ust_channel(void)
+static void test_create_ust_channel()
{
struct ltt_ust_channel *uchan;
struct lttng_channel attr;
ok(lttng_strncpy(attr.name, "channel0", sizeof(attr.name)) == 0,
"Validate channel name length");
uchan = trace_ust_create_channel(&attr, LTTNG_DOMAIN_UST);
- ok(uchan != NULL, "Create UST channel");
+ ok(uchan != nullptr, "Create UST channel");
if (!uchan) {
skip(1, "UST channel is null");
}
ok(uchan->enabled == 0 && strncmp(uchan->name, "channel0", 8) == 0 &&
- uchan->name[LTTNG_UST_ABI_SYM_NAME_LEN - 1] == '\0' && uchan->ctx != NULL &&
- uchan->events != NULL && uchan->attr.overwrite == attr.attr.overwrite,
+ uchan->name[LTTNG_UST_ABI_SYM_NAME_LEN - 1] == '\0' && uchan->ctx != nullptr &&
+ uchan->events != nullptr && uchan->attr.overwrite == attr.attr.overwrite,
"Validate UST channel");
trace_ust_destroy_channel(uchan);
}
-static void test_create_ust_event(void)
+static void test_create_ust_event()
{
struct ltt_ust_event *event;
struct lttng_event ev;
ev.type = LTTNG_EVENT_TRACEPOINT;
ev.loglevel_type = LTTNG_EVENT_LOGLEVEL_ALL;
- ret = trace_ust_create_event(&ev, NULL, NULL, NULL, false, &event);
+ ret = trace_ust_create_event(&ev, nullptr, nullptr, nullptr, false, &event);
ok(ret == LTTNG_OK, "Create UST event");
trace_ust_destroy_event(event);
}
-static void test_create_ust_event_exclusion(void)
+static void test_create_ust_event_exclusion()
{
int copy_ret;
enum lttng_error_code ret;
struct lttng_event ev;
char *name;
char *random_name;
- struct lttng_event_exclusion *exclusion = NULL;
- struct lttng_event_exclusion *exclusion_copy = NULL;
+ struct lttng_event_exclusion *exclusion = nullptr;
+ struct lttng_event_exclusion *exclusion_copy = nullptr;
const int exclusion_count = 2;
memset(&ev, 0, sizeof(ev));
/* set up an exclusion set */
exclusion = zmalloc<lttng_event_exclusion>(sizeof(*exclusion) +
LTTNG_SYMBOL_NAME_LEN * exclusion_count);
- ok(exclusion != NULL, "Create UST exclusion");
+ ok(exclusion != nullptr, "Create UST exclusion");
if (!exclusion) {
skip(4, "zmalloc failed");
goto end;
random_name,
LTTNG_SYMBOL_NAME_LEN - 1);
- ret = trace_ust_create_event(&ev, NULL, NULL, exclusion, false, &event);
- exclusion = NULL;
+ ret = trace_ust_create_event(&ev, nullptr, nullptr, exclusion, false, &event);
+ exclusion = nullptr;
ok(ret != LTTNG_OK, "Create UST event with identical exclusion names fails");
exclusion = zmalloc<lttng_event_exclusion>(sizeof(*exclusion) +
LTTNG_SYMBOL_NAME_LEN * exclusion_count);
- ok(exclusion != NULL, "Create UST exclusion");
+ ok(exclusion != nullptr, "Create UST exclusion");
if (!exclusion) {
skip(2, "zmalloc failed");
goto end;
sizeof(LTTNG_EVENT_EXCLUSION_NAME_AT(exclusion_copy, 1)));
LTTNG_ASSERT(copy_ret == 0);
- ret = trace_ust_create_event(&ev, NULL, NULL, exclusion, false, &event);
- exclusion = NULL;
+ ret = trace_ust_create_event(&ev, nullptr, nullptr, exclusion, false, &event);
+ exclusion = nullptr;
ok(ret == LTTNG_OK, "Create UST event with different exclusion names");
if (!event) {
}
ok(event->enabled == 0 && event->attr.instrumentation == LTTNG_UST_ABI_TRACEPOINT &&
- strcmp(event->attr.name, ev.name) == 0 && event->exclusion != NULL &&
+ strcmp(event->attr.name, ev.name) == 0 && event->exclusion != nullptr &&
event->exclusion->count == exclusion_count &&
!memcmp(event->exclusion->names,
exclusion_copy->names,
return;
}
-static void test_create_ust_context(void)
+static void test_create_ust_context()
{
struct lttng_event_context ectx;
struct ltt_ust_context *uctx;
ectx.ctx = LTTNG_EVENT_CONTEXT_VTID;
uctx = trace_ust_create_context(&ectx);
- ok(uctx != NULL, "Create UST context");
+ ok(uctx != nullptr, "Create UST context");
if (uctx) {
ok((int) uctx->ctx.ctx == LTTNG_UST_ABI_CONTEXT_VTID, "Validate UST context");
free(uctx);
}
-int main(void)
+int main()
{
plan_tests(NUM_TESTS);
#define CLOE_VALUE FD_CLOEXEC
#endif
-static void test_epoll_compat(void)
+static void test_epoll_compat()
{
/*
* Type conversion present to disable warning of anonymous enum from
}
#endif
-static void test_alloc(void)
+static void test_alloc()
{
struct lttng_poll_event poll_events;
lttng_poll_init(&poll_events);
/* Null pointer */
- ok(lttng_poll_create(NULL, 1, 0) != 0, "Create over NULL pointer fails");
+ ok(lttng_poll_create(nullptr, 1, 0) != 0, "Create over NULL pointer fails");
/* Size 0 */
ok(lttng_poll_create(&poll_events, 0, 0) != 0, "Create with size 0 fails");
/* without CLOEXEC */
}
/* Tests stuff related to what would be handled with epoll_ctl. */
-static void test_add_del(void)
+static void test_add_del()
{
struct lttng_poll_event poll_events;
lttng_poll_init(&poll_events);
- ok(lttng_poll_add(NULL, 1, LPOLLIN) != 0, "Adding to NULL set fails");
+ ok(lttng_poll_add(nullptr, 1, LPOLLIN) != 0, "Adding to NULL set fails");
ok(lttng_poll_add(&poll_events, 1, LPOLLIN) != 0,
"Adding to uninitialized structure fails");
ok(lttng_poll_add(&poll_events, -1, LPOLLIN) != 0, "Adding invalid FD fails");
ok(lttng_poll_create(&poll_events, 1, 0) == 0, "Create a poll set succeeds");
ok(LTTNG_POLL_GETNB(&poll_events) == 0, "Set created empty");
- ok(lttng_poll_add(NULL, 1, LPOLLIN) != 0, "Adding to NULL set fails");
+ ok(lttng_poll_add(nullptr, 1, LPOLLIN) != 0, "Adding to NULL set fails");
ok(LTTNG_POLL_GETNB(&poll_events) == 0, "Set still empty");
ok(lttng_poll_add(&poll_events, -1, LPOLLIN) != 0, "Adding invalid FD fails");
ok(LTTNG_POLL_GETNB(&poll_events) == 0, "Set still empty");
ok(lttng_poll_add(&poll_events, 1, LPOLLIN) == 0, "Adding valid FD succeeds");
ok(LTTNG_POLL_GETNB(&poll_events) == 1, "Nb of elements incremented");
- ok(lttng_poll_del(NULL, 1) != 0, "Removing from NULL set fails");
+ ok(lttng_poll_del(nullptr, 1) != 0, "Removing from NULL set fails");
ok(LTTNG_POLL_GETNB(&poll_events) == 1, "Number of FD in set unchanged");
ok(lttng_poll_del(&poll_events, -1) != 0, "Removing from negative FD fails");
lttng_poll_clean(&poll_events);
}
-static void test_mod_wait(void)
+static void test_mod_wait()
{
struct lttng_poll_event poll_events;
struct lttng_poll_event cpoll_events;
if (cpid == 0) {
childok(lttng_poll_create(&cpoll_events, 1, 0) == 0,
"Create valid poll set succeeds");
- childok(lttng_poll_mod(NULL, infd[0], LPOLLIN) == -1,
+ childok(lttng_poll_mod(nullptr, infd[0], LPOLLIN) == -1,
"lttng_poll_mod with invalid input returns an error");
childok(lttng_poll_mod(&cpoll_events, infd[0], LPOLLIN) == -1,
"lttng_poll_mod with invalid input returns an error");
ok(close(hupfd[1]) == 0, "Close valid FD succeeds");
ok(close(infd[0]) == 0, "Close valid FD succeeds");
- ok(lttng_poll_wait(NULL, -1) == -1,
+ ok(lttng_poll_wait(nullptr, -1) == -1,
"lttng_poll_wait call with invalid input returns error");
ok(lttng_poll_create(&poll_events, 1, 0) == 0, "Create valid poll set succeeds");
const unsigned int active_fds_count = __builtin_popcount(active_fds_mask);
struct lttng_poll_event poll_events;
struct lttng_dynamic_pointer_array pipes;
- struct lttng_pipe *pipe = NULL;
+ struct lttng_pipe *pipe = nullptr;
lttng_poll_init(&poll_events);
lttng_dynamic_pointer_array_init(&pipes, destroy_pipe);
}
/* Ownership transferred to the pointer array. */
- pipe = NULL;
+ pipe = nullptr;
}
/* Write one byte for all active fds that should be active. */
fail("Test all combinations of active file descriptors for %u file descriptors", fd_count);
}
-static void test_func_def(void)
+static void test_func_def()
{
#ifdef LTTNG_POLL_GETFD
#define PASS_GETFD 1
ok(PASS_GET_PREV_FD, "GET_PREV_FD is defined");
}
-int main(void)
+int main()
{
plan_tests(NUM_TESTS);
#ifdef HAVE_EPOLL
#define TEST_NAME_PROPER_LEN 16
-int main(void)
+int main()
{
int ret;
char name1[TEST_NAME_PROPER_LEN];
/* Invalid test cases */
char *invalid_tests_inputs[] = {
- NULL,
+ nullptr,
};
const int num_invalid_tests = sizeof(invalid_tests_inputs) / sizeof(invalid_tests_inputs[0]);
} /* namespace */
#define PRINT_ERR(fmt, args...) fprintf(stderr, "test_utils_expand_path: error: " fmt "\n", ##args)
-static int prepare_valid_results(void)
+static int prepare_valid_results()
{
int i;
- char *relative, *cur_path = NULL, *prev_path = NULL, *pprev_path = NULL, *empty = NULL;
+ char *relative, *cur_path = nullptr, *prev_path = nullptr, *pprev_path = nullptr,
+ *empty = nullptr;
int ret = 0;
/* Prepare the relative paths */
- cur_path = realpath(".", NULL);
- prev_path = realpath("..", NULL);
- pprev_path = realpath("../..", NULL);
+ cur_path = realpath(".", nullptr);
+ prev_path = realpath("..", nullptr);
+ pprev_path = realpath("../..", nullptr);
empty = strdup("");
if (!cur_path || !prev_path || !pprev_path || !empty) {
PRINT_ERR("strdup out of memory");
}
for (i = 0; i < num_valid_tests; i++) {
valid_tests_expected_results[i] = calloc<char>(PATH_MAX);
- if (valid_tests_expected_results[i] == NULL) {
+ if (valid_tests_expected_results[i] == nullptr) {
PRINT_ERR("malloc expected results");
ret = -1;
goto end;
return ret;
}
-static int free_valid_results(void)
+static int free_valid_results()
{
int i;
return 0;
}
-static int prepare_symlink_tree(void)
+static int prepare_symlink_tree()
{
int i;
char tmppath[PATH_MAX] = {};
/* Create the temporary directory */
- if (mkdtemp(tree_origin) == NULL) {
+ if (mkdtemp(tree_origin) == nullptr) {
PRINT_ERR("failed to mkdtemp");
goto error;
}
return 1;
}
-static int free_symlink_tree(void)
+static int free_symlink_tree()
{
int i;
char tmppath[PATH_MAX];
return 1;
}
-static void test_utils_expand_path(void)
+static void test_utils_expand_path()
{
char *result;
char name[100], tmppath[PATH_MAX], real_tree_origin[PATH_MAX];
sprintf(name, "valid test case: %s", valid_tests_inputs[i].input);
result = utils_expand_path(valid_tests_inputs[i].input);
- ok(result != NULL && strcmp(result, valid_tests_expected_results[i]) == 0,
+ ok(result != nullptr && strcmp(result, valid_tests_expected_results[i]) == 0,
"%s",
name);
continue;
}
result = utils_expand_path(tmppath);
- ok(result != NULL &&
+ ok(result != nullptr &&
strcmp(result + treelen, symlink_tests_inputs[i].expected_result) == 0,
"%s",
name);
sprintf(name, "invalid test case: %s", test_input ? test_input : "NULL");
result = utils_expand_path(test_input);
- if (result != NULL) {
+ if (result != nullptr) {
free(result);
}
- ok(result == NULL, "%s", name);
+ ok(result == nullptr, "%s", name);
}
}
-int main(void)
+int main()
{
if (prepare_symlink_tree() != 0) {
goto error_mkdir;
const int num_invalid_tests = sizeof(invalid_tests_inputs) / sizeof(invalid_tests_inputs[0]);
} /* namespace */
-static void test_utils_parse_size_suffix(void)
+static void test_utils_parse_size_suffix()
{
uint64_t result;
int ret;
}
}
-int main(void)
+int main()
{
plan_tests(num_valid_tests + num_invalid_tests);
const int num_invalid_tests = sizeof(invalid_tests_inputs) / sizeof(invalid_tests_inputs[0]);
} /* namespace */
-static void test_utils_parse_time_suffix(void)
+static void test_utils_parse_time_suffix()
{
uint64_t result;
int ret;
}
}
-int main(void)
+int main()
{
plan_tests(num_valid_tests + num_invalid_tests);
int lttng_opt_verbose = 0;
int lttng_opt_mi;
-static void run_test_lttng_uuid_from_str(void)
+static void run_test_lttng_uuid_from_str()
{
int ret;
lttng_uuid uuid1;
invalid_str_6);
}
-static void run_test_lttng_uuid_to_str(void)
+static void run_test_lttng_uuid_to_str()
{
char uuid_str[LTTNG_UUID_STR_LEN];
valid_str_3);
}
-static void run_test_lttng_uuid_is_equal(void)
+static void run_test_lttng_uuid_is_equal()
{
int ret;
lttng_uuid uuid1, uuid2;
ok(ret == false, "lttng_uuid_is_equal - Compare different UUID, expect failure");
}
-static void run_test_lttng_uuid_copy(void)
+static void run_test_lttng_uuid_copy()
{
bool ret;
lttng_uuid uuid1;
ok(ret == true, "lttng_uuid_copy - Compare copied UUID with source, expect success");
}
-static void run_test_lttng_uuid_generate(void)
+static void run_test_lttng_uuid_generate()
{
int ret;
lttng_uuid uuid1, uuid2;
ok(ret == LTTNG_UUID_VER, "lttng_uuid_generate - Generated UUID version check");
}
-static void run_test(void)
+static void run_test()
{
plan_tests(NR_TESTS);
run_test_lttng_uuid_generate();
}
-int main(void)
+int main()
{
/* Run tap-formated tests */
run_test();
#endif
static int debug = 0;
-static char *ns_opt = NULL;
-static char *before_unshare_wait_file_path = NULL;
-static char *after_unshare_wait_file_path = NULL;
-static char *after_unshare_signal_file_path = NULL;
+static char *ns_opt = nullptr;
+static char *before_unshare_wait_file_path = nullptr;
+static char *after_unshare_wait_file_path = nullptr;
+static char *after_unshare_signal_file_path = nullptr;
static struct poptOption opts[] = {
/* longName, shortName, argInfo, argPtr, value, descrip, argDesc */
- { "debug", 'd', POPT_ARG_NONE, &debug, 0, "Enable debug output", NULL },
- { "ns", 'n', POPT_ARG_STRING, &ns_opt, 0, "Namespace short identifier", NULL },
+ { "debug", 'd', POPT_ARG_NONE, &debug, 0, "Enable debug output", nullptr },
+ { "ns", 'n', POPT_ARG_STRING, &ns_opt, 0, "Namespace short identifier", nullptr },
{ "before",
'b',
POPT_ARG_STRING,
&before_unshare_wait_file_path,
0,
"Wait for file before unshare",
- NULL },
+ nullptr },
{ "after",
'a',
POPT_ARG_STRING,
&after_unshare_wait_file_path,
0,
"Wait for file after unshare",
- NULL },
+ nullptr },
{ "signal",
's',
POPT_ARG_STRING,
&after_unshare_signal_file_path,
0,
"Create signal file after unshare",
- NULL },
- POPT_AUTOHELP{ NULL, 0, 0, NULL, 0, NULL, NULL }
+ nullptr },
+ POPT_AUTOHELP{ nullptr, 0, 0, nullptr, 0, nullptr, nullptr }
};
static ATTR_FORMAT_PRINTF(1, 2) void debug_printf(const char *format, ...)
int ret = EXIT_SUCCESS;
poptContext pc;
- pc = poptGetContext(NULL, argc, argv, opts, 0);
+ pc = poptGetContext(nullptr, argc, argv, opts, 0);
poptReadDefaultConfig(pc, 0);
if (argc < 2) {
goto end;
}
- if (ns_opt == NULL) {
+ if (ns_opt == nullptr) {
poptPrintUsage(pc, stderr, 0);
ret = EXIT_FAILURE;
goto end;
static int nr_iter = 100;
static int debug = 0;
-static char *ns_opt = NULL;
-static char *after_unshare_file_path = NULL;
-static char *before_second_event_file_path = NULL;
+static char *ns_opt = nullptr;
+static char *after_unshare_file_path = nullptr;
+static char *before_second_event_file_path = nullptr;
static struct poptOption opts[] = {
/* longName, shortName, argInfo, argPtr, value, descrip, argDesc */
- { "debug", 'd', POPT_ARG_NONE, &debug, 0, "Enable debug output", NULL },
- { "ns", 'n', POPT_ARG_STRING, &ns_opt, 0, "Namespace short identifier", NULL },
- { "iter", 'i', POPT_ARG_INT, &nr_iter, 0, "Number of tracepoint iterations", NULL },
+ { "debug", 'd', POPT_ARG_NONE, &debug, 0, "Enable debug output", nullptr },
+ { "ns", 'n', POPT_ARG_STRING, &ns_opt, 0, "Namespace short identifier", nullptr },
+ { "iter", 'i', POPT_ARG_INT, &nr_iter, 0, "Number of tracepoint iterations", nullptr },
{ "after",
'a',
POPT_ARG_STRING,
&after_unshare_file_path,
0,
"after_unshare_file_path,",
- NULL },
+ nullptr },
{ "before",
'b',
POPT_ARG_STRING,
&before_second_event_file_path,
0,
"before_second_event_file_path,",
- NULL },
- POPT_AUTOHELP{ NULL, 0, 0, NULL, 0 }
+ nullptr },
+ POPT_AUTOHELP{ nullptr, 0, 0, nullptr, 0 }
};
static ATTR_FORMAT_PRINTF(1, 2) void debug_printf(const char *format, ...)
int ret = EXIT_SUCCESS;
poptContext pc;
- pc = poptGetContext(NULL, argc, argv, opts, 0);
+ pc = poptGetContext(nullptr, argc, argv, opts, 0);
poptReadDefaultConfig(pc, 0);
if (argc < 2) {
goto end;
}
- if (ns_opt == NULL) {
+ if (ns_opt == nullptr) {
poptPrintUsage(pc, stderr, 0);
ret = EXIT_FAILURE;
goto end;
static struct option long_options[] = {
/* These options set a flag. */
- { "iter", required_argument, 0, 'i' },
- { "wait", required_argument, 0, 'w' },
- { "sync-after-first-event", required_argument, 0, 'a' },
- { "sync-before-last-event", required_argument, 0, 'b' },
- { "sync-before-last-event-touch", required_argument, 0, 'c' },
- { "sync-before-exit", required_argument, 0, 'd' },
- { "sync-before-exit-touch", required_argument, 0, 'e' },
- { "emit-end-event", no_argument, 0, 'f' },
- { 0, 0, 0, 0 }
+ { "iter", required_argument, nullptr, 'i' },
+ { "wait", required_argument, nullptr, 'w' },
+ { "sync-after-first-event", required_argument, nullptr, 'a' },
+ { "sync-before-last-event", required_argument, nullptr, 'b' },
+ { "sync-before-last-event-touch", required_argument, nullptr, 'c' },
+ { "sync-before-exit", required_argument, nullptr, 'd' },
+ { "sync-before-exit-touch", required_argument, nullptr, 'e' },
+ { "emit-end-event", no_argument, nullptr, 'f' },
+ { nullptr, 0, nullptr, 0 }
};
int main(int argc, char **argv)
uint32_t net_values[] = { 1, 2, 3 };
int nr_iter = 100, ret = 0, first_event_file_created = 0;
useconds_t nr_usec = 0;
- char *after_first_event_file_path = NULL;
- char *before_last_event_file_path = NULL;
+ char *after_first_event_file_path = nullptr;
+ char *before_last_event_file_path = nullptr;
/*
* Touch a file to indicate that all events except one were
* generated.
*/
- char *before_last_event_file_path_touch = NULL;
+ char *before_last_event_file_path_touch = nullptr;
/* Touch file when we are exiting */
- char *before_exit_file_path_touch = NULL;
+ char *before_exit_file_path_touch = nullptr;
/* Wait on file before exiting */
- char *before_exit_file_path = NULL;
+ char *before_exit_file_path = nullptr;
/* Emit an end event */
bool emit_end_event = false;
static struct option long_options[] = {
/* These options set a flag. */
- { "iter", required_argument, 0, 'i' },
- { "wait", required_argument, 0, 'w' },
- { "create-in-main", required_argument, 0, 'm' },
- { "wait-before-first-event", required_argument, 0, 'b' },
- { 0, 0, 0, 0 }
+ { "iter", required_argument, nullptr, 'i' },
+ { "wait", required_argument, nullptr, 'w' },
+ { "create-in-main", required_argument, nullptr, 'm' },
+ { "wait-before-first-event", required_argument, nullptr, 'b' },
+ { nullptr, 0, nullptr, 0 }
};
int main(int argc, char **argv)
float flt = 2222.0;
unsigned int nr_iter = 100;
useconds_t nr_usec = 0;
- char *wait_before_first_event_file_path = NULL;
- char *create_in_main_file_path = NULL;
+ char *wait_before_first_event_file_path = nullptr;
+ char *create_in_main_file_path = nullptr;
while ((option = getopt_long(argc, argv, "i:w:b:m:", long_options, &option_index)) != -1) {
switch (option) {
int i;
unsigned int nr_iter = 100;
useconds_t nr_usec = 0;
- char *tmp_file_path = NULL;
+ char *tmp_file_path = nullptr;
if (set_signal_handler()) {
return 1;
}
static
-int set_signal_handler(void)
+int set_signal_handler()
{
int ret;
struct sigaction sa {};
goto end;
}
- ret = sigaction(SIGTERM, &sa, NULL);
+ ret = sigaction(SIGTERM, &sa, nullptr);
if (ret) {
perror("sigaction");
goto end;
not_a_function += 1;
}
-int main(void)
+int main()
{
test_class my_test_class;
/* Call test function. */
for (;;) {
ret = stat(path, &buf);
if (ret == -1 && errno == ENOENT) {
- ret = poll(NULL, 0, 10); /* 10 ms delay */
+ ret = poll(nullptr, 0, 10); /* 10 ms delay */
/* Should return 0 everytime */
if (ret) {
if (ret < 0) {
int i;
xmlNodePtr cur;
- xmlChar *node_child_value_string = NULL;
+ xmlChar *node_child_value_string = nullptr;
LTTNG_ASSERT(output);
size = (nodes) ? nodes->nodeNr : 0;
{
int ret;
xmlChar *prefix;
- xmlChar *ns = NULL;
+ xmlChar *ns = nullptr;
prefix = xmlCharStrdup("lttng");
if (!prefix) {
static int extract_xpath(const char *xml_path, const xmlChar *xpath)
{
int ret;
- xmlDocPtr doc = NULL;
- xmlXPathContextPtr xpathCtx = NULL;
- xmlXPathObjectPtr xpathObj = NULL;
+ xmlDocPtr doc = nullptr;
+ xmlXPathContextPtr xpathCtx = nullptr;
+ xmlXPathObjectPtr xpathObj = nullptr;
LTTNG_ASSERT(xml_path);
LTTNG_ASSERT(xpath);
ret = -LTTNG_ERR_LOAD_INVALID_CONFIG;
goto end;
}
- xmlSchemaSetParserErrors(ctx->parser_ctx, xml_error_handler, xml_error_handler, NULL);
+ xmlSchemaSetParserErrors(ctx->parser_ctx, xml_error_handler, xml_error_handler, nullptr);
ctx->schema = xmlSchemaParse(ctx->parser_ctx);
if (!ctx->schema) {
}
xmlSchemaSetValidErrors(
- ctx->schema_validation_ctx, xml_error_handler, xml_error_handler, NULL);
+ ctx->schema_validation_ctx, xml_error_handler, xml_error_handler, nullptr);
ret = 0;
end:
static int validate_xml(const char *xml_file_path, struct validation_ctx *ctx)
{
int ret;
- xmlDocPtr doc = NULL;
+ xmlDocPtr doc = nullptr;
LTTNG_ASSERT(xml_file_path);
LTTNG_ASSERT(ctx);