diff options
author | João Valverde <joao.valverde@tecnico.ulisboa.pt> | 2021-02-27 03:38:15 +0000 |
---|---|---|
committer | Wireshark GitLab Utility <gerald+gitlab-utility@wireshark.org> | 2021-05-24 01:13:19 +0000 |
commit | 9ba97d12d6b1b2e6e06311375c07ce975fc08205 (patch) | |
tree | 33343e07bc84b8d930546c4e91a987712edb021b /wiretap/merge.c | |
parent | de00cdd5129c30fdd138fe49da2003a5d3f74d8f (diff) |
Add ws_debug() and use it
Replace most instances of ws_debug_printf() except in
epan/dissectors and dissector plugins.
Some replacements use printf(), some use ws_debug(), and
some were removed because they were dead or judged to be
temporary.
Diffstat (limited to 'wiretap/merge.c')
-rw-r--r-- | wiretap/merge.c | 85 |
1 files changed, 41 insertions, 44 deletions
diff --git a/wiretap/merge.c b/wiretap/merge.c index 283cd91717..3efb5b4ebc 100644 --- a/wiretap/merge.c +++ b/wiretap/merge.c @@ -14,6 +14,8 @@ #include "config.h" +#define G_LOG_DOMAIN "wiretap" + #include <stdlib.h> #include <errno.h> @@ -28,14 +30,9 @@ #include <wsutil/filesystem.h> #include "wsutil/os_version_info.h" +#include <wsutil/wslog.h> -#if 0 -#define merge_debug(...) g_warning(__VA_ARGS__) -#else -#define merge_debug(...) -#endif - static const char* idb_merge_mode_strings[] = { /* IDB_MERGE_MODE_NONE */ @@ -472,42 +469,42 @@ is_duplicate_idb(const wtap_block_t idb1, const wtap_block_t idb2) idb1_mand = (wtapng_if_descr_mandatory_t*)wtap_block_get_mandatory_data(idb1); idb2_mand = (wtapng_if_descr_mandatory_t*)wtap_block_get_mandatory_data(idb2); - merge_debug("merge::is_duplicate_idb() called"); - merge_debug("idb1_mand->wtap_encap == idb2_mand->wtap_encap: %s", + ws_debug("merge::is_duplicate_idb() called"); + ws_debug("idb1_mand->wtap_encap == idb2_mand->wtap_encap: %s", (idb1_mand->wtap_encap == idb2_mand->wtap_encap) ? "TRUE":"FALSE"); if (idb1_mand->wtap_encap != idb2_mand->wtap_encap) { /* Clearly not the same interface. */ - merge_debug("merge::is_duplicate_idb() returning FALSE"); + ws_debug("merge::is_duplicate_idb() returning FALSE"); return FALSE; } - merge_debug("idb1_mand->time_units_per_second == idb2_mand->time_units_per_second: %s", + ws_debug("idb1_mand->time_units_per_second == idb2_mand->time_units_per_second: %s", (idb1_mand->time_units_per_second == idb2_mand->time_units_per_second) ? "TRUE":"FALSE"); if (idb1_mand->time_units_per_second != idb2_mand->time_units_per_second) { /* * Probably not the same interface, and we can't combine them * in any case. */ - merge_debug("merge::is_duplicate_idb() returning FALSE"); + ws_debug("merge::is_duplicate_idb() returning FALSE"); return FALSE; } - merge_debug("idb1_mand->tsprecision == idb2_mand->tsprecision: %s", + ws_debug("idb1_mand->tsprecision == idb2_mand->tsprecision: %s", (idb1_mand->tsprecision == idb2_mand->tsprecision) ? "TRUE":"FALSE"); if (idb1_mand->tsprecision != idb2_mand->tsprecision) { /* * Probably not the same interface, and we can't combine them * in any case. */ - merge_debug("merge::is_duplicate_idb() returning FALSE"); + ws_debug("merge::is_duplicate_idb() returning FALSE"); return FALSE; } /* XXX: should snaplen not be compared? */ - merge_debug("idb1_mand->snap_len == idb2_mand->snap_len: %s", + ws_debug("idb1_mand->snap_len == idb2_mand->snap_len: %s", (idb1_mand->snap_len == idb2_mand->snap_len) ? "TRUE":"FALSE"); if (idb1_mand->snap_len != idb2_mand->snap_len) { - merge_debug("merge::is_duplicate_idb() returning FALSE"); + ws_debug("merge::is_duplicate_idb() returning FALSE"); return FALSE; } @@ -515,10 +512,10 @@ is_duplicate_idb(const wtap_block_t idb1, const wtap_block_t idb2) have_idb1_value = (wtap_block_get_uint64_option_value(idb1, OPT_IDB_SPEED, &idb1_if_speed) == WTAP_OPTTYPE_SUCCESS); have_idb2_value = (wtap_block_get_uint64_option_value(idb2, OPT_IDB_SPEED, &idb2_if_speed) == WTAP_OPTTYPE_SUCCESS); if (have_idb1_value && have_idb2_value) { - merge_debug("idb1_if_speed == idb2_if_speed: %s", + ws_debug("idb1_if_speed == idb2_if_speed: %s", (idb1_if_speed == idb2_if_speed) ? "TRUE":"FALSE"); if (idb1_if_speed != idb2_if_speed) { - merge_debug("merge::is_duplicate_idb() returning FALSE"); + ws_debug("merge::is_duplicate_idb() returning FALSE"); return FALSE; } } @@ -527,10 +524,10 @@ is_duplicate_idb(const wtap_block_t idb1, const wtap_block_t idb2) have_idb1_value = (wtap_block_get_uint8_option_value(idb1, OPT_IDB_TSRESOL, &idb1_if_tsresol) == WTAP_OPTTYPE_SUCCESS); have_idb2_value = (wtap_block_get_uint8_option_value(idb2, OPT_IDB_TSRESOL, &idb2_if_tsresol) == WTAP_OPTTYPE_SUCCESS); if (have_idb1_value && have_idb2_value) { - merge_debug("idb1_if_tsresol == idb2_if_tsresol: %s", + ws_debug("idb1_if_tsresol == idb2_if_tsresol: %s", (idb1_if_tsresol == idb2_if_tsresol) ? "TRUE":"FALSE"); if (idb1_if_tsresol != idb2_if_tsresol) { - merge_debug("merge::is_duplicate_idb() returning FALSE"); + ws_debug("merge::is_duplicate_idb() returning FALSE"); return FALSE; } } @@ -539,10 +536,10 @@ is_duplicate_idb(const wtap_block_t idb1, const wtap_block_t idb2) have_idb1_value = (wtap_block_get_uint8_option_value(idb1, OPT_IDB_FCSLEN, &idb1_if_fcslen) == WTAP_OPTTYPE_SUCCESS); have_idb2_value = (wtap_block_get_uint8_option_value(idb2, OPT_IDB_FCSLEN, &idb2_if_fcslen) == WTAP_OPTTYPE_SUCCESS); if (have_idb1_value && have_idb2_value) { - merge_debug("idb1_if_fcslen == idb2_if_fcslen: %s", + ws_debug("idb1_if_fcslen == idb2_if_fcslen: %s", (idb1_if_fcslen == idb2_if_fcslen) ? "TRUE":"FALSE"); if (idb1_if_fcslen == idb2_if_fcslen) { - merge_debug("merge::is_duplicate_idb() returning FALSE"); + ws_debug("merge::is_duplicate_idb() returning FALSE"); return FALSE; } } @@ -557,10 +554,10 @@ is_duplicate_idb(const wtap_block_t idb1, const wtap_block_t idb2) have_idb1_value = (wtap_block_get_nth_string_option_value(idb1, OPT_COMMENT, 0, &idb1_opt_comment) == WTAP_OPTTYPE_SUCCESS); have_idb2_value = (wtap_block_get_nth_string_option_value(idb2, OPT_COMMENT, 0, &idb2_opt_comment) == WTAP_OPTTYPE_SUCCESS); if (have_idb1_value && have_idb2_value) { - merge_debug("g_strcmp0(idb1_opt_comment, idb2_opt_comment) == 0: %s", + ws_debug("g_strcmp0(idb1_opt_comment, idb2_opt_comment) == 0: %s", (g_strcmp0(idb1_opt_comment, idb2_opt_comment) == 0) ? "TRUE":"FALSE"); if (g_strcmp0(idb1_opt_comment, idb2_opt_comment) != 0) { - merge_debug("merge::is_duplicate_idb() returning FALSE"); + ws_debug("merge::is_duplicate_idb() returning FALSE"); return FALSE; } } @@ -569,10 +566,10 @@ is_duplicate_idb(const wtap_block_t idb1, const wtap_block_t idb2) have_idb1_value = (wtap_block_get_string_option_value(idb1, OPT_IDB_NAME, &idb1_if_name) == WTAP_OPTTYPE_SUCCESS); have_idb2_value = (wtap_block_get_string_option_value(idb2, OPT_IDB_NAME, &idb2_if_name) == WTAP_OPTTYPE_SUCCESS); if (have_idb1_value && have_idb2_value) { - merge_debug("g_strcmp0(idb1_if_name, idb2_if_name) == 0: %s", + ws_debug("g_strcmp0(idb1_if_name, idb2_if_name) == 0: %s", (g_strcmp0(idb1_if_name, idb2_if_name) == 0) ? "TRUE":"FALSE"); if (g_strcmp0(idb1_if_name, idb2_if_name) != 0) { - merge_debug("merge::is_duplicate_idb() returning FALSE"); + ws_debug("merge::is_duplicate_idb() returning FALSE"); return FALSE; } } @@ -581,10 +578,10 @@ is_duplicate_idb(const wtap_block_t idb1, const wtap_block_t idb2) have_idb1_value = (wtap_block_get_string_option_value(idb1, OPT_IDB_DESCR, &idb1_if_description) == WTAP_OPTTYPE_SUCCESS); have_idb2_value = (wtap_block_get_string_option_value(idb2, OPT_IDB_DESCR, &idb2_if_description) == WTAP_OPTTYPE_SUCCESS); if (have_idb1_value && have_idb2_value) { - merge_debug("g_strcmp0(idb1_if_description, idb2_if_description) == 0: %s", + ws_debug("g_strcmp0(idb1_if_description, idb2_if_description) == 0: %s", (g_strcmp0(idb1_if_description, idb2_if_description) == 0) ? "TRUE":"FALSE"); if (g_strcmp0(idb1_if_description, idb2_if_description) != 0) { - merge_debug("merge::is_duplicate_idb() returning FALSE"); + ws_debug("merge::is_duplicate_idb() returning FALSE"); return FALSE; } } @@ -593,10 +590,10 @@ is_duplicate_idb(const wtap_block_t idb1, const wtap_block_t idb2) have_idb1_value = (wtap_block_get_string_option_value(idb1, OPT_IDB_HARDWARE, &idb1_if_hardware) == WTAP_OPTTYPE_SUCCESS); have_idb2_value = (wtap_block_get_string_option_value(idb2, OPT_IDB_HARDWARE, &idb2_if_hardware) == WTAP_OPTTYPE_SUCCESS); if (have_idb1_value && have_idb2_value) { - merge_debug("g_strcmp0(idb1_if_hardware, idb2_if_hardware) == 0: %s", + ws_debug("g_strcmp0(idb1_if_hardware, idb2_if_hardware) == 0: %s", (g_strcmp0(idb1_if_hardware, idb2_if_hardware) == 0) ? "TRUE":"FALSE"); if (g_strcmp0(idb1_if_hardware, idb2_if_hardware) != 0) { - merge_debug("merge::is_duplicate_idb() returning FALSE"); + ws_debug("merge::is_duplicate_idb() returning FALSE"); return FALSE; } } @@ -605,16 +602,16 @@ is_duplicate_idb(const wtap_block_t idb1, const wtap_block_t idb2) have_idb1_value = (wtap_block_get_string_option_value(idb1, OPT_IDB_OS, &idb1_if_os) == WTAP_OPTTYPE_SUCCESS); have_idb2_value = (wtap_block_get_string_option_value(idb2, OPT_IDB_OS, &idb2_if_os) == WTAP_OPTTYPE_SUCCESS); if (have_idb1_value && have_idb2_value) { - merge_debug("g_strcmp0(idb1_if_os, idb2_if_os) == 0: %s", + ws_debug("g_strcmp0(idb1_if_os, idb2_if_os) == 0: %s", (g_strcmp0(idb1_if_os, idb2_if_os) == 0) ? "TRUE":"FALSE"); if (g_strcmp0(idb1_if_os, idb2_if_os) != 0) { - merge_debug("merge::is_duplicate_idb() returning FALSE"); + ws_debug("merge::is_duplicate_idb() returning FALSE"); return FALSE; } } /* does not compare filters nor interface statistics */ - merge_debug("merge::is_duplicate_idb() returning TRUE"); + ws_debug("merge::is_duplicate_idb() returning TRUE"); return TRUE; } @@ -645,7 +642,7 @@ all_idbs_are_duplicates(const merge_in_file_t *in_files, const guint in_file_cou other_idb_list_size = other_idb_list->interface_data->len; if (other_idb_list_size != first_idb_list_size) { - merge_debug("merge::all_idbs_are_duplicates: sizes of IDB lists don't match: first=%u, other=%u", + ws_debug("merge::all_idbs_are_duplicates: sizes of IDB lists don't match: first=%u, other=%u", first_idb_list_size, other_idb_list_size); g_free(other_idb_list); g_free(first_idb_list); @@ -657,7 +654,7 @@ all_idbs_are_duplicates(const merge_in_file_t *in_files, const guint in_file_cou other_file_idb = g_array_index(other_idb_list->interface_data, wtap_block_t, j); if (!is_duplicate_idb(first_file_idb, other_file_idb)) { - merge_debug("merge::all_idbs_are_duplicates: IDBs at index %d do not match, returning FALSE", j); + ws_debug("merge::all_idbs_are_duplicates: IDBs at index %d do not match, returning FALSE", j); g_free(other_idb_list); g_free(first_idb_list); return FALSE; @@ -666,7 +663,7 @@ all_idbs_are_duplicates(const merge_in_file_t *in_files, const guint in_file_cou g_free(other_idb_list); } - merge_debug("merge::all_idbs_are_duplicates: returning TRUE"); + ws_debug("merge::all_idbs_are_duplicates: returning TRUE"); g_free(first_idb_list); @@ -750,7 +747,7 @@ generate_merged_idbs(merge_in_file_t *in_files, const guint in_file_count, const if (mode == IDB_MERGE_MODE_ALL_SAME && all_idbs_are_duplicates(in_files, in_file_count)) { guint num_idbs; - merge_debug("merge::generate_merged_idbs: mode ALL set and all IDBs are duplicates"); + ws_debug("merge::generate_merged_idbs: mode ALL set and all IDBs are duplicates"); /* they're all the same, so just get the first file's IDBs */ input_file_idb_list = wtap_file_get_idb_info(in_files[0].wth); @@ -785,7 +782,7 @@ generate_merged_idbs(merge_in_file_t *in_files, const guint in_file_count, const if (mode == IDB_MERGE_MODE_ANY_SAME && find_duplicate_idb(input_file_idb, merged_idb_list, &merged_index)) { - merge_debug("merge::generate_merged_idbs: mode ANY set and found a duplicate"); + ws_debug("merge::generate_merged_idbs: mode ANY set and found a duplicate"); /* * It's the same as a previous IDB, so we're going to "merge" * them into one by adding a map from its old IDB index to the new @@ -794,7 +791,7 @@ generate_merged_idbs(merge_in_file_t *in_files, const guint in_file_count, const add_idb_index_map(&in_files[i], itf_count, merged_index); } else { - merge_debug("merge::generate_merged_idbs: mode NONE set or did not find a duplicate"); + ws_debug("merge::generate_merged_idbs: mode NONE set or did not find a duplicate"); /* * This IDB does not match a previous (or we want to save all IDBs), * so add the IDB to the merge file, and add a map of the indices. @@ -825,7 +822,7 @@ map_rec_interface_id(wtap_rec *rec, const merge_in_file_t *in_file) if (current_interface_id >= in_file->idb_index_map->len) { /* this shouldn't happen, but in a malformed input file it could */ - merge_debug("merge::map_rec_interface_id: current_interface_id (%u) >= in_file->idb_index_map->len (%u) (ERROR?)", + ws_debug("merge::map_rec_interface_id: current_interface_id (%u) >= in_file->idb_index_map->len (%u) (ERROR?)", current_interface_id, in_file->idb_index_map->len); return FALSE; } @@ -1013,12 +1010,12 @@ merge_files_common(const gchar* out_filename, /* normal output mode */ /* if a callback was given, it has to have a callback function ptr */ g_assert((cb != NULL) ? (cb->callback_func != NULL) : TRUE); - merge_debug("merge_files: begin"); + ws_debug("merge_files: begin"); /* open the input files */ if (!merge_open_in_files(in_file_count, in_filenames, &in_files, cb, err, err_info, err_fileno)) { - merge_debug("merge_files: merge_open_in_files() failed with err=%d", *err); + ws_debug("merge_files: merge_open_in_files() failed with err=%d", *err); *err_framenum = 0; return MERGE_ERR_CANT_OPEN_INFILE; } @@ -1036,7 +1033,7 @@ merge_files_common(const gchar* out_filename, /* normal output mode */ * whether we can merge IDBs into one or not. */ frame_type = merge_select_frame_type(in_file_count, in_files); - merge_debug("merge_files: got frame_type=%d", frame_type); + ws_debug("merge_files: got frame_type=%d", frame_type); if (cb) cb->callback_func(MERGE_EVENT_FRAME_TYPE_SELECTED, frame_type, in_files, in_file_count, cb->data); @@ -1055,10 +1052,10 @@ merge_files_common(const gchar* out_filename, /* normal output mode */ if (wtap_file_type_subtype_supports_block(file_type, WTAP_BLOCK_IF_ID_AND_INFO) != BLOCK_NOT_SUPPORTED) { shb_hdrs = create_shb_header(in_files, in_file_count, app_name); - merge_debug("merge_files: SHB created"); + ws_debug("merge_files: SHB created"); idb_inf = generate_merged_idbs(in_files, in_file_count, mode); - merge_debug("merge_files: IDB merge operation complete, got %u IDBs", idb_inf ? idb_inf->interface_data->len : 0); + ws_debug("merge_files: IDB merge operation complete, got %u IDBs", idb_inf ? idb_inf->interface_data->len : 0); /* XXX other blocks like NRB are now discarded. */ params.shb_hdrs = shb_hdrs; |