Replace g_assert() with ws_assert()

pespin/rlcmac
João Valverde 2021-06-18 19:21:42 +01:00 committed by Wireshark GitLab Utility
parent b4eddd32c1
commit 0e50979b3f
95 changed files with 679 additions and 584 deletions

View File

@ -83,6 +83,7 @@
#include <wsutil/report_message.h>
#include <wsutil/str_util.h>
#include <wsutil/file_util.h>
#include <wsutil/ws_assert.h>
#include <wsutil/wsgcrypt.h>
@ -781,7 +782,7 @@ print_stats(const gchar *filename, capture_info *cf_info)
if (cap_file_idb && cf_info->num_interfaces != 0) {
guint i;
g_assert(cf_info->num_interfaces == cf_info->idb_info_strings->len);
ws_assert(cf_info->num_interfaces == cf_info->idb_info_strings->len);
printf ("Number of interfaces in file: %u\n", cf_info->num_interfaces);
for (i = 0; i < cf_info->idb_info_strings->len; i++) {
gchar *s = g_array_index(cf_info->idb_info_strings, gchar*, i);
@ -1123,7 +1124,7 @@ static void
cleanup_capture_info(capture_info *cf_info)
{
guint i;
g_assert(cf_info != NULL);
ws_assert(cf_info != NULL);
g_free(cf_info->encap_counts);
cf_info->encap_counts = NULL;
@ -1210,7 +1211,7 @@ process_cap_file(const char *filename, gboolean need_separator)
idb_info = wtap_file_get_idb_info(cf_info.wth);
g_assert(idb_info->interface_data != NULL);
ws_assert(idb_info->interface_data != NULL);
cf_info.num_interfaces = idb_info->interface_data->len;
cf_info.interface_packet_counts = g_array_sized_new(FALSE, TRUE, sizeof(guint32), cf_info.num_interfaces);

View File

@ -35,6 +35,7 @@ gboolean has_wpcap = FALSE;
#include "capture/capture-pcap-util-int.h"
#include <wsutil/file_util.h>
#include <wsutil/ws_assert.h>
/* XXX - yes, I know, I should move cppmagic.h to a generic location. */
#include "tools/lemon/cppmagic.h"
@ -247,7 +248,7 @@ local_code_page_str_to_utf8(char *str)
static void
prepare_errbuf(char *errbuf)
{
g_assert(errbuf);
ws_assert(errbuf);
errbuf[0] = '\0';
}
@ -283,49 +284,49 @@ cant_load_winpcap_err(const char *app_name)
void
pcap_close(pcap_t *a)
{
g_assert(has_wpcap);
ws_assert(has_wpcap);
p_pcap_close(a);
}
int
pcap_stats(pcap_t *a, struct pcap_stat *b)
{
g_assert(has_wpcap);
ws_assert(has_wpcap);
return p_pcap_stats(a, b);
}
int
pcap_dispatch(pcap_t *a, int b, pcap_handler c, guchar *d)
{
g_assert(has_wpcap);
ws_assert(has_wpcap);
return p_pcap_dispatch(a, b, c, d);
}
int
pcap_snapshot(pcap_t *a)
{
g_assert(has_wpcap);
ws_assert(has_wpcap);
return p_pcap_snapshot(a);
}
int
pcap_datalink(pcap_t *a)
{
g_assert(has_wpcap);
ws_assert(has_wpcap);
return p_pcap_datalink(a);
}
int
pcap_set_datalink(pcap_t *p, int dlt)
{
g_assert(has_wpcap);
ws_assert(has_wpcap);
return p_pcap_set_datalink(p, dlt);
}
int
pcap_setfilter(pcap_t *a, struct bpf_program *b)
{
g_assert(has_wpcap);
ws_assert(has_wpcap);
return p_pcap_setfilter(a, b);
}
@ -333,7 +334,7 @@ char*
pcap_geterr(pcap_t *a)
{
char *errbuf;
g_assert(has_wpcap);
ws_assert(has_wpcap);
errbuf = p_pcap_geterr(a);
convert_errbuf_to_utf8(errbuf);
return errbuf;
@ -343,7 +344,7 @@ int
pcap_compile(pcap_t *a, struct bpf_program *b, const char *c, int d,
bpf_u_int32 e)
{
g_assert(has_wpcap);
ws_assert(has_wpcap);
return p_pcap_compile(a, b, c, d, e);
}
@ -351,7 +352,7 @@ int
pcap_compile_nopcap(int a, int b, struct bpf_program *c, const char *d, int e,
bpf_u_int32 f)
{
g_assert(has_wpcap);
ws_assert(has_wpcap);
return p_pcap_compile_nopcap(a, b, c, d, e, f);
}
@ -359,7 +360,7 @@ int
pcap_lookupnet(const char *a, bpf_u_int32 *b, bpf_u_int32 *c, char *errbuf)
{
int ret;
g_assert(has_wpcap);
ws_assert(has_wpcap);
ret = p_pcap_lookupnet(a, b, c, errbuf);
if (ret == -1)
convert_errbuf_to_utf8(errbuf);
@ -421,7 +422,7 @@ int
pcap_findalldevs_ex(const char *a, struct pcap_rmtauth *b, pcap_if_t **c, char *errbuf)
{
int ret;
g_assert(has_wpcap);
ws_assert(has_wpcap);
ret = p_pcap_findalldevs_ex(a, b, c, errbuf);
if (ret == -1)
convert_errbuf_to_utf8(errbuf);
@ -433,7 +434,7 @@ pcap_createsrcstr(char *a, int b, const char *c, const char *d, const char *e,
char *errbuf)
{
int ret;
g_assert(has_wpcap);
ws_assert(has_wpcap);
ret = p_pcap_createsrcstr(a, b, c, d, e, errbuf);
if (ret == -1)
convert_errbuf_to_utf8(errbuf);
@ -445,7 +446,7 @@ pcap_createsrcstr(char *a, int b, const char *c, const char *d, const char *e,
struct pcap_samp *
pcap_setsampling(pcap_t *a)
{
g_assert(has_wpcap);
ws_assert(has_wpcap);
if (p_pcap_setsampling != NULL) {
return p_pcap_setsampling(a);
}
@ -456,14 +457,14 @@ pcap_setsampling(pcap_t *a)
int
pcap_loop(pcap_t *a, int b, pcap_handler c, guchar *d)
{
g_assert(has_wpcap);
ws_assert(has_wpcap);
return p_pcap_loop(a, b, c, d);
}
void
pcap_freecode(struct bpf_program *a)
{
g_assert(has_wpcap);
ws_assert(has_wpcap);
p_pcap_freecode(a);
}
@ -471,7 +472,7 @@ int
pcap_findalldevs(pcap_if_t **a, char *errbuf)
{
int ret;
g_assert(has_wpcap);
ws_assert(has_wpcap);
ret = p_pcap_findalldevs(a, errbuf);
if (ret == -1)
convert_errbuf_to_utf8(errbuf);
@ -481,7 +482,7 @@ pcap_findalldevs(pcap_if_t **a, char *errbuf)
void
pcap_freealldevs(pcap_if_t *a)
{
g_assert(has_wpcap);
ws_assert(has_wpcap);
p_pcap_freealldevs(a);
}
@ -490,7 +491,7 @@ pcap_t *
pcap_create(const char *a, char *errbuf)
{
pcap_t *p;
g_assert(has_wpcap && p_pcap_create != NULL);
ws_assert(has_wpcap && p_pcap_create != NULL);
p = p_pcap_create(a, errbuf);
if (p == NULL)
convert_errbuf_to_utf8(errbuf);
@ -500,21 +501,21 @@ pcap_create(const char *a, char *errbuf)
int
pcap_set_snaplen(pcap_t *a, int b)
{
g_assert(has_wpcap && p_pcap_set_snaplen != NULL);
ws_assert(has_wpcap && p_pcap_set_snaplen != NULL);
return p_pcap_set_snaplen(a, b);
}
int
pcap_set_promisc(pcap_t *a, int b)
{
g_assert(has_wpcap && p_pcap_set_promisc != NULL);
ws_assert(has_wpcap && p_pcap_set_promisc != NULL);
return p_pcap_set_promisc(a, b);
}
int
pcap_can_set_rfmon(pcap_t *a)
{
g_assert(has_wpcap);
ws_assert(has_wpcap);
if (p_pcap_can_set_rfmon != NULL) {
return p_pcap_can_set_rfmon(a);
}
@ -524,27 +525,27 @@ pcap_can_set_rfmon(pcap_t *a)
int
pcap_set_rfmon(pcap_t *a, int b)
{
g_assert(has_wpcap && p_pcap_set_rfmon != NULL);
ws_assert(has_wpcap && p_pcap_set_rfmon != NULL);
return p_pcap_set_rfmon(a, b);
}
int
pcap_set_timeout(pcap_t *a, int b)
{
g_assert(has_wpcap && p_pcap_set_timeout != NULL);
ws_assert(has_wpcap && p_pcap_set_timeout != NULL);
return p_pcap_set_timeout(a, b);
}
int
pcap_set_buffer_size(pcap_t *a, int b)
{
g_assert(has_wpcap && p_pcap_set_buffer_size != NULL);
ws_assert(has_wpcap && p_pcap_set_buffer_size != NULL);
return p_pcap_set_buffer_size(a, b);
}
int
pcap_activate(pcap_t *a)
{
g_assert(has_wpcap && p_pcap_activate != NULL);
ws_assert(has_wpcap && p_pcap_activate != NULL);
return p_pcap_activate(a);
}
@ -554,7 +555,7 @@ pcap_statustostr(int a)
{
static char ebuf[15 + 10 + 1];
g_assert(has_wpcap);
ws_assert(has_wpcap);
if (p_pcap_statustostr != NULL) {
return p_pcap_statustostr(a);
}
@ -569,7 +570,7 @@ pcap_statustostr(int a)
#ifdef HAVE_PCAP_SET_TSTAMP_TYPE
int
pcap_set_tstamp_type(pcap_t *a, int b) {
g_assert(has_wpcap);
ws_assert(has_wpcap);
if (p_pcap_set_tstamp_type != NULL) {
return p_pcap_set_tstamp_type(a, b);
}
@ -578,7 +579,7 @@ pcap_set_tstamp_type(pcap_t *a, int b) {
int
pcap_set_tstamp_precision(pcap_t *a, int b) {
g_assert(has_wpcap);
ws_assert(has_wpcap);
if (p_pcap_set_tstamp_precision != NULL) {
return p_pcap_set_tstamp_precision(a, b);
}
@ -588,7 +589,7 @@ pcap_set_tstamp_precision(pcap_t *a, int b) {
int
pcap_get_tstamp_precision(pcap_t *a) {
g_assert(has_wpcap);
ws_assert(has_wpcap);
if (p_pcap_get_tstamp_precision != NULL) {
return p_pcap_get_tstamp_precision(a);
}
@ -598,7 +599,7 @@ pcap_get_tstamp_precision(pcap_t *a) {
int
pcap_list_tstamp_types(pcap_t *a, int **b) {
g_assert(has_wpcap);
ws_assert(has_wpcap);
if (p_pcap_list_tstamp_types != NULL) {
return p_pcap_list_tstamp_types(a, b);
}
@ -607,7 +608,7 @@ pcap_list_tstamp_types(pcap_t *a, int **b) {
void
pcap_free_tstamp_types(int *a) {
g_assert(has_wpcap);
ws_assert(has_wpcap);
if (p_pcap_free_tstamp_types != NULL) {
p_pcap_free_tstamp_types(a);
}
@ -615,7 +616,7 @@ pcap_free_tstamp_types(int *a) {
int
pcap_tstamp_type_name_to_val(const char *a) {
g_assert(has_wpcap);
ws_assert(has_wpcap);
if (p_pcap_tstamp_type_name_to_val != NULL) {
return p_pcap_tstamp_type_name_to_val(a);
}
@ -624,7 +625,7 @@ pcap_tstamp_type_name_to_val(const char *a) {
const char *
pcap_tstamp_type_val_to_name(int a) {
g_assert(has_wpcap);
ws_assert(has_wpcap);
if (p_pcap_tstamp_type_val_to_name != NULL) {
return p_pcap_tstamp_type_val_to_name(a);
}
@ -633,7 +634,7 @@ pcap_tstamp_type_val_to_name(int a) {
const char *
pcap_tstamp_type_val_to_description(int a) {
g_assert(has_wpcap);
ws_assert(has_wpcap);
if (p_pcap_tstamp_type_val_to_description != NULL) {
return p_pcap_tstamp_type_val_to_description(a);
}
@ -663,7 +664,7 @@ pcap_list_datalinks(pcap_t *p, int **ddlt)
void
pcap_free_datalinks(int *ddlt)
{
g_assert(has_wpcap);
ws_assert(has_wpcap);
/*
* If we don't have pcap_free_datalinks() in WinPcap,
@ -703,7 +704,7 @@ void pcap_breakloop(pcap_t *a)
/* setbuff is win32 specific! */
int pcap_setbuff(pcap_t *a, int b)
{
g_assert(has_wpcap);
ws_assert(has_wpcap);
return p_pcap_setbuff(a, b);
}
@ -711,7 +712,7 @@ int pcap_setbuff(pcap_t *a, int b)
/* (if you get a declaration warning here, try to update to at least WinPcap 3.1b4 develpack) */
int pcap_next_ex(pcap_t *a, struct pcap_pkthdr **b, const u_char **c)
{
g_assert(has_wpcap);
ws_assert(has_wpcap);
return p_pcap_next_ex(a, b, c);
}

View File

@ -22,6 +22,7 @@
#include <wsutil/strtoi.h>
#include <wsutil/wslog.h>
#include <wsutil/ws_assert.h>
#ifdef _WIN32
#include <wsutil/unicode-utils.h>
@ -1515,9 +1516,9 @@ sync_pipe_gets_nonblock(int pipe_fd, char *bytes, int max) {
/* convert header values (indicator and 3-byte length) */
static void
pipe_convert_header(const guchar *header, int header_len, char *indicator, int *block_len) {
pipe_convert_header(const guchar *header, int header_len _U_, char *indicator, int *block_len) {
g_assert(header_len == 4);
ws_assert(header_len == 4);
/* convert header values */
*indicator = header[0];
@ -1742,7 +1743,7 @@ sync_pipe_input_cb(gint source, gpointer user_data)
break;
}
default:
g_assert_not_reached();
ws_assert_not_reached();
}
return TRUE;
@ -1772,7 +1773,7 @@ sync_pipe_wait_for_child(ws_process_id fork_child, gchar **msgp)
start_time = g_get_monotonic_time();
ws_debug("wait till child closed");
g_assert(fork_child != WS_INVALID_PID);
ws_assert(fork_child != WS_INVALID_PID);
*msgp = NULL; /* assume no error */
#ifdef _WIN32

View File

@ -29,6 +29,7 @@
#include <ui/exit_codes.h>
#include <wsutil/file_util.h>
#include <wsutil/ws_pipe.h>
#include <wsutil/ws_assert.h>
#include "capture/capture_ifinfo.h"
#include "capture/capture-pcap-util.h"
@ -997,7 +998,7 @@ capture_opts_add_opt(capture_options *capture_opts, int opt, const char *optarg_
break;
default:
/* the caller is responsible to send us only the right opt's */
g_assert_not_reached();
ws_assert_not_reached();
}
return 0;

View File

@ -88,6 +88,7 @@
#include "wsutil/time_util.h"
#include "wsutil/please_report_bug.h"
#include "wsutil/glib-compat.h"
#include <wsutil/ws_assert.h>
#include "capture/ws80211_utils.h"
@ -2134,7 +2135,7 @@ pcapng_adjust_block(capture_src *pcap_src, const pcapng_block_header_t *bh, u_ch
for (unsigned i = 0; i < pcap_src->cap_pipe_info.pcapng.src_iface_to_global->len; i++) {
guint32 iface_id = g_array_index(pcap_src->cap_pipe_info.pcapng.src_iface_to_global, guint32, i);
saved_idb_t *idb_source = &g_array_index(global_ld.saved_idbs, saved_idb_t, iface_id);
g_assert(idb_source->interface_id == pcap_src->interface_id);
ws_assert(idb_source->interface_id == pcap_src->interface_id);
g_free(idb_source->idb);
memset(idb_source, 0, sizeof(saved_idb_t));
idb_source->deleted = TRUE;
@ -3361,7 +3362,7 @@ capture_loop_dispatch(loop_data *ld,
if (inpkts < 0) {
ws_debug("%s: src %u pipe reached EOF or err, rcv: %u drop: %u flush: %u",
G_STRFUNC, pcap_src->interface_id, pcap_src->received, pcap_src->dropped, pcap_src->flushed);
g_assert(pcap_src->cap_pipe_err != PIPOK);
ws_assert(pcap_src->cap_pipe_err != PIPOK);
}
}
}
@ -4346,7 +4347,7 @@ capture_loop_start(capture_options *capture_opts, gboolean *stats_known, struct
interface_opts = &g_array_index(capture_opts->ifaces, interface_options, i);
received = pcap_src->received;
if (pcap_src->pcap_h != NULL) {
g_assert(!pcap_src->from_cap_pipe);
ws_assert(!pcap_src->from_cap_pipe);
/* Get the capture statistics, so we know how many packets were dropped. */
if (pcap_stats(pcap_src->pcap_h, stats) >= 0) {
*stats_known = TRUE;
@ -4511,7 +4512,7 @@ capture_loop_write_pcapng_cb(capture_src *pcap_src, const pcapng_block_header_t
/*
* This should never be called if we're not writing pcapng.
*/
g_assert(global_capture_opts.use_pcapng);
ws_assert(global_capture_opts.use_pcapng);
/* We may be called multiple times from pcap_dispatch(); if we've set
the "stop capturing" flag, ignore this packet, as we're not
@ -4523,7 +4524,7 @@ capture_loop_write_pcapng_cb(capture_src *pcap_src, const pcapng_block_header_t
if (!pcapng_adjust_block(pcap_src, bh, pd)) {
ws_info("%s failed to adjust pcapng block.", G_STRFUNC);
g_assert_not_reached();
ws_assert_not_reached();
return;
}

View File

@ -83,6 +83,7 @@
#include <version_info.h>
#include <wsutil/pint.h>
#include <wsutil/strtoi.h>
#include <wsutil/ws_assert.h>
#include <wiretap/wtap_opttypes.h>
#include "ui/failure_message.h"
@ -1731,7 +1732,7 @@ main(int argc, char *argv[])
} else {
filename = g_strdup(argv[optind+1]);
}
g_assert(filename);
ws_assert(filename);
/* If we don't have an application name add one */
if (wtap_block_get_string_option_value(g_array_index(params.shb_hdrs, wtap_block_t, 0), OPT_SHB_USERAPPL, &shb_user_appl) != WTAP_OPTTYPE_SUCCESS) {
@ -1785,7 +1786,7 @@ main(int argc, char *argv[])
nstime_add(&block_next, &secs_per_block); /* reset for next interval */
g_free(filename);
filename = fileset_get_filename_by_pattern(block_cnt++, rec, fprefix, fsuffix);
g_assert(filename);
ws_assert(filename);
if (verbose)
fprintf(stderr, "Continuing writing in file %s\n", filename);
@ -1817,7 +1818,7 @@ main(int argc, char *argv[])
g_free(filename);
filename = fileset_get_filename_by_pattern(block_cnt++, rec, fprefix, fsuffix);
g_assert(filename);
ws_assert(filename);
if (verbose)
fprintf(stderr, "Continuing writing in file %s\n", filename);

View File

@ -17,6 +17,7 @@
#include "tvbuff.h"
#include "ipv6.h"
#include "addr_and_mask.h"
#include <wsutil/ws_assert.h>
guint32
ip_get_subnet_mask(const guint32 mask_length)
@ -33,7 +34,7 @@ ip_get_subnet_mask(const guint32 mask_length)
0xfffffff8, 0xfffffffc, 0xfffffffe, 0xffffffff,
};
g_assert(mask_length <= 32);
ws_assert(mask_length <= 32);
return masks[mask_length];
}

View File

@ -21,6 +21,7 @@
#include <errno.h>
#include <wsutil/strtoi.h>
#include <wsutil/ws_assert.h>
/*
* Win32 doesn't have SIGALRM (and it's the OS where name lookup calls
@ -818,7 +819,7 @@ static void
initialize_services(void)
{
gboolean parse_file = TRUE;
g_assert(serv_port_hashtable == NULL);
ws_assert(serv_port_hashtable == NULL);
serv_port_hashtable = wmem_map_new(wmem_epan_scope(), g_direct_hash, g_direct_equal);
/* Compute the pathname of the services file. */
@ -906,7 +907,7 @@ parse_enterprises_file(const char * path)
static void
initialize_enterprises(void)
{
g_assert(enterprises_hashtable == NULL);
ws_assert(enterprises_hashtable == NULL);
enterprises_hashtable = g_hash_table_new_full(NULL, NULL, NULL, g_free);
if (g_enterprises_path == NULL) {
@ -957,10 +958,10 @@ enterprises_base_custom(char *buf, guint32 value)
static void
enterprises_cleanup(void)
{
g_assert(enterprises_hashtable);
ws_assert(enterprises_hashtable);
g_hash_table_destroy(enterprises_hashtable);
enterprises_hashtable = NULL;
g_assert(g_enterprises_path);
ws_assert(g_enterprises_path);
g_free(g_enterprises_path);
g_enterprises_path = NULL;
g_free(g_penterprises_path);
@ -1870,7 +1871,7 @@ eth_addr_resolve(hashether_t *tp) {
tp->status = HASHETHER_STATUS_RESOLVED_DUMMY;
return tp;
}
g_assert_not_reached();
ws_assert_not_reached();
} /* eth_addr_resolve */
static hashether_t *
@ -2208,7 +2209,7 @@ get_vlannamebyid(guint16 id)
static void
initialize_vlans(void)
{
g_assert(vlan_hash_table == NULL);
ws_assert(vlan_hash_table == NULL);
vlan_hash_table = wmem_map_new(wmem_epan_scope(), g_direct_hash, g_direct_equal);
/* Set g_pvlan_path here, but don't actually do anything
@ -2534,7 +2535,7 @@ subnet_lookup(const guint32 addr)
/* Note that we run from 31 (length 32) to 0 (length 1) */
--i;
g_assert(i < SUBNETLENGTHSIZE);
ws_assert(i < SUBNETLENGTHSIZE);
length_entry = &subnet_length_entries[i];
@ -2578,7 +2579,7 @@ subnet_entry_set(guint32 subnet_addr, const guint8 mask_length, const gchar* nam
sub_net_hashipv4_t * tp;
gsize hash_idx;
g_assert(mask_length > 0 && mask_length <= 32);
ws_assert(mask_length > 0 && mask_length <= 32);
entry = &subnet_length_entries[mask_length - 1];
@ -2779,7 +2780,7 @@ ss7pc_name_lookup_init(void)
{
char *ss7pcspath;
g_assert(ss7pc_hash_table == NULL);
ws_assert(ss7pc_hash_table == NULL);
ss7pc_hash_table = wmem_map_new(wmem_epan_scope(), g_direct_hash, g_direct_equal);
@ -3100,16 +3101,16 @@ host_name_lookup_init(void)
char *hostspath;
guint i;
g_assert(ipxnet_hash_table == NULL);
ws_assert(ipxnet_hash_table == NULL);
ipxnet_hash_table = wmem_map_new(wmem_epan_scope(), g_direct_hash, g_direct_equal);
g_assert(ipv4_hash_table == NULL);
ws_assert(ipv4_hash_table == NULL);
ipv4_hash_table = wmem_map_new(wmem_epan_scope(), g_direct_hash, g_direct_equal);
g_assert(ipv6_hash_table == NULL);
ws_assert(ipv6_hash_table == NULL);
ipv6_hash_table = wmem_map_new(wmem_epan_scope(), ipv6_oat_hash, ipv6_equal);
g_assert(async_dns_queue_head == NULL);
ws_assert(async_dns_queue_head == NULL);
async_dns_queue_head = wmem_list_new(wmem_epan_scope());
if (manually_resolved_ipv4_list == NULL)
@ -3266,7 +3267,7 @@ port_with_resolution_to_str(wmem_allocator_t *scope, port_type proto, guint port
return wmem_strdup_printf(scope, "%u", port);
}
port_str = serv_name_lookup(proto, port);
g_assert(port_str);
ws_assert(port_str);
return wmem_strdup_printf(scope, "%s (%u)", port_str, port);
}
@ -3280,7 +3281,7 @@ port_with_resolution_to_str_buf(gchar *buf, gulong buf_size, port_type proto, gu
return g_snprintf(buf, buf_size, "%u", port);
}
port_str = serv_name_lookup(proto, port);
g_assert(port_str);
ws_assert(port_str);
return g_snprintf(buf, buf_size, "%s (%u)", port_str, port);
}

View File

@ -16,6 +16,7 @@
#include "tvbuff.h"
#include "wmem/wmem.h"
#include <wsutil/ws_assert.h>
#ifdef __cplusplus
extern "C" {
@ -78,12 +79,12 @@ static inline void
set_address(address *addr, int addr_type, int addr_len, const void *addr_data) {
if (addr_len == 0) {
/* Zero length must mean no data */
g_assert(addr_data == NULL);
ws_assert(addr_data == NULL);
} else {
/* Must not be AT_NONE - AT_NONE must have no data */
g_assert(addr_type != AT_NONE);
ws_assert(addr_type != AT_NONE);
/* Make sure we *do* have data */
g_assert(addr_data != NULL);
ws_assert(addr_data != NULL);
}
addr->type = addr_type;
addr->len = addr_len;
@ -112,7 +113,7 @@ set_address_tvb(address *addr, int addr_type, int addr_len, tvbuff_t *tvb, int o
if (addr_len != 0) {
/* Must not be AT_NONE - AT_NONE must have no data */
g_assert(addr_type != AT_NONE);
ws_assert(addr_type != AT_NONE);
p = tvb_get_ptr(tvb, offset, addr_len);
} else
p = NULL;
@ -132,19 +133,19 @@ set_address_tvb(address *addr, int addr_type, int addr_len, tvbuff_t *tvb, int o
static inline void
alloc_address_wmem(wmem_allocator_t *scope, address *addr,
int addr_type, int addr_len, const void *addr_data) {
g_assert(addr);
ws_assert(addr);
clear_address(addr);
addr->type = addr_type;
if (addr_len == 0) {
/* Zero length must mean no data */
g_assert(addr_data == NULL);
ws_assert(addr_data == NULL);
/* Nothing to copy */
return;
}
/* Must not be AT_NONE - AT_NONE must have no data */
g_assert(addr_type != AT_NONE);
ws_assert(addr_type != AT_NONE);
/* Make sure we *do* have data to copy */
g_assert(addr_data != NULL);
ws_assert(addr_data != NULL);
addr->data = addr->priv = wmem_memdup(scope, addr_data, addr_len);
addr->len = addr_len;
}
@ -287,7 +288,7 @@ free_address_wmem(wmem_allocator_t *scope, address *addr) {
if (addr->type != AT_NONE && addr->len > 0 && addr->priv != NULL) {
/* Make sure API use is correct */
/* if priv is not null then data == priv */
g_assert(addr->data == addr->priv);
ws_assert(addr->data == addr->priv);
wmem_free(scope, addr->priv);
}
clear_address(addr);

View File

@ -18,6 +18,7 @@
#include "wsutil/pint.h"
#include "wsutil/str_util.h"
#include "wsutil/inet_addr.h"
#include <wsutil/ws_assert.h>
struct _address_type_t {
int addr_type; /* From address_type enumeration or registered value */
@ -54,18 +55,18 @@ static address_type_t* type_list[MAX_ADDR_TYPE_VALUE + 1];
static void address_type_register(int addr_type, address_type_t *at)
{
/* Check input */
g_assert(addr_type < MAX_ADDR_TYPE_VALUE);
g_assert(addr_type == at->addr_type);
ws_assert(addr_type < MAX_ADDR_TYPE_VALUE);
ws_assert(addr_type == at->addr_type);
/* Don't re-register. */
g_assert(type_list[addr_type] == NULL);
ws_assert(type_list[addr_type] == NULL);
/* Sanity check */
g_assert(at->name);
g_assert(at->pretty_name);
g_assert(at->addr_to_str);
g_assert(at->addr_str_len);
g_assert(((at->addr_name_res_str != NULL) && (at->addr_name_res_len != NULL)) ||
ws_assert(at->name);
ws_assert(at->pretty_name);
ws_assert(at->addr_to_str);
ws_assert(at->addr_str_len);
ws_assert(((at->addr_name_res_str != NULL) && (at->addr_name_res_len != NULL)) ||
((at->addr_name_res_str == NULL) && (at->addr_name_res_len == NULL)));
type_list[addr_type] = at;
@ -79,16 +80,16 @@ int address_type_dissector_register(const char* name, const char* pretty_name,
int addr_type;
/* Ensure valid data/functions for required fields */
g_assert(name);
g_assert(pretty_name);
g_assert(to_str_func);
g_assert(str_len_func);
ws_assert(name);
ws_assert(pretty_name);
ws_assert(to_str_func);
ws_assert(str_len_func);
/* Either have both or neither */
g_assert(((name_res_str_func != NULL) && (name_res_len_func != NULL)) ||
ws_assert(((name_res_str_func != NULL) && (name_res_len_func != NULL)) ||
((name_res_str_func == NULL) && (name_res_len_func == NULL)));
/* This shouldn't happen, so flag it for fixing */
g_assert(num_dissector_addr_type < MAX_DISSECTOR_ADDR_TYPE);
ws_assert(num_dissector_addr_type < MAX_DISSECTOR_ADDR_TYPE);
addr_type = AT_END_OF_LIST+num_dissector_addr_type;
dissector_type_addresses[num_dissector_addr_type].addr_type = addr_type;
@ -699,7 +700,7 @@ void address_types_initialize(void)
/* Given an address type id, return an address_type_t* */
#define ADDR_TYPE_LOOKUP(addr_type, result) \
/* Check input */ \
g_assert(addr_type < MAX_ADDR_TYPE_VALUE); \
ws_assert(addr_type < MAX_ADDR_TYPE_VALUE); \
result = type_list[addr_type];
static int address_type_get_length(const address* addr)
@ -938,7 +939,7 @@ tvb_address_to_str(wmem_allocator_t *scope, tvbuff_t *tvb, int type, const gint
/* For variable length fields, use tvb_address_var_to_str() */
if (at->addr_fixed_len == NULL)
{
g_assert_not_reached();
ws_assert_not_reached();
return NULL;
}
@ -973,7 +974,7 @@ tvb_address_with_resolution_to_str(wmem_allocator_t *scope, tvbuff_t *tvb, int t
/* For variable length fields, use tvb_address_var_with_resolution_to_str() */
if (at->addr_fixed_len == NULL)
{
g_assert_not_reached();
ws_assert_not_reached();
return NULL;
}

View File

@ -17,6 +17,7 @@
#include "packet.h"
#include "capture_dissectors.h"
#include <wsutil/ws_assert.h>
#include <wsutil/wslog.h>
@ -107,7 +108,7 @@ capture_dissector_handle_t register_capture_dissector(const char *name, capture_
capture_dissector_handle_t handle;
/* Make sure the registration is unique */
g_assert(g_hash_table_lookup(registered_dissectors, name) == NULL);
ws_assert(g_hash_table_lookup(registered_dissectors, name) == NULL);
handle = new_capture_dissector_handle(dissector, proto, name);
g_hash_table_insert(registered_dissectors, (gpointer)name, handle);
@ -131,7 +132,7 @@ void capture_dissector_add_uint(const char *name, const guint32 pattern, capture
}
/* Make sure the registration is unique */
g_assert(g_hash_table_lookup(sub_dissectors->hash_table, GUINT_TO_POINTER(pattern)) == NULL);
ws_assert(g_hash_table_lookup(sub_dissectors->hash_table, GUINT_TO_POINTER(pattern)) == NULL);
g_hash_table_insert(sub_dissectors->hash_table, GUINT_TO_POINTER(pattern), (gpointer) handle);
}

View File

@ -23,6 +23,7 @@
#include <wsutil/filesystem.h>
#include <wsutil/file_util.h>
#include <wsutil/wslog.h>
#include <wsutil/ws_assert.h>
#include <epan/packet.h>
#include "color_filters.h"
@ -84,8 +85,8 @@ color_filters_add_tmp(GSList **cfl)
color_t bg_color, fg_color;
color_filter_t *colorf;
g_assert(strlen(prefs.gui_colorized_fg)==69);
g_assert(strlen(prefs.gui_colorized_bg)==69);
ws_assert(strlen(prefs.gui_colorized_fg)==69);
ws_assert(strlen(prefs.gui_colorized_bg)==69);
fg_colors = g_strsplit(prefs.gui_colorized_fg, ",", -1);
bg_colors = g_strsplit(prefs.gui_colorized_bg, ",", -1);
@ -406,7 +407,7 @@ color_filter_compile_cb(gpointer filter_arg, gpointer err)
gchar **err_msg = (gchar**)err;
gchar *local_err_msg = NULL;
g_assert(colorf->c_colorfilter == NULL);
ws_assert(colorf->c_colorfilter == NULL);
/* If the filter is disabled it doesn't matter if it compiles or not. */
if (colorf->disabled) return;
@ -417,7 +418,7 @@ color_filter_compile_cb(gpointer filter_arg, gpointer err)
g_free(local_err_msg);
/* this filter was compilable before, so this should never happen */
/* except if the OK button of the parent window has been clicked */
/* so don't use g_assert_not_reached() but check the filters again */
/* so don't use ws_assert_not_reached() but check the filters again */
}
}
@ -428,7 +429,7 @@ color_filter_validate_cb(gpointer filter_arg, gpointer err)
gchar **err_msg = (gchar**)err;
gchar *local_err_msg;
g_assert(colorf->c_colorfilter == NULL);
ws_assert(colorf->c_colorfilter == NULL);
/* If the filter is disabled it doesn't matter if it compiles or not. */
if (colorf->disabled) return;

View File

@ -33,6 +33,7 @@
#include <epan/dfilter/dfilter.h>
#include <wsutil/utf8_entities.h>
#include <wsutil/ws_assert.h>
#ifdef HAVE_LUA
#include <epan/wslua/wslua.h>
@ -912,7 +913,7 @@ set_abs_ymd_time(const frame_data *fd, gchar *buf, char *decimal_point, gboolean
tsprecision = fd->tsprec;
break;
default:
g_assert_not_reached();
ws_assert_not_reached();
}
switch (tsprecision) {
case WTAP_TSPREC_SEC:
@ -980,7 +981,7 @@ set_abs_ymd_time(const frame_data *fd, gchar *buf, char *decimal_point, gboolean
fd->abs_ts.nsecs);
break;
default:
g_assert_not_reached();
ws_assert_not_reached();
}
} else {
buf[0] = '\0';
@ -1046,7 +1047,7 @@ set_abs_ydoy_time(const frame_data *fd, gchar *buf, char *decimal_point, gboolea
tsprecision = fd->tsprec;
break;
default:
g_assert_not_reached();
ws_assert_not_reached();
}
switch (tsprecision) {
case WTAP_TSPREC_SEC:
@ -1108,7 +1109,7 @@ set_abs_ydoy_time(const frame_data *fd, gchar *buf, char *decimal_point, gboolea
fd->abs_ts.nsecs);
break;
default:
g_assert_not_reached();
ws_assert_not_reached();
}
} else {
buf[0] = '\0';
@ -1163,7 +1164,7 @@ set_time_seconds(const frame_data *fd, const nstime_t *ts, gchar *buf)
tsprecision = fd->tsprec;
break;
default:
g_assert_not_reached();
ws_assert_not_reached();
}
switch (tsprecision) {
case WTAP_TSPREC_SEC:
@ -1191,7 +1192,7 @@ set_time_seconds(const frame_data *fd, const nstime_t *ts, gchar *buf)
(gint64) ts->secs, ts->nsecs, TO_STR_TIME_RES_T_NSECS);
break;
default:
g_assert_not_reached();
ws_assert_not_reached();
}
}
@ -1235,7 +1236,7 @@ set_time_hour_min_sec(const frame_data *fd, const nstime_t *ts, gchar *buf, char
tsprecision = fd->tsprec;
break;
default:
g_assert_not_reached();
ws_assert_not_reached();
}
switch (tsprecision) {
case WTAP_TSPREC_SEC:
@ -1377,7 +1378,7 @@ set_time_hour_min_sec(const frame_data *fd, const nstime_t *ts, gchar *buf, char
}
break;
default:
g_assert_not_reached();
ws_assert_not_reached();
}
}
@ -1405,7 +1406,7 @@ col_set_rel_time(const frame_data *fd, column_info *cinfo, const int col)
set_time_seconds(fd, &del_rel_ts, cinfo->col_expr.col_expr_val[col]);
break;
default:
g_assert_not_reached();
ws_assert_not_reached();
}
cinfo->columns[col].col_data = cinfo->columns[col].col_buf;
}
@ -1429,7 +1430,7 @@ col_set_delta_time(const frame_data *fd, column_info *cinfo, const int col)
set_time_seconds(fd, &del_cap_ts, cinfo->col_expr.col_expr_val[col]);
break;
default:
g_assert_not_reached();
ws_assert_not_reached();
}
cinfo->columns[col].col_data = cinfo->columns[col].col_buf;
@ -1459,7 +1460,7 @@ col_set_delta_time_dis(const frame_data *fd, column_info *cinfo, const int col)
set_time_seconds(fd, &del_dis_ts, cinfo->col_expr.col_expr_val[col]);
break;
default:
g_assert_not_reached();
ws_assert_not_reached();
}
cinfo->columns[col].col_data = cinfo->columns[col].col_buf;
@ -1504,7 +1505,7 @@ set_abs_time(const frame_data *fd, gchar *buf, char *decimal_point, gboolean loc
tsprecision = fd->tsprec;
break;
default:
g_assert_not_reached();
ws_assert_not_reached();
}
switch (tsprecision) {
case WTAP_TSPREC_SEC:
@ -1554,7 +1555,7 @@ set_abs_time(const frame_data *fd, gchar *buf, char *decimal_point, gboolean loc
fd->abs_ts.nsecs);
break;
default:
g_assert_not_reached();
ws_assert_not_reached();
}
} else {
@ -1614,7 +1615,7 @@ set_epoch_time(const frame_data *fd, gchar *buf)
tsprecision = fd->tsprec;
break;
default:
g_assert_not_reached();
ws_assert_not_reached();
}
switch (tsprecision) {
case WTAP_TSPREC_SEC:
@ -1642,7 +1643,7 @@ set_epoch_time(const frame_data *fd, gchar *buf)
fd->abs_ts.secs, fd->abs_ts.nsecs, TO_STR_TIME_RES_T_NSECS);
break;
default:
g_assert_not_reached();
ws_assert_not_reached();
}
return TRUE;
}
@ -1688,7 +1689,7 @@ set_fd_time(const epan_t *epan, frame_data *fd, gchar *buf)
set_time_seconds(fd, &del_rel_ts, buf);
break;
default:
g_assert_not_reached();
ws_assert_not_reached();
}
} else {
buf[0] = '\0';
@ -1709,7 +1710,7 @@ set_fd_time(const epan_t *epan, frame_data *fd, gchar *buf)
set_time_hour_min_sec(fd, &del_cap_ts, buf, col_decimal_point);
break;
default:
g_assert_not_reached();
ws_assert_not_reached();
}
} else {
buf[0] = '\0';
@ -1730,7 +1731,7 @@ set_fd_time(const epan_t *epan, frame_data *fd, gchar *buf)
set_time_hour_min_sec(fd, &del_dis_ts, buf, col_decimal_point);
break;
default:
g_assert_not_reached();
ws_assert_not_reached();
}
} else {
buf[0] = '\0';
@ -1755,7 +1756,7 @@ set_fd_time(const epan_t *epan, frame_data *fd, gchar *buf)
case TS_NOT_SET:
/* code is missing for this case, but I don't know which [jmayer20051219] */
g_assert_not_reached();
ws_assert_not_reached();
break;
}
}
@ -1806,7 +1807,7 @@ col_set_cls_time(const frame_data *fd, column_info *cinfo, const gint col)
case TS_NOT_SET:
/* code is missing for this case, but I don't know which [jmayer20051219] */
g_assert_not_reached();
ws_assert_not_reached();
break;
}
}
@ -1859,7 +1860,7 @@ col_set_fmt_time(const frame_data *fd, column_info *cinfo, const gint fmt, const
break;
default:
g_assert_not_reached();
ws_assert_not_reached();
break;
}
}
@ -1918,7 +1919,7 @@ col_set_time(column_info *cinfo, const gint el, const nstime_t *ts, const char *
(gint64) ts->secs, ts->nsecs, TO_STR_TIME_RES_T_NSECS);
break;
default:
g_assert_not_reached();
ws_assert_not_reached();
}
col_item->col_data = col_item->col_buf;
cinfo->col_expr.col_expr[col] = fieldname;
@ -2049,8 +2050,8 @@ col_set_port(packet_info *pinfo, const int col, const gboolean is_res, const gbo
gboolean
col_based_on_frame_data(column_info *cinfo, const gint col)
{
g_assert(cinfo);
g_assert(col < cinfo->num_cols);
ws_assert(cinfo);
ws_assert(col < cinfo->num_cols);
switch (cinfo->columns[col].col_fmt) {
case COL_NUMBER:
@ -2236,11 +2237,11 @@ col_fill_in(packet_info *pinfo, const gboolean fill_col_exprs, const gboolean fi
break;
case NUM_COL_FMTS: /* keep compiler happy - shouldn't get here */
g_assert_not_reached();
ws_assert_not_reached();
break;
default:
if (col_item->col_fmt >= NUM_COL_FMTS) {
g_assert_not_reached();
ws_assert_not_reached();
}
/*
* Formatting handled by col_custom_set_edt() (COL_CUSTOM), expert.c
@ -2276,7 +2277,7 @@ col_fill_in_error(column_info *cinfo, frame_data *fdata, const gboolean fill_col
col_item->col_data = "Read error";
} else {
if (col_item->col_fmt >= NUM_COL_FMTS) {
g_assert_not_reached();
ws_assert_not_reached();
}
/*
* No dissection was done, and these columns are set as the

View File

@ -23,6 +23,7 @@
#include <epan/dfilter/dfilter.h>
#include <epan/column.h>
#include <epan/packet.h>
#include <wsutil/ws_assert.h>
/* Given a format number (as defined in column-utils.h), returns its equivalent
string */
@ -171,7 +172,7 @@ col_format_desc(const gint fmt_num) {
};
const gchar *val_str = try_val_to_str(fmt_num, dlist_vals);
g_assert(val_str != NULL);
ws_assert(val_str != NULL);
return val_str;
}
@ -294,7 +295,7 @@ get_timestamp_column_longest_string(const gint type, const gint precision)
return "0000-00-00 00:00:00.000000000";
break;
default:
g_assert_not_reached();
ws_assert_not_reached();
}
break;
case(TS_ABSOLUTE_WITH_YDOY):
@ -320,7 +321,7 @@ get_timestamp_column_longest_string(const gint type, const gint precision)
return "0000/000 00:00:00.000000000";
break;
default:
g_assert_not_reached();
ws_assert_not_reached();
}
break;
case(TS_ABSOLUTE):