From a3e8b0eb2ac383e8b87230aa82c1d12005295cf0 Mon Sep 17 00:00:00 2001 From: Erica Bugden Date: Thu, 22 Aug 2024 14:41:36 -0400 Subject: [PATCH] debug-info: cleanup: Replace `NULL` with `nullptr` Change-Id: Ifdd47b8ba2483b389677f3052f5db911e5e66d76 Signed-off-by: Erica Bugden Reviewed-on: https://review.lttng.org/c/babeltrace/+/13229 Reviewed-by: Simon Marchi --- .../lttng-utils/debug-info/bin-info.cpp | 98 +++++++++---------- .../lttng-utils/debug-info/bin-info.hpp | 4 +- .../lttng-utils/debug-info/debug-info.cpp | 83 ++++++++-------- src/plugins/lttng-utils/debug-info/dwarf.cpp | 30 +++--- src/plugins/lttng-utils/debug-info/dwarf.hpp | 4 +- .../debug-info/trace-ir-data-copy.cpp | 2 +- .../debug-info/trace-ir-mapping.cpp | 37 +++---- .../debug-info/trace-ir-metadata-copy.cpp | 4 +- .../trace-ir-metadata-field-class-copy.cpp | 10 +- 9 files changed, 138 insertions(+), 134 deletions(-) diff --git a/src/plugins/lttng-utils/debug-info/bin-info.cpp b/src/plugins/lttng-utils/debug-info/bin-info.cpp index ee10a5a4..64ae6bea 100644 --- a/src/plugins/lttng-utils/debug-info/bin-info.cpp +++ b/src/plugins/lttng-utils/debug-info/bin-info.cpp @@ -52,7 +52,7 @@ struct bin_info *bin_info_create(struct bt_fd_cache *fdc, const char *path, uint const char *target_prefix, bt_logging_level log_level, bt_self_component *self_comp) { - struct bin_info *bin = NULL; + struct bin_info *bin = nullptr; BT_ASSERT(fdc); @@ -68,7 +68,7 @@ struct bin_info *bin_info_create(struct bt_fd_cache *fdc, const char *path, uint bin->log_level = log_level; bin->self_comp = self_comp; if (target_prefix) { - bin->elf_path = g_build_filename(target_prefix, path, NULL); + bin->elf_path = g_build_filename(target_prefix, path, nullptr); } else { bin->elf_path = g_strdup(path); } @@ -88,7 +88,7 @@ struct bin_info *bin_info_create(struct bt_fd_cache *fdc, const char *path, uint bin->memsz = memsz; bin->low_addr = low_addr; bin->high_addr = bin->low_addr + bin->memsz; - bin->build_id = NULL; + bin->build_id = nullptr; bin->build_id_len = 0; bin->file_build_id_matches = false; bin->fd_cache = fdc; @@ -97,7 +97,7 @@ struct bin_info *bin_info_create(struct bt_fd_cache *fdc, const char *path, uint error: bin_info_destroy(bin); - return NULL; + return nullptr; } void bin_info_destroy(struct bin_info *bin) @@ -130,8 +130,8 @@ void bin_info_destroy(struct bin_info *bin) */ static int bin_info_set_elf_file(struct bin_info *bin) { - struct bt_fd_cache_handle *elf_handle = NULL; - Elf *elf_file = NULL; + struct bt_fd_cache_handle *elf_handle = nullptr; + Elf *elf_file = nullptr; int ret; BT_ASSERT(bin); @@ -143,7 +143,7 @@ static int bin_info_set_elf_file(struct bin_info *bin) } bin->elf_handle = elf_handle; - elf_file = elf_begin(bt_fd_cache_handle_get_fd(bin->elf_handle), ELF_C_READ, NULL); + elf_file = elf_begin(bt_fd_cache_handle_get_fd(bin->elf_handle), ELF_C_READ, nullptr); if (!elf_file) { BT_COMP_LOGE_APPEND_CAUSE(bin->self_comp, "elf_begin failed: %s", elf_errmsg(-1)); goto error; @@ -264,7 +264,7 @@ end: static int is_build_id_matching(struct bin_info *bin) { int ret, is_build_id, is_matching = 0; - Elf_Scn *curr_section = NULL, *next_section = NULL; + Elf_Scn *curr_section = nullptr, *next_section = nullptr; GElf_Shdr curr_section_hdr; if (!bin->build_id) { @@ -286,7 +286,7 @@ static int is_build_id_matching(struct bin_info *bin) } while (next_section) { - Elf_Data *note_data = NULL; + Elf_Data *note_data = nullptr; curr_section = next_section; next_section = elf_nextscn(bin->elf_file, curr_section); @@ -302,7 +302,7 @@ static int is_build_id_matching(struct bin_info *bin) /* * elf_getdata() translates the data to native byte order. */ - note_data = elf_getdata(curr_section, NULL); + note_data = elf_getdata(curr_section, nullptr); if (!note_data) { goto error; } @@ -407,9 +407,9 @@ error: static int bin_info_set_dwarf_info_from_path(struct bin_info *bin, char *path) { int ret = 0; - struct bt_fd_cache_handle *dwarf_handle = NULL; - struct bt_dwarf_cu *cu = NULL; - Dwarf *dwarf_info = NULL; + struct bt_fd_cache_handle *dwarf_handle = nullptr; + struct bt_dwarf_cu *cu = nullptr; + Dwarf *dwarf_info = nullptr; if (!bin || !path) { goto error; @@ -471,8 +471,8 @@ error: static int bin_info_set_dwarf_info_build_id(struct bin_info *bin) { int i = 0, ret = 0; - char *path = NULL, *build_id_prefix_dir = NULL, *build_id_file = NULL; - const char *dbg_dir = NULL; + char *path = nullptr, *build_id_prefix_dir = nullptr, *build_id_file = nullptr; + const char *dbg_dir = nullptr; size_t build_id_char_len, build_id_suffix_char_len, build_id_file_len; if (!bin || !bin->build_id) { @@ -522,7 +522,7 @@ static int bin_info_set_dwarf_info_build_id(struct bin_info *bin) /* Append the suffix to the generated string, including the '\0'. */ g_snprintf(&build_id_file[build_id_char_len], build_id_suffix_char_len, BUILD_ID_SUFFIX); - path = g_build_filename(dbg_dir, BUILD_ID_SUBDIR, build_id_prefix_dir, build_id_file, NULL); + path = g_build_filename(dbg_dir, BUILD_ID_SUBDIR, build_id_prefix_dir, build_id_file, nullptr); if (!path) { goto error; } @@ -561,7 +561,7 @@ end: static int is_valid_debug_file(struct bin_info *bin, char *path, uint32_t crc) { int ret = 0; - struct bt_fd_cache_handle *debug_handle = NULL; + struct bt_fd_cache_handle *debug_handle = nullptr; uint32_t _crc = 0; if (!path) { @@ -597,8 +597,8 @@ end: static int bin_info_set_dwarf_info_debug_link(struct bin_info *bin) { int ret = 0; - const gchar *dbg_dir = NULL; - gchar *bin_dir = NULL, *path = NULL; + const gchar *dbg_dir = nullptr; + gchar *bin_dir = nullptr, *path = nullptr; if (!bin || !bin->dbg_link_filename) { goto error; @@ -608,7 +608,7 @@ static int bin_info_set_dwarf_info_debug_link(struct bin_info *bin) bin_dir = g_path_get_dirname(bin->elf_path); /* First look in the executable's dir */ - path = g_build_filename(bin_dir, bin->dbg_link_filename, NULL); + path = g_build_filename(bin_dir, bin->dbg_link_filename, nullptr); if (is_valid_debug_file(bin, path, bin->dbg_link_crc)) { goto found; @@ -616,7 +616,7 @@ static int bin_info_set_dwarf_info_debug_link(struct bin_info *bin) /* If not found, look in .debug subdir */ g_free(path); - path = g_build_filename(bin_dir, DEBUG_SUBDIR, bin->dbg_link_filename, NULL); + path = g_build_filename(bin_dir, DEBUG_SUBDIR, bin->dbg_link_filename, nullptr); if (is_valid_debug_file(bin, path, bin->dbg_link_crc)) { goto found; @@ -625,7 +625,7 @@ static int bin_info_set_dwarf_info_debug_link(struct bin_info *bin) /* Lastly, look under the global debug directory */ g_free(path); - path = g_build_filename(dbg_dir, bin_dir, bin->dbg_link_filename, NULL); + path = g_build_filename(dbg_dir, bin_dir, bin->dbg_link_filename, nullptr); if (is_valid_debug_file(bin, path, bin->dbg_link_crc)) { goto found; } @@ -716,7 +716,7 @@ static int bin_info_append_offset_str(const char *base_str, uint64_t low_addr, u char **result) { uint64_t offset; - char *_result = NULL; + char *_result = nullptr; if (!base_str || !result) { goto error; @@ -760,9 +760,9 @@ static int bin_info_get_nearest_symbol_from_section(Elf_Scn *scn, uint64_t addr, { int i; size_t symbol_count; - Elf_Data *data = NULL; - GElf_Shdr *_shdr = NULL; - GElf_Sym *nearest_sym = NULL; + Elf_Data *data = nullptr; + GElf_Shdr *_shdr = nullptr; + GElf_Sym *nearest_sym = nullptr; if (!scn || !sym || !shdr) { goto error; @@ -786,7 +786,7 @@ static int bin_info_get_nearest_symbol_from_section(Elf_Scn *scn, uint64_t addr, goto end; } - data = elf_getdata(scn, NULL); + data = elf_getdata(scn, nullptr); if (!data) { goto error; } @@ -794,7 +794,7 @@ static int bin_info_get_nearest_symbol_from_section(Elf_Scn *scn, uint64_t addr, symbol_count = _shdr->sh_size / _shdr->sh_entsize; for (i = 0; i < symbol_count; ++i) { - GElf_Sym *cur_sym = NULL; + GElf_Sym *cur_sym = nullptr; cur_sym = g_new0(GElf_Sym, 1); if (!cur_sym) { @@ -862,10 +862,10 @@ static int bin_info_lookup_elf_function_name(struct bin_info *bin, uint64_t addr * first iteration to prevent subsequent ones. */ int ret = 0; - Elf_Scn *scn = NULL; - GElf_Sym *sym = NULL; - GElf_Shdr *shdr = NULL; - char *sym_name = NULL; + Elf_Scn *scn = nullptr; + GElf_Sym *sym = nullptr; + GElf_Shdr *shdr = nullptr; + char *sym_name = nullptr; /* Set ELF file if it hasn't been accessed yet. */ if (!bin->elf_file) { @@ -929,7 +929,7 @@ static int bin_info_lookup_cu_function_name(struct bt_dwarf_cu *cu, uint64_t add { int ret = 0; bool found = false; - struct bt_dwarf_die *die = NULL; + struct bt_dwarf_die *die = nullptr; if (!cu || !func_name) { goto error; @@ -962,7 +962,7 @@ static int bin_info_lookup_cu_function_name(struct bt_dwarf_cu *cu, uint64_t add if (found) { uint64_t low_addr = 0; - char *die_name = NULL; + char *die_name = nullptr; ret = bt_dwarf_die_get_name(die, &die_name); if (ret) { @@ -1008,8 +1008,8 @@ static int bin_info_lookup_dwarf_function_name(struct bin_info *bin, uint64_t ad char **func_name) { int ret = 0; - char *_func_name = NULL; - struct bt_dwarf_cu *cu = NULL; + char *_func_name = nullptr; + struct bt_dwarf_cu *cu = nullptr; if (!bin || !func_name) { goto error; @@ -1048,7 +1048,7 @@ error: int bin_info_lookup_function_name(struct bin_info *bin, uint64_t addr, char **func_name) { int ret = 0; - char *_func_name = NULL; + char *_func_name = nullptr; if (!bin || !func_name) { goto error; @@ -1110,7 +1110,7 @@ error: int bin_info_get_bin_loc(struct bin_info *bin, uint64_t addr, char **bin_loc) { - gchar *_bin_loc = NULL; + gchar *_bin_loc = nullptr; if (!bin || !bin_loc) { goto error; @@ -1240,8 +1240,8 @@ static int bin_info_lookup_cu_src_loc_inl(struct bt_dwarf_cu *cu, uint64_t addr, { int ret = 0; bool found = false; - struct bt_dwarf_die *die = NULL; - struct source_location *_src_loc = NULL; + struct bt_dwarf_die *die = nullptr; + struct source_location *_src_loc = nullptr; if (!cu || !src_loc) { goto error; @@ -1285,7 +1285,7 @@ static int bin_info_lookup_cu_src_loc_inl(struct bt_dwarf_cu *cu, uint64_t addr, end: if (found) { - char *filename = NULL; + char *filename = nullptr; uint64_t line_no; _src_loc = g_new0(struct source_location, 1); @@ -1337,10 +1337,10 @@ error: static int bin_info_lookup_cu_src_loc_no_inl(struct bt_dwarf_cu *cu, uint64_t addr, struct source_location **src_loc) { - struct source_location *_src_loc = NULL; - struct bt_dwarf_die *die = NULL; - const char *filename = NULL; - Dwarf_Line *line = NULL; + struct source_location *_src_loc = nullptr; + struct bt_dwarf_die *die = nullptr; + const char *filename = nullptr; + Dwarf_Line *line = nullptr; Dwarf_Addr line_addr; int ret = 0, line_no; @@ -1364,7 +1364,7 @@ static int bin_info_lookup_cu_src_loc_no_inl(struct bt_dwarf_cu *cu, uint64_t ad goto error; } - filename = dwarf_linesrc(line, NULL, NULL); + filename = dwarf_linesrc(line, nullptr, nullptr); if (!filename) { goto error; } @@ -1416,7 +1416,7 @@ static int bin_info_lookup_cu_src_loc(struct bt_dwarf_cu *cu, uint64_t addr, struct source_location **src_loc) { int ret = 0; - struct source_location *_src_loc = NULL; + struct source_location *_src_loc = nullptr; if (!cu || !src_loc) { goto error; @@ -1455,8 +1455,8 @@ error: int bin_info_lookup_source_location(struct bin_info *bin, uint64_t addr, struct source_location **src_loc) { - struct bt_dwarf_cu *cu = NULL; - struct source_location *_src_loc = NULL; + struct bt_dwarf_cu *cu = nullptr; + struct source_location *_src_loc = nullptr; if (!bin || !src_loc) { goto error; diff --git a/src/plugins/lttng-utils/debug-info/bin-info.hpp b/src/plugins/lttng-utils/debug-info/bin-info.hpp index d3c19c21..1d629b59 100644 --- a/src/plugins/lttng-utils/debug-info/bin-info.hpp +++ b/src/plugins/lttng-utils/debug-info/bin-info.hpp @@ -28,7 +28,7 @@ struct bin_info { bt_logging_level log_level; - /* Used for logging; can be `NULL` */ + /* Used for logging; can be `nullptr` */ bt_self_component *self_comp; /* Base virtual memory address. */ @@ -95,7 +95,7 @@ int bin_info_init(bt_logging_level log_level, bt_self_component *self_comp); * @param target_prefix Path to the root file system of the target * or NULL. * @returns Pointer to the new bin_info on success, - * NULL on failure. + * `nullptr` on failure. */ struct bin_info *bin_info_create(struct bt_fd_cache *fdc, const char *path, uint64_t low_addr, uint64_t memsz, bool is_pic, const char *debug_info_dir, diff --git a/src/plugins/lttng-utils/debug-info/debug-info.cpp b/src/plugins/lttng-utils/debug-info/debug-info.cpp index cca1892b..fb7dc8b3 100644 --- a/src/plugins/lttng-utils/debug-info/debug-info.cpp +++ b/src/plugins/lttng-utils/debug-info/debug-info.cpp @@ -150,8 +150,8 @@ static struct debug_info_source * debug_info_source_create_from_bin(struct bin_info *bin, uint64_t ip, bt_self_component *self_comp) { int ret; - struct debug_info_source *debug_info_src = NULL; - struct source_location *src_loc = NULL; + struct debug_info_source *debug_info_src = nullptr; + struct source_location *src_loc = nullptr; bt_logging_level log_level; BT_ASSERT(bin); @@ -216,7 +216,7 @@ end: error: debug_info_source_destroy(debug_info_src); - return NULL; + return nullptr; } static void proc_debug_info_sources_destroy(struct proc_debug_info_sources *proc_dbg_info_src) @@ -238,7 +238,7 @@ static void proc_debug_info_sources_destroy(struct proc_debug_info_sources *proc static struct proc_debug_info_sources *proc_debug_info_sources_create(void) { - struct proc_debug_info_sources *proc_dbg_info_src = NULL; + struct proc_debug_info_sources *proc_dbg_info_src = nullptr; proc_dbg_info_src = g_new0(struct proc_debug_info_sources, 1); if (!proc_dbg_info_src) { @@ -263,14 +263,14 @@ end: error: proc_debug_info_sources_destroy(proc_dbg_info_src); - return NULL; + return nullptr; } static struct proc_debug_info_sources *proc_debug_info_sources_ht_get_entry(GHashTable *ht, int64_t vpid) { gpointer key = g_new0(int64_t, 1); - struct proc_debug_info_sources *proc_dbg_info_src = NULL; + struct proc_debug_info_sources *proc_dbg_info_src = nullptr; if (!key) { goto end; @@ -292,7 +292,7 @@ static struct proc_debug_info_sources *proc_debug_info_sources_ht_get_entry(GHas g_hash_table_insert(ht, key, proc_dbg_info_src); /* Ownership passed to ht */ - key = NULL; + key = nullptr; end: g_free(key); return proc_dbg_info_src; @@ -313,7 +313,7 @@ static inline const bt_field *event_borrow_payload_field(const bt_event *event, static inline const bt_field *event_borrow_common_context_field(const bt_event *event, const char *field_name) { - const bt_field *event_common_ctx, *field = NULL; + const bt_field *event_common_ctx, *field = nullptr; event_common_ctx = bt_event_borrow_common_context_field_const(event); if (!event_common_ctx) { @@ -400,7 +400,7 @@ static struct debug_info_source * proc_debug_info_sources_get_entry(struct debug_info *debug_info, struct proc_debug_info_sources *proc_dbg_info_src, uint64_t ip) { - struct debug_info_source *debug_info_src = NULL; + struct debug_info_source *debug_info_src = nullptr; gpointer key = g_new0(uint64_t, 1); GHashTableIter iter; gpointer baddr, value; @@ -439,7 +439,7 @@ proc_debug_info_sources_get_entry(struct debug_info *debug_info, if (debug_info_src) { g_hash_table_insert(proc_dbg_info_src->ip_to_debug_info_src, key, debug_info_src); /* Ownership passed to ht. */ - key = NULL; + key = nullptr; } break; } @@ -452,7 +452,7 @@ end: static struct debug_info_source *debug_info_query(struct debug_info *debug_info, int64_t vpid, uint64_t ip) { - struct debug_info_source *dbg_info_src = NULL; + struct debug_info_source *dbg_info_src = nullptr; struct proc_debug_info_sources *proc_dbg_info_src; proc_dbg_info_src = @@ -504,7 +504,7 @@ end: return debug_info; error: g_free(debug_info); - return NULL; + return nullptr; } static void debug_info_destroy(struct debug_info *debug_info) @@ -539,7 +539,7 @@ static void handle_event_statedump_build_id(struct debug_info *debug_info, const { struct proc_debug_info_sources *proc_dbg_info_src; uint64_t build_id_len, baddr; - uint8_t *build_id = NULL; + uint8_t *build_id = nullptr; struct bin_info *bin; int64_t vpid; int ret = 0; @@ -592,10 +592,10 @@ end: static void handle_event_statedump_debug_link(struct debug_info *debug_info, const bt_event *event) { struct proc_debug_info_sources *proc_dbg_info_src; - struct bin_info *bin = NULL; + struct bin_info *bin = nullptr; int64_t vpid; uint64_t baddr; - const char *filename = NULL; + const char *filename = nullptr; uint32_t crc32; uint64_t crc_field_value; @@ -639,7 +639,7 @@ static void handle_bin_info_event(struct debug_info *debug_info, const bt_event uint64_t baddr, memsz; int64_t vpid; const char *path; - gpointer key = NULL; + gpointer key = nullptr; bool is_pic; event_get_payload_unsigned_integer_field_value(event, MEMSZ_FIELD_NAME, &memsz); @@ -702,7 +702,7 @@ static void handle_bin_info_event(struct debug_info *debug_info, const bt_event g_hash_table_insert(proc_dbg_info_src->baddr_to_bin_info, key, bin); /* Ownership passed to ht. */ - key = NULL; + key = nullptr; end: g_free(key); @@ -1136,12 +1136,12 @@ static bt_message *handle_event_message(struct debug_info_msg_iter *debug_it, const bt_stream *in_stream; const bt_stream *out_stream; bt_event_class *out_event_class; - bt_packet *out_packet = NULL; + bt_packet *out_packet = nullptr; bt_event *out_event; bt_logging_level log_level = debug_it->log_level; bt_self_component *self_comp = debug_it->self_comp; - bt_message *out_message = NULL; + bt_message *out_message = nullptr; /* Borrow the input event and its event class. */ const bt_event *in_event = bt_message_event_borrow_event_const(in_message); @@ -1240,7 +1240,7 @@ static bt_message *handle_stream_begin_message(struct debug_info_msg_iter *debug /* Create a duplicated output stream. */ out_stream = trace_ir_mapping_create_new_mapped_stream(debug_it->ir_maps, in_stream); if (!out_stream) { - out_message = NULL; + out_message = nullptr; goto error; } @@ -1260,7 +1260,7 @@ static bt_message *handle_stream_end_message(struct debug_info_msg_iter *debug_i const bt_message *in_message) { const bt_stream *in_stream; - bt_message *out_message = NULL; + bt_message *out_message = nullptr; bt_stream *out_stream; bt_logging_level log_level = debug_it->log_level; bt_self_component *self_comp = debug_it->self_comp; @@ -1293,7 +1293,7 @@ static bt_message *handle_packet_begin_message(struct debug_info_msg_iter *debug { bool has_default_clock_snapshot; const bt_clock_snapshot *cs; - bt_message *out_message = NULL; + bt_message *out_message = nullptr; bt_packet *out_packet; bt_logging_level log_level = debug_it->log_level; bt_self_component *self_comp = debug_it->self_comp; @@ -1336,7 +1336,7 @@ static bt_message *handle_packet_end_message(struct debug_info_msg_iter *debug_i bool has_default_clock_snapshot; const bt_clock_snapshot *cs; const bt_packet *in_packet; - bt_message *out_message = NULL; + bt_message *out_message = nullptr; bt_packet *out_packet; bt_logging_level log_level = debug_it->log_level; bt_self_component *self_comp = debug_it->self_comp; @@ -1393,7 +1393,7 @@ static bt_message *handle_discarded_events_message(struct debug_info_msg_iter *d bool has_default_clock_snapshots; uint64_t discarded_events, begin_cs_value, end_cs_value; bt_property_availability prop_avail; - bt_message *out_message = NULL; + bt_message *out_message = nullptr; bt_stream *out_stream; bt_logging_level log_level = debug_it->log_level; bt_self_component *self_comp = debug_it->self_comp; @@ -1445,7 +1445,7 @@ static bt_message *handle_discarded_packets_message(struct debug_info_msg_iter * const bt_stream *in_stream; uint64_t discarded_packets, begin_cs_value, end_cs_value; bt_property_availability prop_avail; - bt_message *out_message = NULL; + bt_message *out_message = nullptr; bt_stream *out_stream; bt_logging_level log_level = debug_it->log_level; bt_self_component *self_comp = debug_it->self_comp; @@ -1492,7 +1492,7 @@ error: static const bt_message *handle_message(struct debug_info_msg_iter *debug_it, const bt_message *in_message) { - bt_message *out_message = NULL; + bt_message *out_message = nullptr; switch (bt_message_get_type(in_message)) { case BT_MESSAGE_TYPE_EVENT: @@ -1545,7 +1545,7 @@ init_from_params(struct debug_info_component *debug_info_component, const bt_val bt_component_class_initialize_method_status status; bt_logging_level log_level = debug_info_component->log_level; enum bt_param_validation_status validation_status; - gchar *validate_error = NULL; + gchar *validate_error = nullptr; validation_status = bt_param_validation_validate(params, debug_info_params, &validate_error); if (validation_status == BT_PARAM_VALIDATION_STATUS_MEMORY_ERROR) { @@ -1570,14 +1570,14 @@ init_from_params(struct debug_info_component *debug_info_component, const bt_val if (value) { debug_info_component->arg_debug_dir = g_strdup(bt_value_string_get(value)); } else { - debug_info_component->arg_debug_dir = NULL; + debug_info_component->arg_debug_dir = nullptr; } value = bt_value_map_borrow_entry_value_const(params, "target-prefix"); if (value) { debug_info_component->arg_target_prefix = g_strdup(bt_value_string_get(value)); } else { - debug_info_component->arg_target_prefix = NULL; + debug_info_component->arg_target_prefix = nullptr; } value = bt_value_map_borrow_entry_value_const(params, "full-path"); @@ -1623,13 +1623,15 @@ debug_info_comp_init(bt_self_component_filter *self_comp_flt, debug_info_comp->self_comp_filter = self_comp_flt; bt_self_component_set_data(self_comp, debug_info_comp); - add_port_status = bt_self_component_filter_add_input_port(self_comp_flt, "in", NULL, NULL); + add_port_status = + bt_self_component_filter_add_input_port(self_comp_flt, "in", nullptr, nullptr); if (add_port_status != BT_SELF_COMPONENT_ADD_PORT_STATUS_OK) { status = static_cast(add_port_status); goto error; } - add_port_status = bt_self_component_filter_add_output_port(self_comp_flt, "out", NULL, NULL); + add_port_status = + bt_self_component_filter_add_output_port(self_comp_flt, "out", nullptr, nullptr); if (add_port_status != BT_SELF_COMPONENT_ADD_PORT_STATUS_OK) { status = static_cast(add_port_status); goto error; @@ -1648,7 +1650,7 @@ debug_info_comp_init(bt_self_component_filter *self_comp_flt, error: destroy_debug_info_comp(debug_info_comp); - bt_self_component_set_data(self_comp, NULL); + bt_self_component_set_data(self_comp, nullptr); if (status == BT_COMPONENT_CLASS_INITIALIZE_METHOD_STATUS_OK) { status = BT_COMPONENT_CLASS_INITIALIZE_METHOD_STATUS_ERROR; @@ -1673,12 +1675,12 @@ bt_message_iterator_class_next_method_status debug_info_msg_iter_next(bt_self_message_iterator *self_msg_iter, const bt_message_array_const msgs, uint64_t capacity, uint64_t *count) { - bt_message_iterator *upstream_iterator = NULL; + bt_message_iterator *upstream_iterator = nullptr; bt_message_iterator_next_status upstream_iterator_ret_status; struct debug_info_msg_iter *debug_info_msg_iter; - struct debug_info_component *debug_info = NULL; + struct debug_info_component *debug_info = nullptr; bt_message_iterator_class_next_method_status status; - bt_self_component *self_comp = NULL; + bt_self_component *self_comp = nullptr; bt_message_array_const input_msgs; const bt_message *out_message; uint64_t curr_msg_idx, i; @@ -1787,9 +1789,9 @@ debug_info_msg_iter_init(bt_self_message_iterator *self_msg_iter, { bt_message_iterator_class_initialize_method_status status; bt_message_iterator_create_from_message_iterator_status msg_iter_status; - struct bt_self_component_port_input *input_port = NULL; - bt_message_iterator *upstream_iterator = NULL; - struct debug_info_msg_iter *debug_info_msg_iter = NULL; + struct bt_self_component_port_input *input_port = nullptr; + bt_message_iterator *upstream_iterator = nullptr; + struct debug_info_msg_iter *debug_info_msg_iter = nullptr; gchar *debug_info_field_name; int ret; bt_self_component *self_comp = bt_self_message_iterator_borrow_component(self_msg_iter); @@ -1827,8 +1829,9 @@ debug_info_msg_iter_init(bt_self_message_iterator *self_msg_iter, BT_MESSAGE_ITERATOR_MOVE_REF(debug_info_msg_iter->msg_iter, upstream_iterator); /* Create hashtable that will contain debug info mapping. */ - debug_info_msg_iter->debug_info_map = g_hash_table_new_full( - g_direct_hash, g_direct_equal, (GDestroyNotify) NULL, (GDestroyNotify) debug_info_destroy); + debug_info_msg_iter->debug_info_map = + g_hash_table_new_full(g_direct_hash, g_direct_equal, (GDestroyNotify) nullptr, + (GDestroyNotify) debug_info_destroy); if (!debug_info_msg_iter->debug_info_map) { status = BT_MESSAGE_ITERATOR_CLASS_INITIALIZE_METHOD_STATUS_MEMORY_ERROR; goto error; diff --git a/src/plugins/lttng-utils/debug-info/dwarf.cpp b/src/plugins/lttng-utils/debug-info/dwarf.cpp index 2fd77ba3..17ec794b 100644 --- a/src/plugins/lttng-utils/debug-info/dwarf.cpp +++ b/src/plugins/lttng-utils/debug-info/dwarf.cpp @@ -27,7 +27,7 @@ struct bt_dwarf_cu *bt_dwarf_cu_create(Dwarf *dwarf_info) return cu; error: - return NULL; + return nullptr; } void bt_dwarf_cu_destroy(struct bt_dwarf_cu *cu) @@ -46,8 +46,8 @@ int bt_dwarf_cu_next(struct bt_dwarf_cu *cu) goto end; } - ret = dwarf_nextcu(cu->dwarf_info, cu->next_offset, &next_offset, &cu_header_size, NULL, NULL, - NULL); + ret = dwarf_nextcu(cu->dwarf_info, cu->next_offset, &next_offset, &cu_header_size, nullptr, + nullptr, nullptr); if (ret) { /* ret is -1 on error, 1 if no next CU. */ goto end; @@ -63,8 +63,8 @@ end: struct bt_dwarf_die *bt_dwarf_die_create(struct bt_dwarf_cu *cu) { - Dwarf_Die *dwarf_die = NULL; - struct bt_dwarf_die *die = NULL; + Dwarf_Die *dwarf_die = nullptr; + struct bt_dwarf_die *die = nullptr; if (!cu) { goto error; @@ -94,7 +94,7 @@ struct bt_dwarf_die *bt_dwarf_die_create(struct bt_dwarf_cu *cu) error: g_free(dwarf_die); g_free(die); - return NULL; + return nullptr; } void bt_dwarf_die_destroy(struct bt_dwarf_die *die) @@ -115,7 +115,7 @@ int bt_dwarf_die_has_children(struct bt_dwarf_die *die) int bt_dwarf_die_child(struct bt_dwarf_die *die) { int ret; - Dwarf_Die *child_die = NULL; + Dwarf_Die *child_die = nullptr; if (!die) { ret = -1; @@ -147,7 +147,7 @@ error: int bt_dwarf_die_next(struct bt_dwarf_die *die) { int ret; - Dwarf_Die *next_die = NULL; + Dwarf_Die *next_die = nullptr; if (!die) { ret = -1; @@ -234,10 +234,10 @@ int bt_dwarf_die_get_call_file(struct bt_dwarf_die *die, char **filename) { int ret; Dwarf_Sword file_no; - const char *_filename = NULL; - Dwarf_Files *src_files = NULL; - Dwarf_Attribute *file_attr = NULL; - struct bt_dwarf_die *cu_die = NULL; + const char *_filename = nullptr; + Dwarf_Files *src_files = nullptr; + Dwarf_Attribute *file_attr = nullptr; + struct bt_dwarf_die *cu_die = nullptr; if (!die || !filename) { goto error; @@ -263,12 +263,12 @@ int bt_dwarf_die_get_call_file(struct bt_dwarf_die *die, char **filename) goto error; } - ret = dwarf_getsrcfiles(cu_die->dwarf_die, &src_files, NULL); + ret = dwarf_getsrcfiles(cu_die->dwarf_die, &src_files, nullptr); if (ret) { goto error; } - _filename = dwarf_filesrc(src_files, file_no, NULL, NULL); + _filename = dwarf_filesrc(src_files, file_no, nullptr, nullptr); if (!_filename) { goto error; } @@ -290,7 +290,7 @@ error: int bt_dwarf_die_get_call_line(struct bt_dwarf_die *die, uint64_t *line_no) { int ret = 0; - Dwarf_Attribute *line_attr = NULL; + Dwarf_Attribute *line_attr = nullptr; uint64_t _line_no; if (!die || !line_no) { diff --git a/src/plugins/lttng-utils/debug-info/dwarf.hpp b/src/plugins/lttng-utils/debug-info/dwarf.hpp index be955c7a..3a909f98 100644 --- a/src/plugins/lttng-utils/debug-info/dwarf.hpp +++ b/src/plugins/lttng-utils/debug-info/dwarf.hpp @@ -59,7 +59,7 @@ struct bt_dwarf_die * * @param dwarf_info Dwarf instance * @returns Pointer to the new bt_dwarf_cu on success, - * NULL on failure. + * `nullptr` on failure. */ struct bt_dwarf_cu *bt_dwarf_cu_create(Dwarf *dwarf_info); @@ -88,7 +88,7 @@ int bt_dwarf_cu_next(struct bt_dwarf_cu *cu); * * @param cu bt_dwarf_cu instance * @returns Pointer to the new bt_dwarf_die on success, - * NULL on failure. + * `nullptr` on failure. */ struct bt_dwarf_die *bt_dwarf_die_create(struct bt_dwarf_cu *cu); diff --git a/src/plugins/lttng-utils/debug-info/trace-ir-data-copy.cpp b/src/plugins/lttng-utils/debug-info/trace-ir-data-copy.cpp index 95de960d..cfd44569 100644 --- a/src/plugins/lttng-utils/debug-info/trace-ir-data-copy.cpp +++ b/src/plugins/lttng-utils/debug-info/trace-ir-data-copy.cpp @@ -64,7 +64,7 @@ enum debug_info_trace_ir_mapping_status copy_trace_content(const bt_trace *in_tr env_field_count = bt_trace_get_environment_entry_count(in_trace); for (i = 0; i < env_field_count; i++) { const char *value_name; - const bt_value *value = NULL; + const bt_value *value = nullptr; bt_trace_set_environment_entry_status set_env_status; bt_trace_borrow_environment_entry_by_index_const(in_trace, i, &value_name, &value); diff --git a/src/plugins/lttng-utils/debug-info/trace-ir-mapping.cpp b/src/plugins/lttng-utils/debug-info/trace-ir-mapping.cpp index 3e169960..0e6116a5 100644 --- a/src/plugins/lttng-utils/debug-info/trace-ir-mapping.cpp +++ b/src/plugins/lttng-utils/debug-info/trace-ir-mapping.cpp @@ -90,7 +90,7 @@ static bt_trace *create_new_mapped_trace(struct trace_ir_maps *ir_maps, const bt metadata_maps->output_trace_class = create_new_mapped_trace_class(ir_maps, in_trace_class); if (!metadata_maps->output_trace_class) { BT_COMP_LOGE_APPEND_CAUSE(self_comp, "Error create output trace class"); - out_trace = NULL; + out_trace = nullptr; goto end; } } @@ -179,7 +179,7 @@ trace_ir_mapping_create_new_mapped_stream_class(struct trace_ir_maps *ir_maps, goto end; error: - out_stream_class = NULL; + out_stream_class = nullptr; end: return out_stream_class; } @@ -202,7 +202,7 @@ bt_stream *trace_ir_mapping_create_new_mapped_stream(struct trace_ir_maps *ir_ma const bt_stream_class *in_stream_class; const bt_trace *in_trace; bt_stream_class *out_stream_class; - bt_stream *out_stream = NULL; + bt_stream *out_stream = nullptr; BT_ASSERT(ir_maps); BT_ASSERT(in_stream); @@ -262,7 +262,7 @@ bt_stream *trace_ir_mapping_create_new_mapped_stream(struct trace_ir_maps *ir_ma goto end; error: - out_stream = NULL; + out_stream = nullptr; end: return out_stream; } @@ -341,7 +341,7 @@ bt_event_class *trace_ir_mapping_create_new_mapped_event_class(struct trace_ir_m goto end; error: - out_event_class = NULL; + out_event_class = nullptr; end: return out_event_class; } @@ -418,7 +418,7 @@ bt_packet *trace_ir_mapping_create_new_mapped_packet(struct trace_ir_maps *ir_ma goto end; error: - out_packet = NULL; + out_packet = nullptr; end: return out_packet; } @@ -504,9 +504,9 @@ struct trace_ir_data_maps *trace_ir_data_maps_create(struct trace_ir_maps *ir_ma d_maps->input_trace = in_trace; /* Create the hashtables used to map data objects. */ - d_maps->stream_map = g_hash_table_new_full(g_direct_hash, g_direct_equal, NULL, + d_maps->stream_map = g_hash_table_new_full(g_direct_hash, g_direct_equal, nullptr, (GDestroyNotify) bt_stream_put_ref); - d_maps->packet_map = g_hash_table_new_full(g_direct_hash, g_direct_equal, NULL, + d_maps->packet_map = g_hash_table_new_full(g_direct_hash, g_direct_equal, nullptr, (GDestroyNotify) bt_packet_put_ref); add_listener_status = bt_trace_add_destruction_listener( @@ -544,13 +544,13 @@ struct trace_ir_metadata_maps *trace_ir_metadata_maps_create(struct trace_ir_map } /* Create the hashtables used to map metadata objects. */ - md_maps->stream_class_map = g_hash_table_new_full(g_direct_hash, g_direct_equal, NULL, + md_maps->stream_class_map = g_hash_table_new_full(g_direct_hash, g_direct_equal, nullptr, (GDestroyNotify) bt_stream_class_put_ref); - md_maps->event_class_map = g_hash_table_new_full(g_direct_hash, g_direct_equal, NULL, + md_maps->event_class_map = g_hash_table_new_full(g_direct_hash, g_direct_equal, nullptr, (GDestroyNotify) bt_event_class_put_ref); - md_maps->field_class_map = g_hash_table_new_full(g_direct_hash, g_direct_equal, NULL, + md_maps->field_class_map = g_hash_table_new_full(g_direct_hash, g_direct_equal, nullptr, (GDestroyNotify) bt_field_class_put_ref); - md_maps->clock_class_map = g_hash_table_new_full(g_direct_hash, g_direct_equal, NULL, + md_maps->clock_class_map = g_hash_table_new_full(g_direct_hash, g_direct_equal, nullptr, (GDestroyNotify) bt_clock_class_put_ref); add_listener_status = @@ -654,12 +654,12 @@ void trace_ir_maps_destroy(struct trace_ir_maps *maps) if (maps->data_maps) { g_hash_table_destroy(maps->data_maps); - maps->data_maps = NULL; + maps->data_maps = nullptr; } if (maps->metadata_maps) { g_hash_table_destroy(maps->metadata_maps); - maps->metadata_maps = NULL; + maps->metadata_maps = nullptr; } g_free(maps); @@ -687,17 +687,18 @@ struct trace_ir_maps *trace_ir_maps_create(bt_self_component *self_comp, ir_maps->self_comp = self_comp; - ir_maps->data_maps = g_hash_table_new_full(g_direct_hash, g_direct_equal, (GDestroyNotify) NULL, - (GDestroyNotify) trace_ir_data_maps_destroy); + ir_maps->data_maps = + g_hash_table_new_full(g_direct_hash, g_direct_equal, (GDestroyNotify) nullptr, + (GDestroyNotify) trace_ir_data_maps_destroy); ir_maps->metadata_maps = - g_hash_table_new_full(g_direct_hash, g_direct_equal, (GDestroyNotify) NULL, + g_hash_table_new_full(g_direct_hash, g_direct_equal, (GDestroyNotify) nullptr, (GDestroyNotify) trace_ir_metadata_maps_destroy); goto end; error: trace_ir_maps_destroy(ir_maps); - ir_maps = NULL; + ir_maps = nullptr; end: return ir_maps; } diff --git a/src/plugins/lttng-utils/debug-info/trace-ir-metadata-copy.cpp b/src/plugins/lttng-utils/debug-info/trace-ir-metadata-copy.cpp index 00712174..792b56b7 100644 --- a/src/plugins/lttng-utils/debug-info/trace-ir-metadata-copy.cpp +++ b/src/plugins/lttng-utils/debug-info/trace-ir-metadata-copy.cpp @@ -507,8 +507,8 @@ enum debug_info_trace_ir_mapping_status copy_event_common_context_field_class_co const bt_field_class *in_field_class, bt_field_class *out_field_class) { enum debug_info_trace_ir_mapping_status status; - bt_field_class *debug_field_class = NULL, *bin_field_class = NULL, *func_field_class = NULL, - *src_field_class = NULL; + bt_field_class *debug_field_class = nullptr, *bin_field_class = nullptr, + *func_field_class = nullptr, *src_field_class = nullptr; bt_logging_level log_level = md_maps->log_level; bt_self_component *self_comp = md_maps->self_comp; diff --git a/src/plugins/lttng-utils/debug-info/trace-ir-metadata-field-class-copy.cpp b/src/plugins/lttng-utils/debug-info/trace-ir-metadata-field-class-copy.cpp index 09e5aad3..3965674b 100644 --- a/src/plugins/lttng-utils/debug-info/trace-ir-metadata-field-class-copy.cpp +++ b/src/plugins/lttng-utils/debug-info/trace-ir-metadata-field-class-copy.cpp @@ -397,7 +397,7 @@ field_class_variant_copy(struct trace_ir_metadata_maps *md_maps, { bt_self_component *self_comp = md_maps->self_comp; enum debug_info_trace_ir_mapping_status status; - bt_field_class *out_tag_field_class = NULL; + bt_field_class *out_tag_field_class = nullptr; uint64_t i, variant_option_count; bt_field_class_type fc_type = bt_field_class_get_type(in_field_class); @@ -633,7 +633,7 @@ bt_field_class *create_field_class_copy_internal(struct trace_ir_metadata_maps * { bt_self_component *self_comp = md_maps->self_comp; enum debug_info_trace_ir_mapping_status status; - bt_field_class *out_field_class = NULL; + bt_field_class *out_field_class = nullptr; bt_field_class_type fc_type = bt_field_class_get_type(in_field_class); BT_COMP_LOGD("Creating bare field class based on field class: in-fc-addr=%p", in_field_class); @@ -678,7 +678,7 @@ bt_field_class *create_field_class_copy_internal(struct trace_ir_metadata_maps * bt_field_class *out_elem_fc = copy_field_class_array_element(md_maps, in_elem_fc); if (!out_elem_fc) { - out_field_class = NULL; + out_field_class = nullptr; goto error; } @@ -697,7 +697,7 @@ bt_field_class *create_field_class_copy_internal(struct trace_ir_metadata_maps * bt_field_class *out_elem_fc = copy_field_class_array_element(md_maps, in_elem_fc); if (!out_elem_fc) { - out_field_class = NULL; + out_field_class = nullptr; goto error; } @@ -779,7 +779,7 @@ bt_field_class *create_field_class_copy_internal(struct trace_ir_metadata_maps * } } } else if (bt_field_class_type_is(fc_type, BT_FIELD_CLASS_TYPE_VARIANT)) { - bt_field_class *out_sel_fc = NULL; + bt_field_class *out_sel_fc = nullptr; if (bt_field_class_type_is(fc_type, BT_FIELD_CLASS_TYPE_VARIANT_WITH_SELECTOR_FIELD)) { const bt_field_class *in_sel_fc; -- 2.34.1