Standardize `!ptr` i/o `ptr == NULL`, `ptr` i/o `ptr != NULL`
authorPhilippe Proulx <eeppeliteloop@gmail.com>
Tue, 23 Jul 2019 16:23:35 +0000 (12:23 -0400)
committerPhilippe Proulx <eeppeliteloop@gmail.com>
Tue, 23 Jul 2019 17:03:15 +0000 (13:03 -0400)
Signed-off-by: Philippe Proulx <eeppeliteloop@gmail.com>
Change-Id: I3e47fe9ca121cf3fc4f71e6292b9fa9efc6df341
Reviewed-on: https://review.lttng.org/c/babeltrace/+/1746
Tested-by: jenkins <jenkins@lttng.org>
32 files changed:
src/bindings/python/bt2/bt2/native_bt_component_class.i
src/bindings/python/bt2/bt2/native_bt_trace.i
src/bindings/python/bt2/bt2/native_bt_trace_class.i
src/cli/babeltrace2-cfg-cli-args.c
src/cli/babeltrace2-cfg-cli-params-arg.c
src/cli/babeltrace2-cfg-src-auto-disc.c
src/compat/memstream.h
src/compat/mman.c
src/compat/stdio.h
src/ctf-writer/assert-pre.h
src/ctf-writer/fields.h
src/ctf-writer/stream.c
src/lib/assert-pre.h
src/lib/graph/message/event.c
src/lib/plugin/plugin-so.c
src/lib/plugin/plugin.c
src/lib/trace-ir/field.c
src/lib/trace-ir/trace-class.c
src/lib/trace-ir/trace.c
src/plugins/ctf/common/metadata/decoder-packetized-file-stream-to-buf.c
src/plugins/ctf/common/metadata/parser.y
src/plugins/ctf/common/metadata/visitor-generate-ir.c
src/plugins/ctf/common/metadata/visitor-semantic-validator.c
src/plugins/ctf/fs-src/fs.c
src/plugins/ctf/lttng-live/lttng-live.c
src/plugins/ctf/lttng-live/viewer-connection.c
src/plugins/lttng-utils/debug-info/debug-info.c
src/plugins/text/details/obj-lifetime-mgmt.c
src/py-common/py-common.c
tests/ctf-writer/ctf_writer.c
tests/plugins/flt.lttng-utils.debug-info/test_bin_info.c
tests/plugins/flt.lttng-utils.debug-info/test_dwarf.c

index 42feccf5a1d80d451b19879f9af4ea065bc83725..4b718015738c76f8be9254a6e5fcfccd62a4d9a6 100644 (file)
@@ -181,7 +181,7 @@ void log_exception_and_maybe_append_error(int log_level,
 {
        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 */
index 3e27a368c2e1f7562a262839b9f299134198ff52..3448f646492cec8ef54060119e8a5e4cb7c1ef7d 100644 (file)
@@ -40,7 +40,7 @@ trace_destroyed_listener(const bt_trace *trace, void *py_callable)
        }
 
        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();
index 57166bc9a3e944e1ae1cf11057175d1862263930..fd48deebdb32b38562a2d247d1514c604db1e6c1 100644 (file)
@@ -41,7 +41,7 @@ trace_class_destroyed_listener(const bt_trace_class *trace_class, void *py_calla
        }
 
        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();
index 7fc0488455b565b143ca9b8e9521d25d34d3130c..a16fbfceaa4b6d2cff737bddd1eee9ba374c7b4d 100644 (file)
@@ -506,7 +506,7 @@ void destroy_glist_of_gstring(GList *list)
                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);
        }
 
@@ -3162,7 +3162,7 @@ int convert_auto_connect(bt_value *run_args,
        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;
 
@@ -3177,7 +3177,7 @@ int convert_auto_connect(bt_value *run_args,
        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;
 
@@ -3189,7 +3189,7 @@ int convert_auto_connect(bt_value *run_args,
        }
 
        /* 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;
 
index d69ee8225ce3d69aad2c4c200fb9c41bd564a410..b13172d0e7d9ae153bbc68d85651b5eec9e76e59 100644 (file)
@@ -87,7 +87,7 @@ void ini_append_error_expecting(struct ini_parsing_state *state,
        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;
        }
 
index 505a265f272f03d34097b8ea32da012e9415814b..6dcb9e2c9b39194de84d2adb8235b89c0c4cc9b4 100644 (file)
@@ -562,7 +562,7 @@ int auto_discover_source_for_input_as_dir_or_file_rec(GString *input,
                                BT_LOGW_ERRNO("Failed to read directory entry", ": dir=%s", input->str);
                                goto error;
                        }
-               } while (dirent != NULL);
+               } while (dirent);
 
                status = dir_status;
 
index 8dea7a44f13f5d5f79ae75c610eee4b04a15ebd2..7ca3168a5968b0ad33358cdc69ef00499632bbad 100644 (file)
@@ -69,7 +69,7 @@ FILE *bt_fmemopen(void *buf, size_t size, const char *mode)
 
        /* 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;
        }
 
@@ -217,7 +217,7 @@ FILE *bt_open_memstream(char **ptr, size_t *sizeloc)
 
        tmpname = g_build_filename(g_get_tmp_dir(), "babeltrace-tmp-XXXXXX", NULL);
 
-       if (_mktemp(tmpname) == NULL) {
+       if (!_mktemp(tmpname)) {
                goto error_free;
        }
 
index 72c4cc285aabd22b0f855a50950d66067bbb30fc..1a7638c98381e0d6511a3a78f597e43015d90df7 100644 (file)
@@ -75,7 +75,7 @@ struct mmap_mapping *mapping_create(int log_level)
        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;
@@ -283,7 +283,7 @@ int bt_munmap(void *addr, size_t length)
        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;
index 906e695dfd9227a438195fec0ab8c293a4033a22..a484ed2994cabd5023c4c4345f0abc829498f7a9 100644 (file)
@@ -37,10 +37,10 @@ char * _bt_getline_bufalloc(char **lineptr, size_t *n, size_t linelen)
        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;
@@ -80,7 +80,7 @@ ssize_t bt_getline(char **lineptr, size_t *n, FILE *stream)
        char *buf;
        int found_eof = 0;
 
-       if (lineptr == NULL || n == NULL) {
+       if (!lineptr || !n) {
                errno = EINVAL;
                return -1;
        }
index c0a24614c10d90905b6fef7c85b6d77513e401e7..fbff4a7bd3e74974cb4f2ed001846b97cde58951 100644 (file)
  * 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
index 87063fe20bd278a479fb6057cbf0ddb982985cc7..ecf7e914c85e5994a0c18d1442b59be624d715be 100644 (file)
@@ -650,7 +650,7 @@ int bt_ctf_field_common_string_append_len(struct bt_ctf_field_common *field,
                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);
 
index 1bf60df144bf607a22aeba45282265d670ceff18..3f5e610094e7c45ef311070ca91032274d89c13a 100644 (file)
@@ -1021,7 +1021,7 @@ append_ids:
                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;
        }
@@ -1627,7 +1627,7 @@ int bt_ctf_stream_flush(struct bt_ctf_stream *stream)
 
                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);
        }
 
index a470a63b15e86c04feb924dfddbf3ce7189ef340..39472a44cba9478967b9afdb0c03901b7b8ea426 100644 (file)
  * 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
index 285bf8aa86715fb6fae5be4a3f63f4560b8900bb..4222a5a0a33d87b2ed646e433131fe3464fe4b4b 100644 (file)
@@ -50,7 +50,7 @@ static inline bool event_class_has_trace(struct bt_event_class *event_class)
 
        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
index 319988beeb2dbd1be0406e7a94d89021ddc17cb5..b9ef8005770c5ca92e060fed50dd045fcf877724 100644 (file)
@@ -364,7 +364,7 @@ int bt_plugin_so_init(struct bt_plugin *plugin,
                const struct __bt_plugin_descriptor_attribute *cur_attr =
                        *cur_attr_ptr;
 
-               if (cur_attr == NULL) {
+               if (!cur_attr) {
                        continue;
                }
 
@@ -434,7 +434,7 @@ int bt_plugin_so_init(struct bt_plugin *plugin,
                        *cur_cc_descr_ptr;
                struct comp_class_full_descriptor full_descriptor = {0};
 
-               if (cur_cc_descr == NULL) {
+               if (!cur_cc_descr) {
                        continue;
                }
 
@@ -457,7 +457,7 @@ int bt_plugin_so_init(struct bt_plugin *plugin,
                        *cur_cc_descr_attr_ptr;
                enum bt_component_class_type cc_type;
 
-               if (cur_cc_descr_attr == NULL) {
+               if (!cur_cc_descr_attr) {
                        continue;
                }
 
@@ -1319,7 +1319,7 @@ int bt_plugin_so_create_all_from_sections(
                        descriptors_begin[i];
                struct bt_plugin *plugin;
 
-               if (descriptor == NULL) {
+               if (!descriptor) {
                        continue;
                }
 
index 8f2f6da347cb38792b108ed1c8ee3d6cb8c75dbf..5537cb0d115fe2176123556605c831a1510b28c0 100644 (file)
@@ -84,7 +84,7 @@ int init_python_plugin_provider(void) {
        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;
        }
 
index e200c153fa6b7757514e355cdaa9df3991450278..26160c20d0d0ca013e29d0a0bd0f1102ca4c8556 100644 (file)
@@ -674,7 +674,7 @@ enum bt_field_string_append_status bt_field_string_append_with_length(
                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);
 
index 620e8f6daeb3375b0bc5bd3e006d3e1f82c5f3a9..d968ddfe236689d1e92e312e52451d19e5347acf 100644 (file)
@@ -204,7 +204,7 @@ bool has_listener_id(const struct bt_trace_class *tc, uint64_t listener_id)
        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(
index e884c72a29ed0887bfe1da7880b02863684457dd..0f683fb44e182c778198e8ef64892c753a6bb2bb 100644 (file)
@@ -239,7 +239,7 @@ bool trace_has_environment_entry(const struct bt_trace *trace, const char *name)
        BT_ASSERT(trace);
 
        return bt_attributes_borrow_field_value_by_name(
-               trace->environment, name) != NULL;
+               trace->environment, name);
 }
 
 static
@@ -450,7 +450,7 @@ bool has_listener_id(const struct bt_trace *trace, uint64_t listener_id)
        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(
index e14c54d7907d542d3031795ea97e4633aba0a8ed..bf735827b180ff2ad2b90e44ca45eb1601edfa55 100644 (file)
@@ -212,7 +212,7 @@ int ctf_metadata_decoder_packetized_file_stream_to_buf(FILE *fp,
        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;
index b6f5b7a3abd0aa01611766411d57b59889aeb893..ae5a9f981238d4376f2770701fd923c231b7e1bd 100644 (file)
@@ -351,7 +351,7 @@ int is_type(struct ctf_scanner *scanner, const char *id)
        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;
index 3413ac17cd679b7f162d75eac1b4b941b7f9e244..26e11290c60a1080b95cdff21e14daa94a89d93f 100644 (file)
@@ -4810,7 +4810,7 @@ int ctf_visitor_generate_ir_visit_node(struct ctf_visitor_generate_ir *visitor,
                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) {
@@ -4824,7 +4824,7 @@ int ctf_visitor_generate_ir_visit_node(struct ctf_visitor_generate_ir *visitor,
                }
 
                BT_ASSERT(ctx->current_scope &&
-                       ctx->current_scope->parent_scope == NULL);
+                       !ctx->current_scope->parent_scope);
 
                /*
                 * Visit clock blocks.
@@ -4840,7 +4840,7 @@ int ctf_visitor_generate_ir_visit_node(struct ctf_visitor_generate_ir *visitor,
                }
 
                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
@@ -4858,7 +4858,7 @@ int ctf_visitor_generate_ir_visit_node(struct ctf_visitor_generate_ir *visitor,
                }
 
                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) {
@@ -4867,7 +4867,7 @@ int ctf_visitor_generate_ir_visit_node(struct ctf_visitor_generate_ir *visitor,
                }
 
                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) {
@@ -4881,7 +4881,7 @@ int ctf_visitor_generate_ir_visit_node(struct ctf_visitor_generate_ir *visitor,
                }
 
                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) {
@@ -4895,7 +4895,7 @@ int ctf_visitor_generate_ir_visit_node(struct ctf_visitor_generate_ir *visitor,
                }
 
                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) {
@@ -4909,7 +4909,7 @@ int ctf_visitor_generate_ir_visit_node(struct ctf_visitor_generate_ir *visitor,
                }
 
                BT_ASSERT(ctx->current_scope &&
-                       ctx->current_scope->parent_scope == NULL);
+                       !ctx->current_scope->parent_scope);
                break;
        }
        default:
index 17f63ac9887fde795ec280d0ebea1ce1cfbe12ba..8e732997cb53a62d45688339ed6325c6cdd42dd3 100644 (file)
@@ -358,7 +358,7 @@ int ctf_visitor_field_class_declarator(int depth, struct ctf_node *node,
                        }
                }
                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:
index 375ca0f3d02d23796c32a6866414fbfd0c1d2494..e4eb385282ca7dc01916b395ddfe12dbdd6892b6 100644 (file)
@@ -1683,7 +1683,7 @@ int merge_traces_with_same_uuid(struct ctf_fs_component *ctf_fs)
 
        /* 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++;
index 93ff89bdbf0de03d0d6d58bec72a79d7b37077b2..0cabf25d01751e9298c5a95726dac6e4f7ed7ce0 100644 (file)
@@ -868,7 +868,7 @@ retry:
        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) {
@@ -877,7 +877,7 @@ retry:
        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:
index 44e80cc0cfbf91d12707cf71754bf7c3e355256c..ac3354274f79179a7317bf22cb6b0ff663ff6bb5 100644 (file)
@@ -149,10 +149,10 @@ int parse_url(struct live_viewer_connection *viewer_connection)
                        "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;
 
index f330f1be6ee74d7187d58048506e18b3e3c1c151..10e5a7de6f710698009bb94925c0f4c75ef38d6c 100644 (file)
@@ -443,7 +443,7 @@ static inline
 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
index 9547d609cb08884095acb462415788518e7d7479..8da5cf162cef562b28237bba37ed04c069c1f6d5 100644 (file)
@@ -97,7 +97,7 @@ bool details_need_to_write_meta_object(struct details_write_ctx *ctx,
        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;
@@ -130,7 +130,7 @@ bool details_need_to_write_trace_class(struct details_write_ctx *ctx,
 
        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;
index ac780034ee0c661b7860db5a71b563b78cd739db..4fea4d27b5475ecfa5c6c28208ef8de3a0d79795 100644 (file)
@@ -44,9 +44,9 @@ GString *bt_py_common_format_exception(int log_level)
        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);
index 91b2e6337d406cde49b4dbac3199b223617dbb88..fe811960e90d6c2bcc59c31dd2eff639b465e00a 100644 (file)
@@ -681,7 +681,7 @@ void append_complex_event(struct bt_ctf_stream_class *stream_class,
                "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");
@@ -1217,7 +1217,7 @@ void test_empty_stream(struct bt_ctf_writer *writer)
        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);
@@ -1711,7 +1711,7 @@ int main(int argc, char **argv)
                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");
@@ -1798,9 +1798,9 @@ int main(int argc, char **argv)
        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");
@@ -2001,7 +2001,7 @@ int main(int argc, char **argv)
                "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,
index 6d29322498fa308114e240c87c2f7c6657df0464..b9ee32e0b3a0d8849e65a7f80d40515dfc9c6cbf 100644 (file)
@@ -97,7 +97,7 @@ int build_id_to_bin(void)
 {
        int ret, len, i;
 
-       if (opt_build_id == NULL) {
+       if (!opt_build_id) {
                goto error;
        }
 
@@ -165,7 +165,7 @@ void subtest_lookup_function_name(struct bin_info *bin, uint64_t addr,
 
        /* 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);
 }
@@ -196,7 +196,7 @@ void subtest_lookup_source_location(struct bin_info *bin, uint64_t addr,
 
        /* 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);
@@ -221,7 +221,7 @@ void test_bin_info_build_id(const char *bin_info_dir)
        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);
        }
 
@@ -233,7 +233,7 @@ void test_bin_info_build_id(const char *bin_info_dir)
 
        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);
@@ -275,7 +275,7 @@ void test_bin_info_debug_link(const char *bin_info_dir)
        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);
        }
 
@@ -287,7 +287,7 @@ void test_bin_info_debug_link(const char *bin_info_dir)
 
        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);
@@ -325,7 +325,7 @@ void test_bin_info_elf(const char *bin_info_dir)
        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);
        }
 
@@ -337,7 +337,7 @@ void test_bin_info_elf(const char *bin_info_dir)
 
        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);
@@ -373,7 +373,7 @@ void test_bin_info_bundled(const char *bin_info_dir)
        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);
        }
 
@@ -385,7 +385,7 @@ void test_bin_info_bundled(const char *bin_info_dir)
 
        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);
index abb72bba6051e516404fb16b6140a9ac4c97150a..953556c41004cf43341d01f25fdacb5dbd397e2a 100644 (file)
@@ -46,7 +46,7 @@ void test_bt_no_dwarf(const char *data_dir)
        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);
        }
@@ -57,10 +57,10 @@ void test_bt_no_dwarf(const char *data_dir)
                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);
@@ -81,7 +81,7 @@ void test_bt_dwarf(const char *data_dir)
        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);
        }
@@ -92,13 +92,13 @@ void test_bt_dwarf(const char *data_dir)
                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);
        }
This page took 0.044436 seconds and 4 git commands to generate.