{
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;
}
/* Only if channel is enabled disable it. */
- if (kchan->enabled == 1) {
+ if (kchan->enabled) {
ret = kernel_disable_channel(kchan);
if (ret < 0 && ret != -EEXIST) {
ret = LTTNG_ERR_KERN_CHAN_DISABLE_FAIL;
LTTNG_ASSERT(ksession);
LTTNG_ASSERT(kchan);
- if (kchan->enabled == 0) {
+ if (!kchan->enabled) {
if (kernel_enable_channel(kchan) < 0) {
ret_code = LTTNG_ERR_KERN_CHAN_ENABLE_FAIL;
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;
}
ret_code = LTTNG_ERR_UST_CHAN_EXIST;
goto end;
} else {
- uchan->enabled = 1;
+ uchan->enabled = true;
DBG2("Channel %s enabled successfully", uchan->name);
}
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::urcu::read_lock_guard read_lock;
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;
}
- uchan->enabled = 1;
- if (trace_ust_is_max_id(usess->used_channel_id)) {
+ uchan->enabled = true;
+ if (trace_ust_is_max_id(usess->used_event_container_id)) {
ret_code = LTTNG_ERR_UST_CHAN_FAIL;
goto error;
}
- uchan->id = trace_ust_get_next_chan_id(usess);
+
+ uchan->id = trace_ust_get_next_event_container_id(usess);
DBG2("Channel %s is being created for UST with buffer %d and id %" PRIu64,
uchan->name,
}
/* Adding the channel to the channel hash table. */
- rcu_read_lock();
- if (strncmp(uchan->name, DEFAULT_METADATA_NAME, sizeof(uchan->name))) {
+ if (strncmp(uchan->name, DEFAULT_METADATA_NAME, sizeof(uchan->name)) != 0) {
lttng_ht_add_unique_str(usess->domain_global.channels, &uchan->node);
chan_published = true;
} else {
*/
memcpy(&usess->metadata_attr, &uchan->attr, sizeof(usess->metadata_attr));
}
- rcu_read_unlock();
DBG2("Channel %s created successfully", uchan->name);
if (domain != LTTNG_DOMAIN_UST) {
LTTNG_ASSERT(uchan);
/* Already disabled */
- if (uchan->enabled == 0) {
+ if (!uchan->enabled) {
DBG2("Channel UST %s already disabled", uchan->name);
goto end;
}
- uchan->enabled = 0;
+ uchan->enabled = false;
/*
* If session is inactive we don't notify the tracer right away. We
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);