{
GString *gstr;
- BT_ASSERT(PyErr_Occurred() != NULL);
+ BT_ASSERT(PyErr_Occurred());
gstr = bt_py_common_format_exception(BT_LOG_OUTPUT_LEVEL);
if (!gstr) {
/* bt_py_common_format_exception() logs errors */
}
py_res = PyObject_CallFunction(py_callable, "(O)", py_trace_ptr);
- if (py_res != NULL) {
+ if (py_res) {
BT_ASSERT(py_res == Py_None);
} else {
loge_exception();
}
py_res = PyObject_CallFunction(py_callable, "(O)", py_trace_class_ptr);
- if (py_res != NULL) {
+ if (py_res) {
BT_ASSERT(py_res == Py_None);
} else {
loge_exception();
return;
}
- for (at = list; at != NULL; at = g_list_next(at)) {
+ for (at = list; at; at = g_list_next(at)) {
g_string_free(at->data, TRUE);
}
BT_ASSERT(sink_names);
/* Connect all sources to the first filter */
- for (source_at = source_names; source_at != NULL; source_at = g_list_next(source_at)) {
+ for (source_at = source_names; source_at; source_at = g_list_next(source_at)) {
GString *source_name = source_at->data;
GString *filter_name = filter_at->data;
filter_at = g_list_next(filter_at);
/* Connect remaining filters */
- for (; filter_at != NULL; filter_prev = filter_at, filter_at = g_list_next(filter_at)) {
+ for (; filter_at; filter_prev = filter_at, filter_at = g_list_next(filter_at)) {
GString *filter_name = filter_at->data;
GString *filter_prev_name = filter_prev->data;
}
/* Connect last filter to all sinks */
- for (sink_at = sink_names; sink_at != NULL; sink_at = g_list_next(sink_at)) {
+ for (sink_at = sink_names; sink_at; sink_at = g_list_next(sink_at)) {
GString *filter_name = filter_prev->data;
GString *sink_name = sink_at->data;
g_string_append_printf(state->ini_error, "Expecting %s:\n", expecting);
/* Only append error if there's one line */
- if (strchr(state->arg, '\n') != NULL || strlen(state->arg) == 0) {
+ if (strchr(state->arg, '\n') || strlen(state->arg) == 0) {
return;
}
BT_LOGW_ERRNO("Failed to read directory entry", ": dir=%s", input->str);
goto error;
}
- } while (dirent != NULL);
+ } while (dirent);
status = dir_status;
/* Build a temporary filename */
tmpname = g_build_filename(g_get_tmp_dir(), "babeltrace-tmp-XXXXXX", NULL);
- if (_mktemp(tmpname) == NULL) {
+ if (!_mktemp(tmpname)) {
goto error_free;
}
tmpname = g_build_filename(g_get_tmp_dir(), "babeltrace-tmp-XXXXXX", NULL);
- if (_mktemp(tmpname) == NULL) {
+ if (!_mktemp(tmpname)) {
goto error_free;
}
struct mmap_mapping *mapping;
mapping = malloc(sizeof(struct mmap_mapping));
- if (mapping != NULL) {
+ if (mapping) {
mapping->file_handle = NULL;
mapping->map_handle = NULL;
mapping->log_level = log_level;
mmap_lock(log_level);
/* Check if the mapping exists in the hashtable. */
- if (g_hash_table_lookup(mmap_mappings, addr) == NULL) {
+ if (!g_hash_table_lookup(mmap_mappings, addr)) {
_set_errno(EINVAL);
ret = -1;
goto end;
size_t buflen = *n;
char *buf = *lineptr;
- if (buflen >= linelen && buf != NULL) {
+ if (buflen >= linelen && buf) {
return buf;
}
- if (buf == NULL) {
+ if (!buf) {
buflen = BT_GETLINE_MINBUFLEN;
} else {
buflen = buflen << 1;
char *buf;
int found_eof = 0;
- if (lineptr == NULL || n == NULL) {
+ if (!lineptr || !n) {
errno = EINVAL;
return -1;
}
* Developer mode: asserts that a given variable is not NULL.
*/
#define BT_CTF_ASSERT_PRE_NON_NULL(_obj, _obj_name) \
- BT_CTF_ASSERT_PRE((_obj) != NULL, "%s is NULL: ", _obj_name)
+ BT_CTF_ASSERT_PRE((_obj), "%s is NULL: ", _obj_name)
/*
* Developer mode: asserts that a given object is NOT frozen. This macro
BT_CTF_FIELD_TYPE_ID_STRING, "Field");
/* Make sure no null bytes are appended */
- BT_CTF_ASSERT_PRE(memchr(value, '\0', length) == NULL,
+ BT_CTF_ASSERT_PRE(!memchr(value, '\0', length),
"String value to append contains a null character: "
"partial-value=\"%.32s\", length=%u", value, length);
stream_class_id, stream->common.id);
file_path = g_build_filename(writer->path->str, filename->str, NULL);
- if (file_path == NULL) {
+ if (!file_path) {
ret = -1;
goto end;
}
packet_size_field = bt_ctf_field_structure_get_field_by_name(
stream->packet_context, "packet_size");
- has_packet_size = (packet_size_field != NULL);
+ has_packet_size = packet_size_field;
bt_ctf_object_put_ref(packet_size_field);
}
* is not `NULL`.
*/
#define BT_ASSERT_PRE_NON_NULL(_obj, _obj_name) \
- BT_ASSERT_PRE((_obj) != NULL, "%s is NULL: ", _obj_name)
+ BT_ASSERT_PRE((_obj), "%s is NULL: ", _obj_name)
/*
* Asserts that a given index `_index` is less than a given length
stream_class = bt_event_class_borrow_stream_class_inline(event_class);
BT_ASSERT(stream_class);
- return bt_stream_class_borrow_trace_class(stream_class) != NULL;
+ return bt_stream_class_borrow_trace_class(stream_class);
}
BT_HIDDEN
const struct __bt_plugin_descriptor_attribute *cur_attr =
*cur_attr_ptr;
- if (cur_attr == NULL) {
+ if (!cur_attr) {
continue;
}
*cur_cc_descr_ptr;
struct comp_class_full_descriptor full_descriptor = {0};
- if (cur_cc_descr == NULL) {
+ if (!cur_cc_descr) {
continue;
}
*cur_cc_descr_attr_ptr;
enum bt_component_class_type cc_type;
- if (cur_cc_descr_attr == NULL) {
+ if (!cur_cc_descr_attr) {
continue;
}
descriptors_begin[i];
struct bt_plugin *plugin;
- if (descriptor == NULL) {
+ if (!descriptor) {
continue;
}
static const char * const provider_dir_envvar_name = "LIBBABELTRACE2_PLUGIN_PROVIDER_DIR";
char *provider_path = NULL;
- if (bt_plugin_python_create_all_from_file_sym != NULL) {
+ if (bt_plugin_python_create_all_from_file_sym) {
goto end;
}
BT_FIELD_CLASS_TYPE_STRING, "Field");
/* Make sure no null bytes are appended */
- BT_ASSERT_PRE_DEV(memchr(value, '\0', length) == NULL,
+ BT_ASSERT_PRE_DEV(!memchr(value, '\0', length),
"String value to append contains a null character: "
"partial-value=\"%.32s\", length=%" PRIu64, value, length);
BT_ASSERT(listener_id < tc->destruction_listeners->len);
return (&g_array_index(tc->destruction_listeners,
struct bt_trace_class_destruction_listener_elem,
- listener_id))->func != NULL;
+ listener_id))->func;
}
enum bt_trace_class_remove_listener_status bt_trace_class_remove_destruction_listener(
BT_ASSERT(trace);
return bt_attributes_borrow_field_value_by_name(
- trace->environment, name) != NULL;
+ trace->environment, name);
}
static
BT_ASSERT(listener_id < trace->destruction_listeners->len);
return (&g_array_index(trace->destruction_listeners,
struct bt_trace_destruction_listener_elem,
- listener_id))->func != NULL;
+ listener_id))->func;
}
enum bt_trace_remove_listener_status bt_trace_remove_destruction_listener(
size_t packet_index = 0;
out_fp = bt_open_memstream(buf, &size);
- if (out_fp == NULL) {
+ if (!out_fp) {
BT_COMP_LOGE("Cannot open memory stream: %s.",
strerror(errno));
goto error;
struct ctf_scanner_scope *it;
int ret = 0;
- for (it = scanner->cs; it != NULL; it = it->parent) {
+ for (it = scanner->cs; it; it = it->parent) {
if (lookup_type(it, id)) {
ret = 1;
break;
BT_ASSERT(ctx->ctf_tc->default_byte_order == CTF_BYTE_ORDER_LITTLE ||
ctx->ctf_tc->default_byte_order == CTF_BYTE_ORDER_BIG);
BT_ASSERT(ctx->current_scope &&
- ctx->current_scope->parent_scope == NULL);
+ !ctx->current_scope->parent_scope);
/* Environment */
bt_list_for_each_entry(iter, &node->u.root.env, siblings) {
}
BT_ASSERT(ctx->current_scope &&
- ctx->current_scope->parent_scope == NULL);
+ !ctx->current_scope->parent_scope);
/*
* Visit clock blocks.
}
BT_ASSERT(ctx->current_scope &&
- ctx->current_scope->parent_scope == NULL);
+ !ctx->current_scope->parent_scope);
/*
* Visit root declarations next, as they can be used by any
}
BT_ASSERT(ctx->current_scope &&
- ctx->current_scope->parent_scope == NULL);
+ !ctx->current_scope->parent_scope);
/* Callsite blocks are not supported */
bt_list_for_each_entry(iter, &node->u.root.callsite, siblings) {
}
BT_ASSERT(ctx->current_scope &&
- ctx->current_scope->parent_scope == NULL);
+ !ctx->current_scope->parent_scope);
/* Trace */
bt_list_for_each_entry(iter, &node->u.root.trace, siblings) {
}
BT_ASSERT(ctx->current_scope &&
- ctx->current_scope->parent_scope == NULL);
+ !ctx->current_scope->parent_scope);
/* Streams */
bt_list_for_each_entry(iter, &node->u.root.stream, siblings) {
}
BT_ASSERT(ctx->current_scope &&
- ctx->current_scope->parent_scope == NULL);
+ !ctx->current_scope->parent_scope);
/* Events */
bt_list_for_each_entry(iter, &node->u.root.event, siblings) {
}
BT_ASSERT(ctx->current_scope &&
- ctx->current_scope->parent_scope == NULL);
+ !ctx->current_scope->parent_scope);
break;
}
default:
}
}
if (node->u.field_class_declarator.type == TYPEDEC_ID &&
- node->u.field_class_declarator.u.id != NULL)
+ node->u.field_class_declarator.u.id)
goto errperm;
break; /* OK */
case NODE_TYPEDEF:
/* Clear any NULL slot (traces that got merged in another one) in the array. */
for (i = 0; i < traces->len;) {
- if (g_ptr_array_index(traces, i) == NULL) {
+ if (!g_ptr_array_index(traces, i)) {
g_ptr_array_remove_index_fast(traces, i);
} else {
i++;
live_status = lttng_live_iterator_next_handle_one_quiescent_stream(
lttng_live_msg_iter, stream_iter, curr_msg);
if (live_status != LTTNG_LIVE_ITERATOR_STATUS_OK) {
- BT_ASSERT(*curr_msg == NULL);
+ BT_ASSERT(!*curr_msg);
goto end;
}
if (*curr_msg) {
live_status = lttng_live_iterator_next_handle_one_active_data_stream(
lttng_live_msg_iter, stream_iter, curr_msg);
if (live_status != LTTNG_LIVE_ITERATOR_STATUS_OK) {
- BT_ASSERT(*curr_msg == NULL);
+ BT_ASSERT(!*curr_msg);
}
end:
"proto : %s",
viewer_connection->relay_hostname->str,
viewer_connection->port,
- viewer_connection->target_hostname == NULL ?
- "<none>" : viewer_connection->target_hostname->str,
- viewer_connection->session_name == NULL ?
- "<none>" : viewer_connection->session_name->str,
+ !viewer_connection->target_hostname ?
+ "<none>" : viewer_connection->target_hostname->str,
+ !viewer_connection->session_name ?
+ "<none>" : viewer_connection->session_name->str,
lttng_live_url_parts.proto->str);
ret = 0;
bool event_has_payload_field(const bt_event *event,
const char *field_name)
{
- return event_borrow_payload_field(event, field_name) != NULL;
+ return event_borrow_payload_field(event, field_name);
}
static
details_tc_meta = g_hash_table_lookup(ctx->details_comp->meta, tc);
BT_ASSERT(details_tc_meta);
need_to_write =
- g_hash_table_lookup(details_tc_meta->objects, obj) == NULL;
+ !g_hash_table_lookup(details_tc_meta->objects, obj);
end:
return need_to_write;
BT_ASSERT(ctx->details_comp->meta);
details_tc_meta = g_hash_table_lookup(ctx->details_comp->meta, tc);
- need_to_write = details_tc_meta == NULL;
+ need_to_write = !details_tc_meta;
end:
return need_to_write;
const char *format_exc_func_name;
Py_ssize_t i;
- BT_ASSERT(PyErr_Occurred() != NULL);
+ BT_ASSERT(PyErr_Occurred());
PyErr_Fetch(&type, &value, &traceback);
- BT_ASSERT(type != NULL);
+ BT_ASSERT(type);
/* Make sure `value` is what we expected: an instance of `type` */
PyErr_NormalizeException(&type, &value, &traceback);
"bt_ctf_event_class_get_stream_class returns the correct stream class");
bt_ctf_object_put_ref(ret_stream_class);
- ok(bt_ctf_event_class_get_field_by_name(event_class, "truie") == NULL,
+ ok(!bt_ctf_event_class_get_field_by_name(event_class, "truie"),
"bt_ctf_event_class_get_field_by_name handles an invalid field name correctly");
ret_field_type = bt_ctf_event_class_get_field_by_name(event_class,
"complex_structure");
ret = bt_ctf_stream_class_set_event_header_type(stream_class, NULL);
BT_ASSERT(ret == 0);
- ok(bt_ctf_stream_class_get_trace(stream_class) == NULL,
+ ok(!bt_ctf_stream_class_get_trace(stream_class),
"bt_ctf_stream_class_get_trace returns NULL when stream class is orphaned");
stream = bt_ctf_writer_create_stream(writer, stream_class);
name.machine);
/* Define a clock and add it to the trace */
- ok(bt_ctf_clock_create("signed") == NULL,
+ ok(!bt_ctf_clock_create("signed"),
"Illegal clock name rejected");
clock = bt_ctf_clock_create(clock_name);
ok(clock, "Clock created sucessfully");
ok(ret_string && strcmp(ret_string, "test_stream") == 0,
"bt_ctf_stream_class_get_name returns a correct stream class name");
- ok(bt_ctf_stream_class_get_clock(stream_class) == NULL,
+ ok(!bt_ctf_stream_class_get_clock(stream_class),
"bt_ctf_stream_class_get_clock returns NULL when a clock was not set");
- ok(bt_ctf_stream_class_get_clock(NULL) == NULL,
+ ok(!bt_ctf_stream_class_get_clock(NULL),
"bt_ctf_stream_class_get_clock handles NULL correctly");
ok(stream_class, "Create stream class");
"Changes to a stream class that was already instantiated fail");
/* Populate the custom packet header field only once for all tests */
- ok(bt_ctf_stream_get_packet_header(NULL) == NULL,
+ ok(!bt_ctf_stream_get_packet_header(NULL),
"bt_ctf_stream_get_packet_header handles NULL correctly");
packet_header = bt_ctf_stream_get_packet_header(stream1);
ok(packet_header,
{
int ret, len, i;
- if (opt_build_id == NULL) {
+ if (!opt_build_id) {
goto error;
}
/* Test function name lookup - erroneous address */
ret = bin_info_lookup_function_name(bin, SO_INV_ADDR, &_func_name);
- ok(ret == -1 && _func_name == NULL,
+ ok(ret == -1 && !_func_name,
"bin_info_lookup_function_name - fail on invalid addr");
free(_func_name);
}
/* Test source location lookup - erroneous address */
ret = bin_info_lookup_source_location(bin, SO_INV_ADDR, &src_loc);
- ok(ret == -1 && src_loc == NULL,
+ ok(ret == -1 && !src_loc,
"bin_info_lookup_source_location - fail on invalid addr");
if (src_loc) {
source_location_destroy(src_loc);
bin_path =
g_build_filename(bin_info_dir, BUILDID_DIR_NAME, SO_NAME, NULL);
- if (data_dir == NULL || bin_path == NULL) {
+ if (!data_dir || !bin_path) {
exit(EXIT_FAILURE);
}
bin = bin_info_create(&fdc, bin_path, SO_LOW_ADDR, SO_MEMSZ, true,
data_dir, NULL, BT_LOG_OUTPUT_LEVEL, NULL);
- ok(bin != NULL, "bin_info_create successful (%s)", bin_path);
+ ok(bin, "bin_info_create successful (%s)", bin_path);
/* Test setting invalid build_id */
ret = bin_info_set_build_id(bin, invalid_build_id, BUILD_ID_HEX_LEN);
bin_path = g_build_filename(bin_info_dir, DEBUGLINK_DIR_NAME, SO_NAME,
NULL);
- if (data_dir == NULL || bin_path == NULL) {
+ if (!data_dir || !bin_path) {
exit(EXIT_FAILURE);
}
bin = bin_info_create(&fdc, bin_path, SO_LOW_ADDR, SO_MEMSZ, true,
data_dir, NULL, BT_LOG_OUTPUT_LEVEL, NULL);
- ok(bin != NULL, "bin_info_create successful (%s)", bin_path);
+ ok(bin, "bin_info_create successful (%s)", bin_path);
/* Test setting debug link */
ret = bin_info_set_debug_link(bin, DEBUG_NAME, opt_debug_link_crc);
data_dir = g_build_filename(bin_info_dir, ELF_DIR_NAME, NULL);
bin_path = g_build_filename(bin_info_dir, ELF_DIR_NAME, SO_NAME, NULL);
- if (data_dir == NULL || bin_path == NULL) {
+ if (!data_dir || !bin_path) {
exit(EXIT_FAILURE);
}
bin = bin_info_create(&fdc, bin_path, SO_LOW_ADDR, SO_MEMSZ, true,
data_dir, NULL, BT_LOG_OUTPUT_LEVEL, NULL);
- ok(bin != NULL, "bin_info_create successful (%s)", bin_path);
+ ok(bin, "bin_info_create successful (%s)", bin_path);
/* Test bin_info_has_address */
subtest_has_address(bin, func_foo_printf_addr);
bin_path =
g_build_filename(bin_info_dir, DWARF_DIR_NAME, SO_NAME, NULL);
- if (data_dir == NULL || bin_path == NULL) {
+ if (!data_dir || !bin_path) {
exit(EXIT_FAILURE);
}
bin = bin_info_create(&fdc, bin_path, SO_LOW_ADDR, SO_MEMSZ, true,
data_dir, NULL, BT_LOG_OUTPUT_LEVEL, NULL);
- ok(bin != NULL, "bin_info_create successful (%s)", bin_path);
+ ok(bin, "bin_info_create successful (%s)", bin_path);
/* Test bin_info_has_address */
subtest_has_address(bin, func_foo_printf_addr);
Dwarf *dwarf_info = NULL;
path = g_build_filename(data_dir, ELF_DIR_NAME, SO_NAME, NULL);
- if (path == NULL) {
+ if (!path) {
diag("Failed to allocate memory for path");
exit(EXIT_FAILURE);
}
skip(1, "dwarf_begin failed as expected");
} else {
dwarf_info = dwarf_begin(fd, DWARF_C_READ);
- ok(dwarf_info == NULL, "dwarf_begin failed as expected");
+ ok(!dwarf_info, "dwarf_begin failed as expected");
}
- if (dwarf_info != NULL) {
+ if (dwarf_info) {
dwarf_end(dwarf_info);
}
close(fd);
Dwarf *dwarf_info = NULL;
path = g_build_filename(data_dir, DWARF_DIR_NAME, SO_NAME, NULL);
- if (path == NULL) {
+ if (!path) {
diag("Failed to allocate memory for path");
exit(EXIT_FAILURE);
}
exit(EXIT_FAILURE);
}
dwarf_info = dwarf_begin(fd, DWARF_C_READ);
- ok(dwarf_info != NULL, "dwarf_begin successful");
+ ok(dwarf_info, "dwarf_begin successful");
cu = bt_dwarf_cu_create(dwarf_info);
- ok(cu != NULL, "bt_dwarf_cu_create successful");
+ ok(cu, "bt_dwarf_cu_create successful");
ret = bt_dwarf_cu_next(cu);
ok(ret == 0, "bt_dwarf_cu_next successful");
die = bt_dwarf_die_create(cu);
- ok(die != NULL, "bt_dwarf_die_create successful");
+ ok(die, "bt_dwarf_die_create successful");
if (!die) {
exit(EXIT_FAILURE);
}