Replace g_assert() with ws_assert()

This commit is contained in:
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/report_message.h>
#include <wsutil/str_util.h> #include <wsutil/str_util.h>
#include <wsutil/file_util.h> #include <wsutil/file_util.h>
#include <wsutil/ws_assert.h>
#include <wsutil/wsgcrypt.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) { if (cap_file_idb && cf_info->num_interfaces != 0) {
guint i; 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); printf ("Number of interfaces in file: %u\n", cf_info->num_interfaces);
for (i = 0; i < cf_info->idb_info_strings->len; i++) { for (i = 0; i < cf_info->idb_info_strings->len; i++) {
gchar *s = g_array_index(cf_info->idb_info_strings, gchar*, 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) cleanup_capture_info(capture_info *cf_info)
{ {
guint i; guint i;
g_assert(cf_info != NULL); ws_assert(cf_info != NULL);
g_free(cf_info->encap_counts); g_free(cf_info->encap_counts);
cf_info->encap_counts = NULL; 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); 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.num_interfaces = idb_info->interface_data->len;
cf_info.interface_packet_counts = g_array_sized_new(FALSE, TRUE, sizeof(guint32), cf_info.num_interfaces); 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 "capture/capture-pcap-util-int.h"
#include <wsutil/file_util.h> #include <wsutil/file_util.h>
#include <wsutil/ws_assert.h>
/* XXX - yes, I know, I should move cppmagic.h to a generic location. */ /* XXX - yes, I know, I should move cppmagic.h to a generic location. */
#include "tools/lemon/cppmagic.h" #include "tools/lemon/cppmagic.h"
@ -247,7 +248,7 @@ local_code_page_str_to_utf8(char *str)
static void static void
prepare_errbuf(char *errbuf) prepare_errbuf(char *errbuf)
{ {
g_assert(errbuf); ws_assert(errbuf);
errbuf[0] = '\0'; errbuf[0] = '\0';
} }
@ -283,49 +284,49 @@ cant_load_winpcap_err(const char *app_name)
void void
pcap_close(pcap_t *a) pcap_close(pcap_t *a)
{ {
g_assert(has_wpcap); ws_assert(has_wpcap);
p_pcap_close(a); p_pcap_close(a);
} }
int int
pcap_stats(pcap_t *a, struct pcap_stat *b) pcap_stats(pcap_t *a, struct pcap_stat *b)
{ {
g_assert(has_wpcap); ws_assert(has_wpcap);
return p_pcap_stats(a, b); return p_pcap_stats(a, b);
} }
int int
pcap_dispatch(pcap_t *a, int b, pcap_handler c, guchar *d) 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); return p_pcap_dispatch(a, b, c, d);
} }
int int
pcap_snapshot(pcap_t *a) pcap_snapshot(pcap_t *a)
{ {
g_assert(has_wpcap); ws_assert(has_wpcap);
return p_pcap_snapshot(a); return p_pcap_snapshot(a);
} }
int int
pcap_datalink(pcap_t *a) pcap_datalink(pcap_t *a)
{ {
g_assert(has_wpcap); ws_assert(has_wpcap);
return p_pcap_datalink(a); return p_pcap_datalink(a);
} }
int int
pcap_set_datalink(pcap_t *p, int dlt) pcap_set_datalink(pcap_t *p, int dlt)
{ {
g_assert(has_wpcap); ws_assert(has_wpcap);
return p_pcap_set_datalink(p, dlt); return p_pcap_set_datalink(p, dlt);
} }
int int
pcap_setfilter(pcap_t *a, struct bpf_program *b) pcap_setfilter(pcap_t *a, struct bpf_program *b)
{ {
g_assert(has_wpcap); ws_assert(has_wpcap);
return p_pcap_setfilter(a, b); return p_pcap_setfilter(a, b);
} }
@ -333,7 +334,7 @@ char*
pcap_geterr(pcap_t *a) pcap_geterr(pcap_t *a)
{ {
char *errbuf; char *errbuf;
g_assert(has_wpcap); ws_assert(has_wpcap);
errbuf = p_pcap_geterr(a); errbuf = p_pcap_geterr(a);
convert_errbuf_to_utf8(errbuf); convert_errbuf_to_utf8(errbuf);
return errbuf; return errbuf;
@ -343,7 +344,7 @@ int
pcap_compile(pcap_t *a, struct bpf_program *b, const char *c, int d, pcap_compile(pcap_t *a, struct bpf_program *b, const char *c, int d,
bpf_u_int32 e) bpf_u_int32 e)
{ {
g_assert(has_wpcap); ws_assert(has_wpcap);
return p_pcap_compile(a, b, c, d, e); 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, pcap_compile_nopcap(int a, int b, struct bpf_program *c, const char *d, int e,
bpf_u_int32 f) bpf_u_int32 f)
{ {
g_assert(has_wpcap); ws_assert(has_wpcap);
return p_pcap_compile_nopcap(a, b, c, d, e, f); 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) pcap_lookupnet(const char *a, bpf_u_int32 *b, bpf_u_int32 *c, char *errbuf)
{ {
int ret; int ret;
g_assert(has_wpcap); ws_assert(has_wpcap);
ret = p_pcap_lookupnet(a, b, c, errbuf); ret = p_pcap_lookupnet(a, b, c, errbuf);
if (ret == -1) if (ret == -1)
convert_errbuf_to_utf8(errbuf); 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) pcap_findalldevs_ex(const char *a, struct pcap_rmtauth *b, pcap_if_t **c, char *errbuf)
{ {
int ret; int ret;
g_assert(has_wpcap); ws_assert(has_wpcap);
ret = p_pcap_findalldevs_ex(a, b, c, errbuf); ret = p_pcap_findalldevs_ex(a, b, c, errbuf);
if (ret == -1) if (ret == -1)
convert_errbuf_to_utf8(errbuf); 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) char *errbuf)
{ {
int ret; int ret;
g_assert(has_wpcap); ws_assert(has_wpcap);
ret = p_pcap_createsrcstr(a, b, c, d, e, errbuf); ret = p_pcap_createsrcstr(a, b, c, d, e, errbuf);
if (ret == -1) if (ret == -1)
convert_errbuf_to_utf8(errbuf); 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 * struct pcap_samp *
pcap_setsampling(pcap_t *a) pcap_setsampling(pcap_t *a)
{ {
g_assert(has_wpcap); ws_assert(has_wpcap);
if (p_pcap_setsampling != NULL) { if (p_pcap_setsampling != NULL) {
return p_pcap_setsampling(a); return p_pcap_setsampling(a);
} }
@ -456,14 +457,14 @@ pcap_setsampling(pcap_t *a)
int int
pcap_loop(pcap_t *a, int b, pcap_handler c, guchar *d) 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); return p_pcap_loop(a, b, c, d);
} }
void void
pcap_freecode(struct bpf_program *a) pcap_freecode(struct bpf_program *a)
{ {
g_assert(has_wpcap); ws_assert(has_wpcap);
p_pcap_freecode(a); p_pcap_freecode(a);
} }
@ -471,7 +472,7 @@ int
pcap_findalldevs(pcap_if_t **a, char *errbuf) pcap_findalldevs(pcap_if_t **a, char *errbuf)
{ {
int ret; int ret;
g_assert(has_wpcap); ws_assert(has_wpcap);
ret = p_pcap_findalldevs(a, errbuf); ret = p_pcap_findalldevs(a, errbuf);
if (ret == -1) if (ret == -1)
convert_errbuf_to_utf8(errbuf); convert_errbuf_to_utf8(errbuf);
@ -481,7 +482,7 @@ pcap_findalldevs(pcap_if_t **a, char *errbuf)
void void
pcap_freealldevs(pcap_if_t *a) pcap_freealldevs(pcap_if_t *a)
{ {
g_assert(has_wpcap); ws_assert(has_wpcap);
p_pcap_freealldevs(a); p_pcap_freealldevs(a);
} }
@ -490,7 +491,7 @@ pcap_t *
pcap_create(const char *a, char *errbuf) pcap_create(const char *a, char *errbuf)
{ {
pcap_t *p; 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); p = p_pcap_create(a, errbuf);
if (p == NULL) if (p == NULL)
convert_errbuf_to_utf8(errbuf); convert_errbuf_to_utf8(errbuf);
@ -500,21 +501,21 @@ pcap_create(const char *a, char *errbuf)
int int
pcap_set_snaplen(pcap_t *a, int b) 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); return p_pcap_set_snaplen(a, b);
} }
int int
pcap_set_promisc(pcap_t *a, int b) 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); return p_pcap_set_promisc(a, b);
} }
int int
pcap_can_set_rfmon(pcap_t *a) pcap_can_set_rfmon(pcap_t *a)
{ {
g_assert(has_wpcap); ws_assert(has_wpcap);
if (p_pcap_can_set_rfmon != NULL) { if (p_pcap_can_set_rfmon != NULL) {
return p_pcap_can_set_rfmon(a); return p_pcap_can_set_rfmon(a);
} }
@ -524,27 +525,27 @@ pcap_can_set_rfmon(pcap_t *a)
int int
pcap_set_rfmon(pcap_t *a, int b) 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); return p_pcap_set_rfmon(a, b);
} }
int int
pcap_set_timeout(pcap_t *a, int b) 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); return p_pcap_set_timeout(a, b);
} }
int int
pcap_set_buffer_size(pcap_t *a, int b) 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); return p_pcap_set_buffer_size(a, b);
} }
int int
pcap_activate(pcap_t *a) 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); return p_pcap_activate(a);
} }
@ -554,7 +555,7 @@ pcap_statustostr(int a)
{ {
static char ebuf[15 + 10 + 1]; static char ebuf[15 + 10 + 1];
g_assert(has_wpcap); ws_assert(has_wpcap);
if (p_pcap_statustostr != NULL) { if (p_pcap_statustostr != NULL) {
return p_pcap_statustostr(a); return p_pcap_statustostr(a);
} }
@ -569,7 +570,7 @@ pcap_statustostr(int a)
#ifdef HAVE_PCAP_SET_TSTAMP_TYPE #ifdef HAVE_PCAP_SET_TSTAMP_TYPE
int int
pcap_set_tstamp_type(pcap_t *a, int b) { pcap_set_tstamp_type(pcap_t *a, int b) {
g_assert(has_wpcap); ws_assert(has_wpcap);
if (p_pcap_set_tstamp_type != NULL) { if (p_pcap_set_tstamp_type != NULL) {
return p_pcap_set_tstamp_type(a, b); return p_pcap_set_tstamp_type(a, b);
} }
@ -578,7 +579,7 @@ pcap_set_tstamp_type(pcap_t *a, int b) {
int int
pcap_set_tstamp_precision(pcap_t *a, int b) { pcap_set_tstamp_precision(pcap_t *a, int b) {
g_assert(has_wpcap); ws_assert(has_wpcap);
if (p_pcap_set_tstamp_precision != NULL) { if (p_pcap_set_tstamp_precision != NULL) {
return p_pcap_set_tstamp_precision(a, b); return p_pcap_set_tstamp_precision(a, b);
} }
@ -588,7 +589,7 @@ pcap_set_tstamp_precision(pcap_t *a, int b) {
int int
pcap_get_tstamp_precision(pcap_t *a) { pcap_get_tstamp_precision(pcap_t *a) {
g_assert(has_wpcap); ws_assert(has_wpcap);
if (p_pcap_get_tstamp_precision != NULL) { if (p_pcap_get_tstamp_precision != NULL) {
return p_pcap_get_tstamp_precision(a); return p_pcap_get_tstamp_precision(a);
} }
@ -598,7 +599,7 @@ pcap_get_tstamp_precision(pcap_t *a) {
int int
pcap_list_tstamp_types(pcap_t *a, int **b) { pcap_list_tstamp_types(pcap_t *a, int **b) {
g_assert(has_wpcap); ws_assert(has_wpcap);
if (p_pcap_list_tstamp_types != NULL) { if (p_pcap_list_tstamp_types != NULL) {
return p_pcap_list_tstamp_types(a, b); return p_pcap_list_tstamp_types(a, b);
} }
@ -607,7 +608,7 @@ pcap_list_tstamp_types(pcap_t *a, int **b) {
void void
pcap_free_tstamp_types(int *a) { pcap_free_tstamp_types(int *a) {
g_assert(has_wpcap); ws_assert(has_wpcap);
if (p_pcap_free_tstamp_types != NULL) { if (p_pcap_free_tstamp_types != NULL) {
p_pcap_free_tstamp_types(a); p_pcap_free_tstamp_types(a);
} }
@ -615,7 +616,7 @@ pcap_free_tstamp_types(int *a) {
int int
pcap_tstamp_type_name_to_val(const char *a) { 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) { if (p_pcap_tstamp_type_name_to_val != NULL) {
return p_pcap_tstamp_type_name_to_val(a); return p_pcap_tstamp_type_name_to_val(a);
} }
@ -624,7 +625,7 @@ pcap_tstamp_type_name_to_val(const char *a) {
const char * const char *
pcap_tstamp_type_val_to_name(int a) { 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) { if (p_pcap_tstamp_type_val_to_name != NULL) {
return p_pcap_tstamp_type_val_to_name(a); return p_pcap_tstamp_type_val_to_name(a);
} }
@ -633,7 +634,7 @@ pcap_tstamp_type_val_to_name(int a) {
const char * const char *
pcap_tstamp_type_val_to_description(int a) { 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) { if (p_pcap_tstamp_type_val_to_description != NULL) {
return p_pcap_tstamp_type_val_to_description(a); return p_pcap_tstamp_type_val_to_description(a);
} }
@ -663,7 +664,7 @@ pcap_list_datalinks(pcap_t *p, int **ddlt)
void void
pcap_free_datalinks(int *ddlt) pcap_free_datalinks(int *ddlt)
{ {
g_assert(has_wpcap); ws_assert(has_wpcap);
/* /*
* If we don't have pcap_free_datalinks() in WinPcap, * If we don't have pcap_free_datalinks() in WinPcap,
@ -703,7 +704,7 @@ void pcap_breakloop(pcap_t *a)
/* setbuff is win32 specific! */ /* setbuff is win32 specific! */
int pcap_setbuff(pcap_t *a, int b) int pcap_setbuff(pcap_t *a, int b)
{ {
g_assert(has_wpcap); ws_assert(has_wpcap);
return p_pcap_setbuff(a, b); 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) */ /* (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) 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); return p_pcap_next_ex(a, b, c);
} }

View File

@ -22,6 +22,7 @@
#include <wsutil/strtoi.h> #include <wsutil/strtoi.h>
#include <wsutil/wslog.h> #include <wsutil/wslog.h>
#include <wsutil/ws_assert.h>
#ifdef _WIN32 #ifdef _WIN32
#include <wsutil/unicode-utils.h> #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) */ /* convert header values (indicator and 3-byte length) */
static void 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 */ /* convert header values */
*indicator = header[0]; *indicator = header[0];
@ -1742,7 +1743,7 @@ sync_pipe_input_cb(gint source, gpointer user_data)
break; break;
} }
default: default:
g_assert_not_reached(); ws_assert_not_reached();
} }
return TRUE; return TRUE;
@ -1772,7 +1773,7 @@ sync_pipe_wait_for_child(ws_process_id fork_child, gchar **msgp)
start_time = g_get_monotonic_time(); start_time = g_get_monotonic_time();
ws_debug("wait till child closed"); 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 */ *msgp = NULL; /* assume no error */
#ifdef _WIN32 #ifdef _WIN32

View File

@ -29,6 +29,7 @@
#include <ui/exit_codes.h> #include <ui/exit_codes.h>
#include <wsutil/file_util.h> #include <wsutil/file_util.h>
#include <wsutil/ws_pipe.h> #include <wsutil/ws_pipe.h>
#include <wsutil/ws_assert.h>
#include "capture/capture_ifinfo.h" #include "capture/capture_ifinfo.h"
#include "capture/capture-pcap-util.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; break;
default: default:
/* the caller is responsible to send us only the right opt's */ /* the caller is responsible to send us only the right opt's */
g_assert_not_reached(); ws_assert_not_reached();
} }
return 0; return 0;

View File

@ -88,6 +88,7 @@
#include "wsutil/time_util.h" #include "wsutil/time_util.h"
#include "wsutil/please_report_bug.h" #include "wsutil/please_report_bug.h"
#include "wsutil/glib-compat.h" #include "wsutil/glib-compat.h"
#include <wsutil/ws_assert.h>
#include "capture/ws80211_utils.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++) { 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); 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); 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); g_free(idb_source->idb);
memset(idb_source, 0, sizeof(saved_idb_t)); memset(idb_source, 0, sizeof(saved_idb_t));
idb_source->deleted = TRUE; idb_source->deleted = TRUE;
@ -3361,7 +3362,7 @@ capture_loop_dispatch(loop_data *ld,
if (inpkts < 0) { if (inpkts < 0) {
ws_debug("%s: src %u pipe reached EOF or err, rcv: %u drop: %u flush: %u", 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_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); interface_opts = &g_array_index(capture_opts->ifaces, interface_options, i);
received = pcap_src->received; received = pcap_src->received;
if (pcap_src->pcap_h != NULL) { 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. */ /* Get the capture statistics, so we know how many packets were dropped. */
if (pcap_stats(pcap_src->pcap_h, stats) >= 0) { if (pcap_stats(pcap_src->pcap_h, stats) >= 0) {
*stats_known = TRUE; *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. * 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 /* We may be called multiple times from pcap_dispatch(); if we've set
the "stop capturing" flag, ignore this packet, as we're not 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)) { if (!pcapng_adjust_block(pcap_src, bh, pd)) {
ws_info("%s failed to adjust pcapng block.", G_STRFUNC); ws_info("%s failed to adjust pcapng block.", G_STRFUNC);
g_assert_not_reached(); ws_assert_not_reached();
return; return;
} }

View File

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

View File

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

View File

@ -21,6 +21,7 @@
#include <errno.h> #include <errno.h>
#include <wsutil/strtoi.h> #include <wsutil/strtoi.h>
#include <wsutil/ws_assert.h>
/* /*
* Win32 doesn't have SIGALRM (and it's the OS where name lookup calls * Win32 doesn't have SIGALRM (and it's the OS where name lookup calls
@ -818,7 +819,7 @@ static void
initialize_services(void) initialize_services(void)
{ {
gboolean parse_file = TRUE; 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); serv_port_hashtable = wmem_map_new(wmem_epan_scope(), g_direct_hash, g_direct_equal);
/* Compute the pathname of the services file. */ /* Compute the pathname of the services file. */
@ -906,7 +907,7 @@ parse_enterprises_file(const char * path)
static void static void
initialize_enterprises(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); enterprises_hashtable = g_hash_table_new_full(NULL, NULL, NULL, g_free);
if (g_enterprises_path == NULL) { if (g_enterprises_path == NULL) {
@ -957,10 +958,10 @@ enterprises_base_custom(char *buf, guint32 value)
static void static void
enterprises_cleanup(void) enterprises_cleanup(void)
{ {
g_assert(enterprises_hashtable); ws_assert(enterprises_hashtable);
g_hash_table_destroy(enterprises_hashtable); g_hash_table_destroy(enterprises_hashtable);
enterprises_hashtable = NULL; enterprises_hashtable = NULL;
g_assert(g_enterprises_path); ws_assert(g_enterprises_path);
g_free(g_enterprises_path); g_free(g_enterprises_path);
g_enterprises_path = NULL; g_enterprises_path = NULL;
g_free(g_penterprises_path); g_free(g_penterprises_path);
@ -1870,7 +1871,7 @@ eth_addr_resolve(hashether_t *tp) {
tp->status = HASHETHER_STATUS_RESOLVED_DUMMY; tp->status = HASHETHER_STATUS_RESOLVED_DUMMY;
return tp; return tp;
} }
g_assert_not_reached(); ws_assert_not_reached();
} /* eth_addr_resolve */ } /* eth_addr_resolve */
static hashether_t * static hashether_t *
@ -2208,7 +2209,7 @@ get_vlannamebyid(guint16 id)
static void static void
initialize_vlans(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); 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 /* 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) */ /* Note that we run from 31 (length 32) to 0 (length 1) */
--i; --i;
g_assert(i < SUBNETLENGTHSIZE); ws_assert(i < SUBNETLENGTHSIZE);
length_entry = &subnet_length_entries[i]; 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; sub_net_hashipv4_t * tp;
gsize hash_idx; 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]; entry = &subnet_length_entries[mask_length - 1];
@ -2779,7 +2780,7 @@ ss7pc_name_lookup_init(void)
{ {
char *ss7pcspath; 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); 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; char *hostspath;
guint i; 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); 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); 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); 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()); async_dns_queue_head = wmem_list_new(wmem_epan_scope());
if (manually_resolved_ipv4_list == NULL) 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); return wmem_strdup_printf(scope, "%u", port);
} }
port_str = serv_name_lookup(proto, 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); 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); return g_snprintf(buf, buf_size, "%u", port);
} }
port_str = serv_name_lookup(proto, 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); return g_snprintf(buf, buf_size, "%s (%u)", port_str, port);
} }

View File

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

View File

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

View File

@ -17,6 +17,7 @@
#include "packet.h" #include "packet.h"
#include "capture_dissectors.h" #include "capture_dissectors.h"
#include <wsutil/ws_assert.h>
#include <wsutil/wslog.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; capture_dissector_handle_t handle;
/* Make sure the registration is unique */ /* 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); handle = new_capture_dissector_handle(dissector, proto, name);
g_hash_table_insert(registered_dissectors, (gpointer)name, handle); 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 */ /* 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); 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/filesystem.h>
#include <wsutil/file_util.h> #include <wsutil/file_util.h>
#include <wsutil/wslog.h> #include <wsutil/wslog.h>
#include <wsutil/ws_assert.h>
#include <epan/packet.h> #include <epan/packet.h>
#include "color_filters.h" #include "color_filters.h"
@ -84,8 +85,8 @@ color_filters_add_tmp(GSList **cfl)
color_t bg_color, fg_color; color_t bg_color, fg_color;
color_filter_t *colorf; color_filter_t *colorf;
g_assert(strlen(prefs.gui_colorized_fg)==69); ws_assert(strlen(prefs.gui_colorized_fg)==69);
g_assert(strlen(prefs.gui_colorized_bg)==69); ws_assert(strlen(prefs.gui_colorized_bg)==69);
fg_colors = g_strsplit(prefs.gui_colorized_fg, ",", -1); fg_colors = g_strsplit(prefs.gui_colorized_fg, ",", -1);
bg_colors = g_strsplit(prefs.gui_colorized_bg, ",", -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 **err_msg = (gchar**)err;
gchar *local_err_msg = NULL; 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 the filter is disabled it doesn't matter if it compiles or not. */
if (colorf->disabled) return; if (colorf->disabled) return;
@ -417,7 +418,7 @@ color_filter_compile_cb(gpointer filter_arg, gpointer err)
g_free(local_err_msg); g_free(local_err_msg);
/* this filter was compilable before, so this should never happen */ /* this filter was compilable before, so this should never happen */
/* except if the OK button of the parent window has been clicked */ /* 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 **err_msg = (gchar**)err;
gchar *local_err_msg; 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 the filter is disabled it doesn't matter if it compiles or not. */
if (colorf->disabled) return; if (colorf->disabled) return;

View File

@ -33,6 +33,7 @@
#include <epan/dfilter/dfilter.h> #include <epan/dfilter/dfilter.h>
#include <wsutil/utf8_entities.h> #include <wsutil/utf8_entities.h>
#include <wsutil/ws_assert.h>
#ifdef HAVE_LUA #ifdef HAVE_LUA
#include <epan/wslua/wslua.h> #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; tsprecision = fd->tsprec;
break; break;
default: default:
g_assert_not_reached(); ws_assert_not_reached();
} }
switch (tsprecision) { switch (tsprecision) {
case WTAP_TSPREC_SEC: 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); fd->abs_ts.nsecs);
break; break;
default: default:
g_assert_not_reached(); ws_assert_not_reached();
} }
} else { } else {
buf[0] = '\0'; buf[0] = '\0';
@ -1046,7 +1047,7 @@ set_abs_ydoy_time(const frame_data *fd, gchar *buf, char *decimal_point, gboolea
tsprecision = fd->tsprec; tsprecision = fd->tsprec;
break; break;
default: default:
g_assert_not_reached(); ws_assert_not_reached();
} }
switch (tsprecision) { switch (tsprecision) {
case WTAP_TSPREC_SEC: 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); fd->abs_ts.nsecs);
break; break;
default: default:
g_assert_not_reached(); ws_assert_not_reached();
} }
} else { } else {
buf[0] = '\0'; buf[0] = '\0';
@ -1163,7 +1164,7 @@ set_time_seconds(const frame_data *fd, const nstime_t *ts, gchar *buf)
tsprecision = fd->tsprec; tsprecision = fd->tsprec;
break; break;
default: default:
g_assert_not_reached(); ws_assert_not_reached();
} }
switch (tsprecision) { switch (tsprecision) {
case WTAP_TSPREC_SEC: 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); (gint64) ts->secs, ts->nsecs, TO_STR_TIME_RES_T_NSECS);
break; break;
default: 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; tsprecision = fd->tsprec;
break; break;
default: default:
g_assert_not_reached(); ws_assert_not_reached();
} }
switch (tsprecision) { switch (tsprecision) {
case WTAP_TSPREC_SEC: 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; break;
default: 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]); set_time_seconds(fd, &del_rel_ts, cinfo->col_expr.col_expr_val[col]);
break; break;
default: default:
g_assert_not_reached(); ws_assert_not_reached();
} }
cinfo->columns[col].col_data = cinfo->columns[col].col_buf; 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]); set_time_seconds(fd, &del_cap_ts, cinfo->col_expr.col_expr_val[col]);
break; break;
default: default:
g_assert_not_reached(); ws_assert_not_reached();
} }
cinfo->columns[col].col_data = cinfo->columns[col].col_buf; 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]); set_time_seconds(fd, &del_dis_ts, cinfo->col_expr.col_expr_val[col]);
break; break;
default: default:
g_assert_not_reached(); ws_assert_not_reached();
} }
cinfo->columns[col].col_data = cinfo->columns[col].col_buf; 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; tsprecision = fd->tsprec;
break; break;
default: default:
g_assert_not_reached(); ws_assert_not_reached();
} }
switch (tsprecision) { switch (tsprecision) {
case WTAP_TSPREC_SEC: 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); fd->abs_ts.nsecs);
break; break;
default: default:
g_assert_not_reached(); ws_assert_not_reached();
} }
} else { } else {
@ -1614,7 +1615,7 @@ set_epoch_time(const frame_data *fd, gchar *buf)
tsprecision = fd->tsprec; tsprecision = fd->tsprec;
break; break;
default: default:
g_assert_not_reached(); ws_assert_not_reached();
} }
switch (tsprecision) { switch (tsprecision) {
case WTAP_TSPREC_SEC: 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); fd->abs_ts.secs, fd->abs_ts.nsecs, TO_STR_TIME_RES_T_NSECS);
break; break;
default: default:
g_assert_not_reached(); ws_assert_not_reached();
} }
return TRUE; 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); set_time_seconds(fd, &del_rel_ts, buf);
break; break;
default: default:
g_assert_not_reached(); ws_assert_not_reached();
} }
} else { } else {
buf[0] = '\0'; 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); set_time_hour_min_sec(fd, &del_cap_ts, buf, col_decimal_point);
break; break;
default: default:
g_assert_not_reached(); ws_assert_not_reached();
} }
} else { } else {
buf[0] = '\0'; 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); set_time_hour_min_sec(fd, &del_dis_ts, buf, col_decimal_point);
break; break;
default: default:
g_assert_not_reached(); ws_assert_not_reached();
} }
} else { } else {
buf[0] = '\0'; buf[0] = '\0';
@ -1755,7 +1756,7 @@ set_fd_time(const epan_t *epan, frame_data *fd, gchar *buf)
case TS_NOT_SET: case TS_NOT_SET:
/* code is missing for this case, but I don't know which [jmayer20051219] */ /* code is missing for this case, but I don't know which [jmayer20051219] */
g_assert_not_reached(); ws_assert_not_reached();
break; break;
} }
} }
@ -1806,7 +1807,7 @@ col_set_cls_time(const frame_data *fd, column_info *cinfo, const gint col)
case TS_NOT_SET: case TS_NOT_SET:
/* code is missing for this case, but I don't know which [jmayer20051219] */ /* code is missing for this case, but I don't know which [jmayer20051219] */
g_assert_not_reached(); ws_assert_not_reached();
break; break;
} }
} }
@ -1859,7 +1860,7 @@ col_set_fmt_time(const frame_data *fd, column_info *cinfo, const gint fmt, const
break; break;
default: default:
g_assert_not_reached(); ws_assert_not_reached();
break; 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); (gint64) ts->secs, ts->nsecs, TO_STR_TIME_RES_T_NSECS);
break; break;
default: default:
g_assert_not_reached(); ws_assert_not_reached();
} }
col_item->col_data = col_item->col_buf; col_item->col_data = col_item->col_buf;
cinfo->col_expr.col_expr[col] = fieldname; 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 gboolean
col_based_on_frame_data(column_info *cinfo, const gint col) col_based_on_frame_data(column_info *cinfo, const gint col)
{ {
g_assert(cinfo); ws_assert(cinfo);
g_assert(col < cinfo->num_cols); ws_assert(col < cinfo->num_cols);
switch (cinfo->columns[col].col_fmt) { switch (cinfo->columns[col].col_fmt) {
case COL_NUMBER: case COL_NUMBER:
@ -2236,11 +2237,11 @@ col_fill_in(packet_info *pinfo, const gboolean fill_col_exprs, const gboolean fi
break; break;
case NUM_COL_FMTS: /* keep compiler happy - shouldn't get here */ case NUM_COL_FMTS: /* keep compiler happy - shouldn't get here */
g_assert_not_reached(); ws_assert_not_reached();
break; break;
default: default:
if (col_item->col_fmt >= NUM_COL_FMTS) { 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 * 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"; col_item->col_data = "Read error";
} else { } else {
if (col_item->col_fmt >= NUM_COL_FMTS) { 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 * No dissection was done, and these columns are set as the

View File

@ -23,6 +23,7 @@
#include <epan/dfilter/dfilter.h> #include <epan/dfilter/dfilter.h>
#include <epan/column.h> #include <epan/column.h>
#include <epan/packet.h> #include <epan/packet.h>
#include <wsutil/ws_assert.h>
/* Given a format number (as defined in column-utils.h), returns its equivalent /* Given a format number (as defined in column-utils.h), returns its equivalent
string */ string */
@ -171,7 +172,7 @@ col_format_desc(const gint fmt_num) {
}; };
const gchar *val_str = try_val_to_str(fmt_num, dlist_vals); 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; 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"; return "0000-00-00 00:00:00.000000000";
break; break;
default: default:
g_assert_not_reached(); ws_assert_not_reached();
} }
break; break;
case(TS_ABSOLUTE_WITH_YDOY): 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"; return "0000/000 00:00:00.000000000";
break; break;
default: default:
g_assert_not_reached(); ws_assert_not_reached();
} }
break; break;
case(TS_ABSOLUTE): case(TS_ABSOLUTE):
@ -346,7 +347,7 @@ get_timestamp_column_longest_string(const gint type, const gint precision)
return "00:00:00.000000000"; return "00:00:00.000000000";
break; break;
default: default:
g_assert_not_reached(); ws_assert_not_reached();
} }
break; break;
case(TS_RELATIVE): /* fallthrough */ case(TS_RELATIVE): /* fallthrough */
@ -373,7 +374,7 @@ get_timestamp_column_longest_string(const gint type, const gint precision)
return "0000.000000000"; return "0000.000000000";
break; break;
default: default:
g_assert_not_reached(); ws_assert_not_reached();
} }
break; break;
case(TS_EPOCH): case(TS_EPOCH):
@ -399,14 +400,14 @@ get_timestamp_column_longest_string(const gint type, const gint precision)
return "0000000000000000000.000000000"; return "0000000000000000000.000000000";
break; break;
default: default:
g_assert_not_reached(); ws_assert_not_reached();
} }
break; break;
case(TS_NOT_SET): case(TS_NOT_SET):
return "0000.000000"; return "0000.000000";
break; break;
default: default:
g_assert_not_reached(); ws_assert_not_reached();
} }
/* never reached, satisfy compiler */ /* never reached, satisfy compiler */

View File

@ -22,6 +22,7 @@
#include <stdio.h> #include <stdio.h>
#include <stdlib.h> #include <stdlib.h>
#include <errno.h> #include <errno.h>
#include <wsutil/ws_assert.h>
GList *decode_as_list = NULL; GList *decode_as_list = NULL;
@ -30,9 +31,9 @@ void register_decode_as(decode_as_t* reg)
dissector_table_t decode_table; dissector_table_t decode_table;
/* Ensure valid functions */ /* Ensure valid functions */
g_assert(reg->populate_list); ws_assert(reg->populate_list);
g_assert(reg->reset_value); ws_assert(reg->reset_value);
g_assert(reg->change_value); ws_assert(reg->change_value);
decode_table = find_dissector_table(reg->table_name); decode_table = find_dissector_table(reg->table_name);
if (decode_table != NULL) if (decode_table != NULL)
@ -368,7 +369,7 @@ decode_as_write_entry (const gchar *table_name, ftenum_t selector_type,
break; break;
default: default:
g_assert_not_reached(); ws_assert_not_reached();
break; break;
} }
@ -478,7 +479,7 @@ decode_build_reset_list (const gchar *table_name, ftenum_t selector_type,
break; break;
default: default:
g_assert_not_reached(); ws_assert_not_reached();
} }
dissector_reset_list = g_slist_prepend(dissector_reset_list, item); dissector_reset_list = g_slist_prepend(dissector_reset_list, item);
} }
@ -519,7 +520,7 @@ decode_clear_all(void)
break; break;
default: default:
g_assert_not_reached(); ws_assert_not_reached();
} }
g_free(item->ddi_table_name); g_free(item->ddi_table_name);
g_free(item); g_free(item);

View File

@ -22,6 +22,7 @@
#include "dfilter-macro.h" #include "dfilter-macro.h"
#include "scanner_lex.h" #include "scanner_lex.h"
#include <wsutil/wslog.h> #include <wsutil/wslog.h>
#include <wsutil/ws_assert.h>
#define DFILTER_TOKEN_ID_OFFSET 1 #define DFILTER_TOKEN_ID_OFFSET 1
@ -212,7 +213,7 @@ dfilter_compile(const gchar *text, dfilter_t **dfp, gchar **err_msg)
/* XXX, GHashTable */ /* XXX, GHashTable */
GPtrArray *deprecated; GPtrArray *deprecated;
g_assert(dfp); ws_assert(dfp);
if (!text) { if (!text) {
*dfp = NULL; *dfp = NULL;

View File

@ -18,6 +18,7 @@
#include <ftypes/ftypes-int.h> #include <ftypes/ftypes-int.h>
#include <ftypes/ftypes.h> #include <ftypes/ftypes.h>
#include <epan/exceptions.h> #include <epan/exceptions.h>
#include <wsutil/ws_assert.h>
/* Convert an FT_STRING using a callback function */ /* Convert an FT_STRING using a callback function */
static gboolean static gboolean
@ -191,7 +192,7 @@ ul_semcheck_params(dfwork_t *dfw, int param_num, stnode_t *st_node)
} }
} }
else { else {
g_assert_not_reached(); ws_assert_not_reached();
} }
} }
@ -213,7 +214,7 @@ ul_semcheck_len_params(dfwork_t *dfw, int param_num, stnode_t *st_node)
} }
} }
else { else {
g_assert_not_reached(); ws_assert_not_reached();
} }
} }
@ -234,7 +235,7 @@ ul_semcheck_field_param(dfwork_t *dfw, int param_num, stnode_t *st_node)
} }
} }
else { else {
g_assert_not_reached(); ws_assert_not_reached();
} }
} }
@ -300,7 +301,7 @@ ul_semcheck_string_param(dfwork_t *dfw, int param_num, stnode_t *st_node)
} }
} }
else { else {
g_assert_not_reached(); ws_assert_not_reached();
} }
} }

View File

@ -11,6 +11,7 @@
#include "dfvm.h" #include "dfvm.h"
#include <ftypes/ftypes-int.h> #include <ftypes/ftypes-int.h>
#include <wsutil/ws_assert.h>
dfvm_insn_t* dfvm_insn_t*
dfvm_insn_new(dfvm_opcode_t op) dfvm_insn_new(dfvm_opcode_t op)
@ -133,7 +134,7 @@ dfvm_dump(FILE *f, dfilter_t *df)
case IF_TRUE_GOTO: case IF_TRUE_GOTO:
case IF_FALSE_GOTO: case IF_FALSE_GOTO:
default: default:
g_assert_not_reached(); ws_assert_not_reached();
break; break;
} }
} }
@ -175,7 +176,7 @@ dfvm_dump(FILE *f, dfilter_t *df)
case PUT_FVALUE: case PUT_FVALUE:
/* We already dumped these */ /* We already dumped these */
g_assert_not_reached(); ws_assert_not_reached();
break; break;
case PUT_PCRE: case PUT_PCRE:
@ -292,7 +293,7 @@ dfvm_dump(FILE *f, dfilter_t *df)
break; break;
default: default:
g_assert_not_reached(); ws_assert_not_reached();
break; break;
} }
} }
@ -429,8 +430,8 @@ any_in_range(dfilter_t *df, int reg1, int reg2, int reg3)
* the list length MUST be one. This should have been enforced by * the list length MUST be one. This should have been enforced by
* grammar.lemon. * grammar.lemon.
*/ */
g_assert(list_low && !g_list_next(list_low)); ws_assert(list_low && !g_list_next(list_low));
g_assert(list_high && !g_list_next(list_high)); ws_assert(list_high && !g_list_next(list_high));
low = (fvalue_t *)list_low->data; low = (fvalue_t *)list_low->data;
high = (fvalue_t *)list_high->data; high = (fvalue_t *)list_high->data;
@ -490,7 +491,7 @@ mk_range(dfilter_t *df, int from_reg, int to_reg, drange_t *d_range)
/* Assert here because semcheck.c should have /* Assert here because semcheck.c should have
* already caught the cases in which a slice * already caught the cases in which a slice
* cannot be made. */ * cannot be made. */
g_assert(new_fv); ws_assert(new_fv);
to_list = g_list_append(to_list, new_fv); to_list = g_list_append(to_list, new_fv);
from_list = g_list_next(from_list); from_list = g_list_next(from_list);
@ -516,7 +517,7 @@ dfvm_apply(dfilter_t *df, proto_tree *tree)
GList *param1; GList *param1;
GList *param2; GList *param2;
g_assert(tree); ws_assert(tree);
length = df->insns->len; length = df->insns->len;
@ -662,12 +663,12 @@ dfvm_apply(dfilter_t *df, proto_tree *tree)
#endif #endif
default: default:
g_assert_not_reached(); ws_assert_not_reached();
break; break;
} }
} }
g_assert_not_reached(); ws_assert_not_reached();
return FALSE; /* to appease the compiler */ return FALSE; /* to appease the compiler */
} }
@ -715,7 +716,7 @@ dfvm_init_const(dfilter_t *df)
case IF_TRUE_GOTO: case IF_TRUE_GOTO:
case IF_FALSE_GOTO: case IF_FALSE_GOTO:
default: default:
g_assert_not_reached(); ws_assert_not_reached();
break; break;
} }
} }

View File

@ -12,6 +12,7 @@
#include "config.h" #include "config.h"
#include "drange.h" #include "drange.h"
#include <wsutil/ws_assert.h>
/* drange_node constructor */ /* drange_node constructor */
drange_node* drange_node*
@ -54,28 +55,28 @@ drange_node_free(drange_node* drnode)
gint gint
drange_node_get_start_offset(drange_node* drnode) drange_node_get_start_offset(drange_node* drnode)
{ {
g_assert(drnode->ending != DRANGE_NODE_END_T_UNINITIALIZED); ws_assert(drnode->ending != DRANGE_NODE_END_T_UNINITIALIZED);
return drnode->start_offset; return drnode->start_offset;
} }
gint gint
drange_node_get_length(drange_node* drnode) drange_node_get_length(drange_node* drnode)
{ {
g_assert(drnode->ending == DRANGE_NODE_END_T_LENGTH); ws_assert(drnode->ending == DRANGE_NODE_END_T_LENGTH);
return drnode->length; return drnode->length;
} }
gint gint
drange_node_get_end_offset(drange_node* drnode) drange_node_get_end_offset(drange_node* drnode)
{ {
g_assert(drnode->ending == DRANGE_NODE_END_T_OFFSET); ws_assert(drnode->ending == DRANGE_NODE_END_T_OFFSET);
return drnode->end_offset; return drnode->end_offset;
} }
drange_node_end_t drange_node_end_t
drange_node_get_ending(drange_node* drnode) drange_node_get_ending(drange_node* drnode)
{ {
g_assert(drnode->ending != DRANGE_NODE_END_T_UNINITIALIZED); ws_assert(drnode->ending != DRANGE_NODE_END_T_UNINITIALIZED);
return drnode->ending; return drnode->ending;
} }

View File

@ -17,6 +17,7 @@
#include "sttype-set.h" #include "sttype-set.h"
#include "sttype-function.h" #include "sttype-function.h"
#include "ftypes/ftypes.h" #include "ftypes/ftypes.h"
#include <wsutil/ws_assert.h>
static void static void
gencode(dfwork_t *dfw, stnode_t *st_node); gencode(dfwork_t *dfw, stnode_t *st_node);
@ -198,7 +199,7 @@ dfw_append_function(dfwork_t *dfw, stnode_t *node, dfvm_value_t **p_jmp)
insn->arg4 = val; insn->arg4 = val;
break; break;
default: default:
g_assert_not_reached(); ws_assert_not_reached();
} }
params = params->next; params = params->next;
@ -221,7 +222,7 @@ dfw_append_function(dfwork_t *dfw, stnode_t *node, dfvm_value_t **p_jmp)
/* We need another instruction to jump to another exit /* We need another instruction to jump to another exit
* place, if the call() of our function failed for some reaosn */ * place, if the call() of our function failed for some reaosn */
insn = dfvm_insn_new(IF_FALSE_GOTO); insn = dfvm_insn_new(IF_FALSE_GOTO);
g_assert(p_jmp); ws_assert(p_jmp);
*p_jmp = dfvm_value_new(INSN_NUMBER); *p_jmp = dfvm_value_new(INSN_NUMBER);
insn->arg1 = *p_jmp; insn->arg1 = *p_jmp;
dfw_append_insn(dfw, insn); dfw_append_insn(dfw, insn);
@ -411,7 +412,7 @@ gen_entity(dfwork_t *dfw, stnode_t *st_arg, dfvm_value_t **p_jmp)
reg = dfw_append_read_tree(dfw, hfinfo); reg = dfw_append_read_tree(dfw, hfinfo);
insn = dfvm_insn_new(IF_FALSE_GOTO); insn = dfvm_insn_new(IF_FALSE_GOTO);
g_assert(p_jmp); ws_assert(p_jmp);
*p_jmp = dfvm_value_new(INSN_NUMBER); *p_jmp = dfvm_value_new(INSN_NUMBER);
insn->arg1 = *p_jmp; insn->arg1 = *p_jmp;
dfw_append_insn(dfw, insn); dfw_append_insn(dfw, insn);
@ -430,7 +431,7 @@ gen_entity(dfwork_t *dfw, stnode_t *st_arg, dfvm_value_t **p_jmp)
} }
else { else {
/* printf("sttype_id is %u\n", (unsigned)e_type); */ /* printf("sttype_id is %u\n", (unsigned)e_type); */
g_assert_not_reached(); ws_assert_not_reached();
} }
return reg; return reg;
} }
@ -450,7 +451,7 @@ gen_test(dfwork_t *dfw, stnode_t *st_node)
switch (st_op) { switch (st_op) {
case TEST_OP_UNINITIALIZED: case TEST_OP_UNINITIALIZED:
g_assert_not_reached(); ws_assert_not_reached();
break; break;
case TEST_OP_EXISTS: case TEST_OP_EXISTS:
@ -560,7 +561,7 @@ gencode(dfwork_t *dfw, stnode_t *st_node)
gen_test(dfw, st_node); gen_test(dfw, st_node);
break; break;
default: default:
g_assert_not_reached(); ws_assert_not_reached();
} }
} }

View File

@ -119,7 +119,7 @@ any "error" symbols are shifted, if possible. */
case STTYPE_RANGE: case STTYPE_RANGE:
case STTYPE_FVALUE: case STTYPE_FVALUE:
case STTYPE_PCRE: case STTYPE_PCRE:
g_assert_not_reached(); ws_assert_not_reached();
break; break;
} }
dfw->syntax_error = TRUE; dfw->syntax_error = TRUE;
@ -280,7 +280,7 @@ relation_test(T) ::= entity(E) rel_op2(O) relation_test(R).
F = R; F = R;
do { do {
g_assert(F != NULL && stnode_type_id(F) == STTYPE_TEST); ws_assert(F != NULL && stnode_type_id(F) == STTYPE_TEST);
sttype_test_get(F, NULL, &F, NULL); sttype_test_get(F, NULL, &F, NULL);
} while (stnode_type_id(F) == STTYPE_TEST); } while (stnode_type_id(F) == STTYPE_TEST);

View File

@ -474,7 +474,7 @@ simple(int token)
case TOKEN_TEST_IN: case TOKEN_TEST_IN:
break; break;
default: default:
g_assert_not_reached(); ws_assert_not_reached();
} }
return token; return token;
} }
@ -501,7 +501,7 @@ set_lval(int token, gpointer data)
type_id = STTYPE_FUNCTION; type_id = STTYPE_FUNCTION;
break; break;
default: default:
g_assert_not_reached(); ws_assert_not_reached();
} }
stnode_init(df_lval, type_id, data); stnode_init(df_lval, type_id, data);
return token; return token;
@ -522,7 +522,7 @@ set_lval_int(dfwork_t *dfw, int token, char *s)
type_id = STTYPE_INTEGER; type_id = STTYPE_INTEGER;
break; break;
default: default:
g_assert_not_reached(); ws_assert_not_reached();
} }
stnode_init_int(df_lval, type_id, val); stnode_init_int(df_lval, type_id, val);

View File

@ -21,6 +21,8 @@
#include <epan/exceptions.h> #include <epan/exceptions.h>
#include <epan/packet.h> #include <epan/packet.h>
#include <wsutil/ws_assert.h>
#include <ftypes/ftypes-int.h> #include <ftypes/ftypes-int.h>
/* Enable debug logging by defining AM_CFLAGS /* Enable debug logging by defining AM_CFLAGS
@ -130,10 +132,10 @@ compatible_ftypes(ftenum_t a, ftenum_t b)
} }
case FT_NUM_TYPES: case FT_NUM_TYPES:
g_assert_not_reached(); ws_assert_not_reached();
} }
g_assert_not_reached(); ws_assert_not_reached();
return FALSE; return FALSE;
} }
@ -242,7 +244,7 @@ mk_fvalue_from_val_string(dfwork_t *dfw, header_field_info *hfinfo, char *s)
break; break;
case FT_NUM_TYPES: case FT_NUM_TYPES:
g_assert_not_reached(); ws_assert_not_reached();
} }
/* TRUE/FALSE *always* exist for FT_BOOLEAN. */ /* TRUE/FALSE *always* exist for FT_BOOLEAN. */
@ -381,10 +383,10 @@ is_bytes_type(enum ftenum type)
return FALSE; return FALSE;
case FT_NUM_TYPES: case FT_NUM_TYPES:
g_assert_not_reached(); ws_assert_not_reached();
} }
g_assert_not_reached(); ws_assert_not_reached();
return FALSE; return FALSE;
} }
@ -476,7 +478,7 @@ check_exists(dfwork_t *dfw, stnode_t *st_arg1)
case STTYPE_SET: case STTYPE_SET:
case STTYPE_PCRE: case STTYPE_PCRE:
case STTYPE_NUM_TYPES: case STTYPE_NUM_TYPES:
g_assert_not_reached(); ws_assert_not_reached();
} }
} }
@ -571,7 +573,7 @@ check_drange_node_sanity(gpointer data, gpointer user_data)
case DRANGE_NODE_END_T_UNINITIALIZED: case DRANGE_NODE_END_T_UNINITIALIZED:
default: default:
g_assert_not_reached(); ws_assert_not_reached();
} }
} }
@ -810,7 +812,7 @@ check_relation_LHS_FIELD(dfwork_t *dfw, const char *relation_string,
GSList *nodelist; GSList *nodelist;
/* A set should only ever appear on RHS of 'in' operation */ /* A set should only ever appear on RHS of 'in' operation */
if (strcmp(relation_string, "in") != 0) { if (strcmp(relation_string, "in") != 0) {
g_assert_not_reached(); ws_assert_not_reached();
} }
/* Attempt to interpret one element of the set at a time. Each /* Attempt to interpret one element of the set at a time. Each
* element is represented by two items in the list, the element * element is represented by two items in the list, the element
@ -827,7 +829,7 @@ check_relation_LHS_FIELD(dfwork_t *dfw, const char *relation_string,
} }
nodelist = g_slist_next(nodelist); nodelist = g_slist_next(nodelist);
g_assert(nodelist); ws_assert(nodelist);
stnode_t *node_right = (stnode_t *)nodelist->data; stnode_t *node_right = (stnode_t *)nodelist->data;
if (node_right) { if (node_right) {
/* range type, check if comparison is possible. */ /* range type, check if comparison is possible. */
@ -849,7 +851,7 @@ check_relation_LHS_FIELD(dfwork_t *dfw, const char *relation_string,
} }
} }
else { else {
g_assert_not_reached(); ws_assert_not_reached();
} }
} }
@ -943,7 +945,7 @@ check_relation_LHS_STRING(dfwork_t *dfw, const char* relation_string,
THROW(TypeError); THROW(TypeError);
} }
else { else {
g_assert_not_reached(); ws_assert_not_reached();
} }
} }
@ -1037,7 +1039,7 @@ check_relation_LHS_UNPARSED(dfwork_t *dfw, const char* relation_string,
THROW(TypeError); THROW(TypeError);
} }
else { else {
g_assert_not_reached(); ws_assert_not_reached();
} }
} }
@ -1240,7 +1242,7 @@ check_relation_LHS_RANGE(dfwork_t *dfw, const char *relation_string,
THROW(TypeError); THROW(TypeError);
} }
else { else {
g_assert_not_reached(); ws_assert_not_reached();
} }
} }
@ -1401,7 +1403,7 @@ check_relation_LHS_FUNCTION(dfwork_t *dfw, const char *relation_string,
THROW(TypeError); THROW(TypeError);
} }
else { else {
g_assert_not_reached(); ws_assert_not_reached();
} }
} }
@ -1463,7 +1465,7 @@ header_field_info *hfinfo;
case STTYPE_FVALUE: case STTYPE_FVALUE:
case STTYPE_SET: case STTYPE_SET:
default: default:
g_assert_not_reached(); ws_assert_not_reached();
} }
} }
@ -1483,7 +1485,7 @@ check_test(dfwork_t *dfw, stnode_t *st_node, GPtrArray *deprecated)
switch (st_op) { switch (st_op) {
case TEST_OP_UNINITIALIZED: case TEST_OP_UNINITIALIZED:
g_assert_not_reached(); ws_assert_not_reached();
break; break;
case TEST_OP_EXISTS: case TEST_OP_EXISTS:
@ -1550,7 +1552,7 @@ check_test(dfwork_t *dfw, stnode_t *st_node, GPtrArray *deprecated)
break; break;
default: default:
g_assert_not_reached(); ws_assert_not_reached();
} }
DebugLog((" 3 check_test(stnode_t *st_node = %p) [%u] - End\n", st_node, i++)); DebugLog((" 3 check_test(stnode_t *st_node = %p) [%u] - End\n", st_node, i++));
} }
@ -1571,7 +1573,7 @@ semcheck(dfwork_t *dfw, stnode_t *st_node, GPtrArray *deprecated)
check_test(dfw, st_node, deprecated); check_test(dfw, st_node, deprecated);
break; break;
default: default:
g_assert_not_reached(); ws_assert_not_reached();
} }
} }

View File

@ -10,6 +10,7 @@
#include "syntax-tree.h" #include "syntax-tree.h"
#include "sttype-function.h" #include "sttype-function.h"
#include <wsutil/ws_assert.h>
typedef struct { typedef struct {
guint32 magic; guint32 magic;
@ -24,7 +25,7 @@ function_new(gpointer funcdef)
{ {
function_t *stfuncrec; function_t *stfuncrec;
g_assert(funcdef != NULL); ws_assert(funcdef != NULL);
stfuncrec = g_new(function_t, 1); stfuncrec = g_new(function_t, 1);
@ -67,7 +68,7 @@ static void
function_free(gpointer value) function_free(gpointer value)
{ {
function_t *stfuncrec = (function_t*)value; function_t *stfuncrec = (function_t*)value;
assert_magic(stfuncrec, FUNCTION_MAGIC); ws_assert_magic(stfuncrec, FUNCTION_MAGIC);
st_funcparams_free(stfuncrec->params); st_funcparams_free(stfuncrec->params);
g_free(stfuncrec); g_free(stfuncrec);
} }
@ -81,7 +82,7 @@ sttype_function_set_params(stnode_t *node, GSList *params)
function_t *stfuncrec; function_t *stfuncrec;
stfuncrec = (function_t*)stnode_data(node); stfuncrec = (function_t*)stnode_data(node);
assert_magic(stfuncrec, FUNCTION_MAGIC); ws_assert_magic(stfuncrec, FUNCTION_MAGIC);
stfuncrec->params = params; stfuncrec->params = params;
} }
@ -93,7 +94,7 @@ sttype_function_funcdef(stnode_t *node)
function_t *stfuncrec; function_t *stfuncrec;
stfuncrec = (function_t*)stnode_data(node); stfuncrec = (function_t*)stnode_data(node);
assert_magic(stfuncrec, FUNCTION_MAGIC); ws_assert_magic(stfuncrec, FUNCTION_MAGIC);
return stfuncrec->funcdef; return stfuncrec->funcdef;
} }
@ -104,7 +105,7 @@ sttype_function_params(stnode_t *node)
function_t *stfuncrec; function_t *stfuncrec;
stfuncrec = (function_t*)stnode_data(node); stfuncrec = (function_t*)stnode_data(node);
assert_magic(stfuncrec, FUNCTION_MAGIC); ws_assert_magic(stfuncrec, FUNCTION_MAGIC);
return stfuncrec->params; return stfuncrec->params;
} }

View File

@ -18,6 +18,7 @@
#include <epan/proto.h> #include <epan/proto.h>
#include "drange.h" #include "drange.h"
#include "sttype-range.h" #include "sttype-range.h"
#include <wsutil/ws_assert.h>
typedef struct { typedef struct {
guint32 magic; guint32 magic;
@ -28,11 +29,11 @@ typedef struct {
#define RANGE_MAGIC 0xec0990ce #define RANGE_MAGIC 0xec0990ce
static gpointer static gpointer
range_new(gpointer junk) range_new(gpointer junk _U_)
{ {
range_t *range; range_t *range;
g_assert(junk == NULL); ws_assert(junk == NULL);
range = g_new(range_t, 1); range = g_new(range_t, 1);
@ -60,7 +61,7 @@ static void
range_free(gpointer value) range_free(gpointer value)
{ {
range_t *range = (range_t*)value; range_t *range = (range_t*)value;
assert_magic(range, RANGE_MAGIC); ws_assert_magic(range, RANGE_MAGIC);
if (range->drange) if (range->drange)
drange_free(range->drange); drange_free(range->drange);
@ -77,7 +78,7 @@ sttype_range_remove_drange(stnode_t *node)
range_t *range; range_t *range;
range = (range_t*)stnode_data(node); range = (range_t*)stnode_data(node);
assert_magic(range, RANGE_MAGIC); ws_assert_magic(range, RANGE_MAGIC);
range->drange = NULL; range->drange = NULL;
} }
@ -90,7 +91,7 @@ sttype_range_set(stnode_t *node, stnode_t *entity, GSList* drange_list)
range_t *range; range_t *range;
range = (range_t*)stnode_data(node); range = (range_t*)stnode_data(node);
assert_magic(range, RANGE_MAGIC); ws_assert_magic(range, RANGE_MAGIC);
range->entity = entity; range->entity = entity;

View File

@ -9,6 +9,7 @@
#include "config.h" #include "config.h"
#include "syntax-tree.h" #include "syntax-tree.h"
#include <wsutil/ws_assert.h>
/* Keep track of sttype_t's via their sttype_id_t number */ /* Keep track of sttype_t's via their sttype_id_t number */
static sttype_t* type_list[STTYPE_NUM_TYPES]; static sttype_t* type_list[STTYPE_NUM_TYPES];
@ -44,10 +45,10 @@ sttype_register(sttype_t *type)
type_id = type->id; type_id = type->id;
/* Check input */ /* Check input */
g_assert(type_id < STTYPE_NUM_TYPES); ws_assert(type_id < STTYPE_NUM_TYPES);
/* Don't re-register. */ /* Don't re-register. */
g_assert(type_list[type_id] == NULL); ws_assert(type_list[type_id] == NULL);
type_list[type_id] = type; type_list[type_id] = type;
} }
@ -58,12 +59,12 @@ sttype_lookup(sttype_id_t type_id)
sttype_t *result; sttype_t *result;
/* Check input */ /* Check input */
g_assert(type_id < STTYPE_NUM_TYPES); ws_assert(type_id < STTYPE_NUM_TYPES);
result = type_list[type_id]; result = type_list[type_id];
/* Check output. */ /* Check output. */
g_assert(result != NULL); ws_assert(result != NULL);
return result; return result;
} }
@ -86,7 +87,7 @@ stnode_new(sttype_id_t type_id, gpointer data)
} }
else { else {
type = sttype_lookup(type_id); type = sttype_lookup(type_id);
g_assert(type); ws_assert(type);
node->type = type; node->type = type;
if (type->func_new) { if (type->func_new) {
node->data = type->func_new(data); node->data = type->func_new(data);
@ -136,12 +137,12 @@ stnode_init(stnode_t *node, sttype_id_t type_id, gpointer data)
{ {
sttype_t *type; sttype_t *type;
assert_magic(node, STNODE_MAGIC); ws_assert_magic(node, STNODE_MAGIC);
g_assert(!node->type); ws_assert(!node->type);
g_assert(!node->data); ws_assert(!node->data);
type = sttype_lookup(type_id); type = sttype_lookup(type_id);
g_assert(type); ws_assert(type);
node->type = type; node->type = type;
if (type->func_new) { if (type->func_new) {
node->data = type->func_new(data); node->data = type->func_new(data);
@ -161,14 +162,14 @@ stnode_init_int(stnode_t *node, sttype_id_t type_id, gint32 value)
void void
stnode_free(stnode_t *node) stnode_free(stnode_t *node)
{ {
assert_magic(node, STNODE_MAGIC); ws_assert_magic(node, STNODE_MAGIC);
if (node->type) { if (node->type) {
if (node->type->func_free) { if (node->type->func_free) {
node->type->func_free(node->data); node->type->func_free(node->data);
} }
} }
else { else {
g_assert(!node->data); ws_assert(!node->data);
} }
g_free(node); g_free(node);
} }
@ -176,7 +177,7 @@ stnode_free(stnode_t *node)
const char* const char*
stnode_type_name(stnode_t *node) stnode_type_name(stnode_t *node)
{ {
assert_magic(node, STNODE_MAGIC); ws_assert_magic(node, STNODE_MAGIC);
if (node->type) if (node->type)
return node->type->name; return node->type->name;
else else
@ -186,7 +187,7 @@ stnode_type_name(stnode_t *node)
sttype_id_t sttype_id_t
stnode_type_id(stnode_t *node) stnode_type_id(stnode_t *node)
{ {
assert_magic(node, STNODE_MAGIC); ws_assert_magic(node, STNODE_MAGIC);
if (node->type) if (node->type)
return node->type->id; return node->type->id;
else else
@ -196,16 +197,16 @@ stnode_type_id(stnode_t *node)
gpointer gpointer
stnode_data(stnode_t *node) stnode_data(stnode_t *node)
{ {
assert_magic(node, STNODE_MAGIC); ws_assert_magic(node, STNODE_MAGIC);
return node->data; return node->data;
} }
gpointer gpointer
stnode_steal_data(stnode_t *node) stnode_steal_data(stnode_t *node)
{ {
assert_magic(node, STNODE_MAGIC); ws_assert_magic(node, STNODE_MAGIC);
gpointer data = node->data; gpointer data = node->data;
g_assert(data); ws_assert(data);
node->data = NULL; node->data = NULL;
return data; return data;
} }
@ -213,7 +214,7 @@ stnode_steal_data(stnode_t *node)
gint32 gint32
stnode_value(stnode_t *node) stnode_value(stnode_t *node)
{ {
assert_magic(node, STNODE_MAGIC); ws_assert_magic(node, STNODE_MAGIC);
return node->value; return node->value;
} }

View File

@ -113,20 +113,26 @@ const char *
stnode_deprecated(stnode_t *node); stnode_deprecated(stnode_t *node);
#define assert_magic(obj, mnum) \ #define assert_magic(obj, mnum) \
g_assert((obj)); \ g_assert_true((obj)); \
if ((obj)->magic != (mnum)) { \ if ((obj)->magic != (mnum)) { \
g_print("\nMagic num is 0x%08x, but should be 0x%08x", \ g_print("\nMagic num is 0x%08x, but should be 0x%08x", \
(obj)->magic, (mnum)); \ (obj)->magic, (mnum)); \
g_assert((obj)->magic == (mnum)); \ g_assert_true((obj)->magic == (mnum)); \
} }
#ifdef WS_DEBUG
#define ws_assert_magic(obj, mnum) assert_magic(obj, mnum)
#else
#define ws_assert_magic(obj, mnum)
#endif
#define STTYPE_ACCESSOR(ret,type,attr,magicnum) \ #define STTYPE_ACCESSOR(ret,type,attr,magicnum) \
ret \ ret \
CONCAT(CONCAT(CONCAT(sttype_,type),_),attr) (stnode_t *node) \ CONCAT(CONCAT(CONCAT(sttype_,type),_),attr) (stnode_t *node) \
{\ {\
CONCAT(type,_t) *value; \ CONCAT(type,_t) *value; \
value = (CONCAT(type,_t) *)stnode_data(node);\ value = (CONCAT(type,_t) *)stnode_data(node);\
assert_magic(value, magicnum); \ ws_assert_magic(value, magicnum); \
return value->attr; \ return value->attr; \
} }

View File

@ -30,6 +30,7 @@
#include <wsutil/wsgcrypt.h> #include <wsutil/wsgcrypt.h>
#include <wsutil/str_util.h> #include <wsutil/str_util.h>
#include <wsutil/wslog.h> #include <wsutil/wslog.h>
#include <wsutil/ws_assert.h>
#include <epan/proto_data.h> #include <epan/proto_data.h>
#include <epan/addr_resolv.h> #include <epan/addr_resolv.h>
#include <wmem/wmem.h> #include <wmem/wmem.h>

View File

@ -7079,7 +7079,7 @@ ncp2222_compile_dfilters(void)
g_error("NCP dissector failed to compile dfilter \"%s\": %s\n", g_error("NCP dissector failed to compile dfilter \"%s\": %s\n",
req_conds[i].dfilter_text, err_msg); req_conds[i].dfilter_text, err_msg);
g_free(err_msg); g_free(err_msg);
g_assert_not_reached(); ws_assert_not_reached();
} }
} }
} }

View File

@ -5767,7 +5767,7 @@ dissect_scsi_rsp(tvbuff_t *tvb, packet_info *pinfo,
cdata->type = SCSI_PDU_TYPE_RSP; cdata->type = SCSI_PDU_TYPE_RSP;
tap_queue_packet(scsi_tap, pinfo, cdata); tap_queue_packet(scsi_tap, pinfo, cdata);
csdata = get_cmdset_data(itlq, itl); /* will g_assert if itlq is null */ csdata = get_cmdset_data(itlq, itl);
/* Nothing really to do here, just print some stuff passed to us /* Nothing really to do here, just print some stuff passed to us
*/ */

View File

@ -34,6 +34,7 @@
#include <wsutil/str_util.h> #include <wsutil/str_util.h>
#include <wsutil/wsgcrypt.h> #include <wsutil/wsgcrypt.h>
#include <wsutil/pint.h> #include <wsutil/pint.h>
#include <wsutil/ws_assert.h>
#include "packet-tcp.h" #include "packet-tcp.h"
#include "packet-ip.h" #include "packet-ip.h"

View File

@ -40,6 +40,7 @@
#include <wsutil/strtoi.h> #include <wsutil/strtoi.h>
#include <wsutil/wsgcrypt.h> #include <wsutil/wsgcrypt.h>
#include <wsutil/rsa.h> #include <wsutil/rsa.h>
#include <wsutil/ws_assert.h>
#include <version_info.h> #include <version_info.h>
#include "packet-ber.h" #include "packet-ber.h"
#include "packet-x509af.h" #include "packet-x509af.h"
@ -4715,7 +4716,7 @@ tls_decrypt_aead_record(SslDecryptSession *ssl, SslDecoder *decoder,
/* struct { opaque salt[4]; opaque nonce_explicit[8] } CCMNonce (RFC 6655) */ /* struct { opaque salt[4]; opaque nonce_explicit[8] } CCMNonce (RFC 6655) */
nonce_with_counter[IMPLICIT_NONCE_LEN + EXPLICIT_NONCE_LEN + 3] = 1; nonce_with_counter[IMPLICIT_NONCE_LEN + EXPLICIT_NONCE_LEN + 3] = 1;
} else { } else {
g_assert_not_reached(); ws_assert_not_reached();
} }
#endif #endif
} else if (version == TLSV1DOT3_VERSION || cipher_mode == MODE_POLY1305) { } else if (version == TLSV1DOT3_VERSION || cipher_mode == MODE_POLY1305) {
@ -5813,7 +5814,7 @@ tls13_load_secret(SslDecryptSession *ssl, ssl_master_key_map_t *mk_map,
} }
break; break;
default: default:
g_assert_not_reached(); ws_assert_not_reached();
} }
/* Transitioning to new keys, mark old ones as unusable. */ /* Transitioning to new keys, mark old ones as unusable. */

View File

@ -66,6 +66,7 @@
#include <wsutil/str_util.h> #include <wsutil/str_util.h>
#include <wsutil/strtoi.h> #include <wsutil/strtoi.h>
#include <wsutil/rsa.h> #include <wsutil/rsa.h>
#include <wsutil/ws_assert.h>
#include "packet-tcp.h" #include "packet-tcp.h"
#include "packet-x509af.h" #include "packet-x509af.h"
#include "packet-tls.h" #include "packet-tls.h"
@ -3872,7 +3873,7 @@ tls13_get_quic_secret(packet_info *pinfo, gboolean is_from_server, int type, gui
} }
break; break;
default: default:
g_assert_not_reached(); ws_assert_not_reached();
} }
StringInfo *secret = (StringInfo *)g_hash_table_lookup(key_map, &ssl->client_random); StringInfo *secret = (StringInfo *)g_hash_table_lookup(key_map, &ssl->client_random);

View File

@ -32,6 +32,7 @@
#include <wsutil/nstime.h> #include <wsutil/nstime.h>
#include <wsutil/wslog.h> #include <wsutil/wslog.h>
#include <wsutil/ws_assert.h>
#include "conversation.h" #include "conversation.h"
#include "except.h" #include "except.h"
@ -519,7 +520,7 @@ epan_set_always_visible(gboolean force)
void void
epan_dissect_init(epan_dissect_t *edt, epan_t *session, const gboolean create_proto_tree, const gboolean proto_tree_visible) epan_dissect_init(epan_dissect_t *edt, epan_t *session, const gboolean create_proto_tree, const gboolean proto_tree_visible)
{ {
g_assert(edt); ws_assert(edt);
edt->session = session; edt->session = session;
@ -551,7 +552,7 @@ epan_dissect_reset(epan_dissect_t *edt)
/* We have to preserve the pool pointer across the memzeroing */ /* We have to preserve the pool pointer across the memzeroing */
wmem_allocator_t *tmp; wmem_allocator_t *tmp;
g_assert(edt); ws_assert(edt);
g_slist_free(edt->pi.proto_data); g_slist_free(edt->pi.proto_data);
g_slist_free(edt->pi.dependent_frames); g_slist_free(edt->pi.dependent_frames);
@ -652,7 +653,7 @@ epan_dissect_file_run_with_taps(epan_dissect_t *edt, wtap_rec *rec,
void void
epan_dissect_cleanup(epan_dissect_t* edt) epan_dissect_cleanup(epan_dissect_t* edt)
{ {
g_assert(edt); ws_assert(edt);
g_slist_foreach(epan_plugins, epan_plugin_dissect_cleanup, edt); g_slist_foreach(epan_plugins, epan_plugin_dissect_cleanup, edt);

View File

@ -12,6 +12,7 @@
#define __EXCEPTIONS_H__ #define __EXCEPTIONS_H__
#include "except.h" #include "except.h"
#include <wsutil/ws_assert.h>
/* Wireshark has only one exception group, to make these macros simple */ /* Wireshark has only one exception group, to make these macros simple */
#define XCEPT_GROUP_WIRESHARK 1 #define XCEPT_GROUP_WIRESHARK 1
@ -398,7 +399,7 @@
#define RETHROW \ #define RETHROW \
{ \ { \
/* check we're in a catch block */ \ /* check we're in a catch block */ \
g_assert(except_state == EXCEPT_CAUGHT); \ ws_assert(except_state == EXCEPT_CAUGHT); \
/* we can't use except_rethrow here, as that pops a catch block \ /* we can't use except_rethrow here, as that pops a catch block \
* off the stack, and we don't want to do that, because we want to \ * off the stack, and we don't want to do that, because we want to \
* excecute the FINALLY {} block first. \ * excecute the FINALLY {} block first. \

View File

@ -18,6 +18,7 @@
#include <epan/frame_data.h> #include <epan/frame_data.h>
#include <epan/column-utils.h> #include <epan/column-utils.h>
#include <epan/timestamp.h> #include <epan/timestamp.h>
#include <wsutil/ws_assert.h>
#define COMPARE_FRAME_NUM() ((fdata1->num < fdata2->num) ? -1 : \ #define COMPARE_FRAME_NUM() ((fdata1->num < fdata2->num) ? -1 : \
(fdata1->num > fdata2->num) ? 1 : \ (fdata1->num > fdata2->num) ? 1 : \
@ -214,7 +215,7 @@ frame_data_init(frame_data *fdata, guint32 num, const wtap_rec *rec,
} }
/* To save some memory, we coerce it into 4 bits */ /* To save some memory, we coerce it into 4 bits */
g_assert(rec->tsprec <= 0xF); ws_assert(rec->tsprec <= 0xF);
fdata->tsprec = (unsigned int)rec->tsprec; fdata->tsprec = (unsigned int)rec->tsprec;
fdata->abs_ts = rec->ts; fdata->abs_ts = rec->ts;
fdata->has_phdr_comment = (rec->opt_comment != NULL); fdata->has_phdr_comment = (rec->opt_comment != NULL);

View File

@ -15,6 +15,7 @@
#include <wsutil/glib-compat.h> #include <wsutil/glib-compat.h>
#include <epan/exceptions.h> #include <epan/exceptions.h>
#include <wsutil/ws_assert.h>
#define CMP_MATCHES cmp_matches #define CMP_MATCHES cmp_matches
@ -137,11 +138,11 @@ val_repr_len(fvalue_t *fv, ftrepr_t rtype, int field_display _U_)
} }
static void static void
val_to_repr(fvalue_t *fv, ftrepr_t rtype, int field_display _U_, char * volatile buf, unsigned int size _U_) val_to_repr(fvalue_t *fv, ftrepr_t rtype _U_, int field_display _U_, char * volatile buf, unsigned int size _U_)
{ {
guint length; guint length;
g_assert(rtype == FTREPR_DFILTER); ws_assert(rtype == FTREPR_DFILTER);
TRY { TRY {
length = tvb_captured_length(fv->value.protocol.tvb); length = tvb_captured_length(fv->value.protocol.tvb);

View File

@ -15,6 +15,7 @@
#define CMP_MATCHES cmp_matches #define CMP_MATCHES cmp_matches
#include <strutil.h> #include <strutil.h>
#include <wsutil/ws_assert.h>
static void static void
string_fvalue_new(fvalue_t *fv) string_fvalue_new(fvalue_t *fv)
@ -49,7 +50,7 @@ string_repr_len(fvalue_t *fv, ftrepr_t rtype, int field_display _U_)
case FTREPR_DFILTER: case FTREPR_DFILTER:
return escape_string_len(fv->value.string); return escape_string_len(fv->value.string);
} }
g_assert_not_reached(); ws_assert_not_reached();
return -1; return -1;
} }
@ -65,7 +66,7 @@ string_to_repr(fvalue_t *fv, ftrepr_t rtype, int field_display _U_, char *buf, u
escape_string(buf, fv->value.string); escape_string(buf, fv->value.string);
return; return;
} }
g_assert_not_reached(); ws_assert_not_reached();
} }

View File

@ -12,6 +12,7 @@
#include <glib.h> #include <glib.h>
#include "ftypes.h" #include "ftypes.h"
#include <wsutil/ws_assert.h>
/* Keep track of ftype_t's via their ftenum number */ /* Keep track of ftype_t's via their ftenum number */
static ftype_t* type_list[FT_NUM_TYPES]; static ftype_t* type_list[FT_NUM_TYPES];
@ -38,11 +39,11 @@ void
ftype_register(enum ftenum ftype, ftype_t *ft) ftype_register(enum ftenum ftype, ftype_t *ft)
{ {
/* Check input */ /* Check input */
g_assert(ftype < FT_NUM_TYPES); ws_assert(ftype < FT_NUM_TYPES);
g_assert(ftype == ft->ftype); ws_assert(ftype == ft->ftype);
/* Don't re-register. */ /* Don't re-register. */
g_assert(type_list[ftype] == NULL); ws_assert(type_list[ftype] == NULL);
type_list[ftype] = ft; type_list[ftype] = ft;
} }
@ -50,7 +51,7 @@ ftype_register(enum ftenum ftype, ftype_t *ft)
/* Given an ftenum number, return an ftype_t* */ /* Given an ftenum number, return an ftype_t* */
#define FTYPE_LOOKUP(ftype, result) \ #define FTYPE_LOOKUP(ftype, result) \
/* Check input */ \ /* Check input */ \
g_assert(ftype < FT_NUM_TYPES); \ ws_assert(ftype < FT_NUM_TYPES); \
result = type_list[ftype]; result = type_list[ftype];
@ -358,7 +359,7 @@ fvalue_length(fvalue_t *fv)
int int
fvalue_string_repr_len(fvalue_t *fv, ftrepr_t rtype, int field_display) fvalue_string_repr_len(fvalue_t *fv, ftrepr_t rtype, int field_display)
{ {
g_assert(fv->ftype->len_string_repr); ws_assert(fv->ftype->len_string_repr);
return fv->ftype->len_string_repr(fv, rtype, field_display); return fv->ftype->len_string_repr(fv, rtype, field_display);
} }
@ -451,10 +452,10 @@ slice_func(gpointer data, gpointer user_data)
length = end_offset - start_offset + 1; length = end_offset - start_offset + 1;
} }
else { else {
g_assert_not_reached(); ws_assert_not_reached();
} }
g_assert(start_offset >=0 && length > 0); ws_assert(start_offset >=0 && length > 0);
fv->ftype->slice(fv, slice_data->bytes, start_offset, length); fv->ftype->slice(fv, slice_data->bytes, start_offset, length);
} }
@ -486,64 +487,64 @@ fvalue_slice(fvalue_t *fv, drange_t *d_range)
void void
fvalue_set_byte_array(fvalue_t *fv, GByteArray *value) fvalue_set_byte_array(fvalue_t *fv, GByteArray *value)
{ {
g_assert(fv->ftype->ftype == FT_BYTES || ws_assert(fv->ftype->ftype == FT_BYTES ||
fv->ftype->ftype == FT_UINT_BYTES || fv->ftype->ftype == FT_UINT_BYTES ||
fv->ftype->ftype == FT_OID || fv->ftype->ftype == FT_OID ||
fv->ftype->ftype == FT_REL_OID || fv->ftype->ftype == FT_REL_OID ||
fv->ftype->ftype == FT_SYSTEM_ID); fv->ftype->ftype == FT_SYSTEM_ID);
g_assert(fv->ftype->set_value.set_value_byte_array); ws_assert(fv->ftype->set_value.set_value_byte_array);
fv->ftype->set_value.set_value_byte_array(fv, value); fv->ftype->set_value.set_value_byte_array(fv, value);
} }
void void
fvalue_set_bytes(fvalue_t *fv, const guint8 *value) fvalue_set_bytes(fvalue_t *fv, const guint8 *value)
{ {
g_assert(fv->ftype->ftype == FT_AX25 || ws_assert(fv->ftype->ftype == FT_AX25 ||
fv->ftype->ftype == FT_VINES || fv->ftype->ftype == FT_VINES ||
fv->ftype->ftype == FT_ETHER || fv->ftype->ftype == FT_ETHER ||
fv->ftype->ftype == FT_FCWWN || fv->ftype->ftype == FT_FCWWN ||
fv->ftype->ftype == FT_IPv6); fv->ftype->ftype == FT_IPv6);
g_assert(fv->ftype->set_value.set_value_bytes); ws_assert(fv->ftype->set_value.set_value_bytes);
fv->ftype->set_value.set_value_bytes(fv, value); fv->ftype->set_value.set_value_bytes(fv, value);
} }
void void
fvalue_set_guid(fvalue_t *fv, const e_guid_t *value) fvalue_set_guid(fvalue_t *fv, const e_guid_t *value)
{ {
g_assert(fv->ftype->ftype == FT_GUID); ws_assert(fv->ftype->ftype == FT_GUID);
g_assert(fv->ftype->set_value.set_value_guid); ws_assert(fv->ftype->set_value.set_value_guid);
fv->ftype->set_value.set_value_guid(fv, value); fv->ftype->set_value.set_value_guid(fv, value);
} }
void void
fvalue_set_time(fvalue_t *fv, const nstime_t *value) fvalue_set_time(fvalue_t *fv, const nstime_t *value)
{ {
g_assert(IS_FT_TIME(fv->ftype->ftype)); ws_assert(IS_FT_TIME(fv->ftype->ftype));
g_assert(fv->ftype->set_value.set_value_time); ws_assert(fv->ftype->set_value.set_value_time);
fv->ftype->set_value.set_value_time(fv, value); fv->ftype->set_value.set_value_time(fv, value);
} }
void void
fvalue_set_string(fvalue_t *fv, const gchar *value) fvalue_set_string(fvalue_t *fv, const gchar *value)
{ {
g_assert(IS_FT_STRING(fv->ftype->ftype) || ws_assert(IS_FT_STRING(fv->ftype->ftype) ||
fv->ftype->ftype == FT_UINT_STRING); fv->ftype->ftype == FT_UINT_STRING);
g_assert(fv->ftype->set_value.set_value_string); ws_assert(fv->ftype->set_value.set_value_string);
fv->ftype->set_value.set_value_string(fv, value); fv->ftype->set_value.set_value_string(fv, value);
} }
void void
fvalue_set_protocol(fvalue_t *fv, tvbuff_t *value, const gchar *name) fvalue_set_protocol(fvalue_t *fv, tvbuff_t *value, const gchar *name)
{ {
g_assert(fv->ftype->ftype == FT_PROTOCOL); ws_assert(fv->ftype->ftype == FT_PROTOCOL);
g_assert(fv->ftype->set_value.set_value_protocol); ws_assert(fv->ftype->set_value.set_value_protocol);
fv->ftype->set_value.set_value_protocol(fv, value, name); fv->ftype->set_value.set_value_protocol(fv, value, name);
} }
void void
fvalue_set_uinteger(fvalue_t *fv, guint32 value) fvalue_set_uinteger(fvalue_t *fv, guint32 value)
{ {
g_assert(fv->ftype->ftype == FT_IEEE_11073_SFLOAT || ws_assert(fv->ftype->ftype == FT_IEEE_11073_SFLOAT ||
fv->ftype->ftype == FT_IEEE_11073_FLOAT || fv->ftype->ftype == FT_IEEE_11073_FLOAT ||
fv->ftype->ftype == FT_CHAR || fv->ftype->ftype == FT_CHAR ||
fv->ftype->ftype == FT_UINT8 || fv->ftype->ftype == FT_UINT8 ||
@ -553,51 +554,51 @@ fvalue_set_uinteger(fvalue_t *fv, guint32 value)
fv->ftype->ftype == FT_IPXNET || fv->ftype->ftype == FT_IPXNET ||
fv->ftype->ftype == FT_FRAMENUM || fv->ftype->ftype == FT_FRAMENUM ||
fv->ftype->ftype == FT_IPv4); fv->ftype->ftype == FT_IPv4);
g_assert(fv->ftype->set_value.set_value_uinteger); ws_assert(fv->ftype->set_value.set_value_uinteger);
fv->ftype->set_value.set_value_uinteger(fv, value); fv->ftype->set_value.set_value_uinteger(fv, value);
} }
void void
fvalue_set_sinteger(fvalue_t *fv, gint32 value) fvalue_set_sinteger(fvalue_t *fv, gint32 value)
{ {
g_assert(fv->ftype->ftype == FT_INT8 || ws_assert(fv->ftype->ftype == FT_INT8 ||
fv->ftype->ftype == FT_INT16 || fv->ftype->ftype == FT_INT16 ||
fv->ftype->ftype == FT_INT24 || fv->ftype->ftype == FT_INT24 ||
fv->ftype->ftype == FT_INT32); fv->ftype->ftype == FT_INT32);
g_assert(fv->ftype->set_value.set_value_sinteger); ws_assert(fv->ftype->set_value.set_value_sinteger);
fv->ftype->set_value.set_value_sinteger(fv, value); fv->ftype->set_value.set_value_sinteger(fv, value);
} }
void void
fvalue_set_uinteger64(fvalue_t *fv, guint64 value) fvalue_set_uinteger64(fvalue_t *fv, guint64 value)
{ {
g_assert(fv->ftype->ftype == FT_UINT40 || ws_assert(fv->ftype->ftype == FT_UINT40 ||
fv->ftype->ftype == FT_UINT48 || fv->ftype->ftype == FT_UINT48 ||
fv->ftype->ftype == FT_UINT56 || fv->ftype->ftype == FT_UINT56 ||
fv->ftype->ftype == FT_UINT64 || fv->ftype->ftype == FT_UINT64 ||
fv->ftype->ftype == FT_BOOLEAN || fv->ftype->ftype == FT_BOOLEAN ||
fv->ftype->ftype == FT_EUI64); fv->ftype->ftype == FT_EUI64);
g_assert(fv->ftype->set_value.set_value_uinteger64); ws_assert(fv->ftype->set_value.set_value_uinteger64);
fv->ftype->set_value.set_value_uinteger64(fv, value); fv->ftype->set_value.set_value_uinteger64(fv, value);
} }
void void
fvalue_set_sinteger64(fvalue_t *fv, gint64 value) fvalue_set_sinteger64(fvalue_t *fv, gint64 value)
{ {
g_assert(fv->ftype->ftype == FT_INT40 || ws_assert(fv->ftype->ftype == FT_INT40 ||
fv->ftype->ftype == FT_INT48 || fv->ftype->ftype == FT_INT48 ||
fv->ftype->ftype == FT_INT56 || fv->ftype->ftype == FT_INT56 ||
fv->ftype->ftype == FT_INT64); fv->ftype->ftype == FT_INT64);
g_assert(fv->ftype->set_value.set_value_sinteger64); ws_assert(fv->ftype->set_value.set_value_sinteger64);
fv->ftype->set_value.set_value_sinteger64(fv, value); fv->ftype->set_value.set_value_sinteger64(fv, value);
} }
void void
fvalue_set_floating(fvalue_t *fv, gdouble value) fvalue_set_floating(fvalue_t *fv, gdouble value)
{ {
g_assert(fv->ftype->ftype == FT_FLOAT || ws_assert(fv->ftype->ftype == FT_FLOAT ||
fv->ftype->ftype == FT_DOUBLE); fv->ftype->ftype == FT_DOUBLE);
g_assert(fv->ftype->set_value.set_value_floating); ws_assert(fv->ftype->set_value.set_value_floating);
fv->ftype->set_value.set_value_floating(fv, value); fv->ftype->set_value.set_value_floating(fv, value);
} }
@ -605,7 +606,7 @@ fvalue_set_floating(fvalue_t *fv, gdouble value)
gpointer gpointer
fvalue_get(fvalue_t *fv) fvalue_get(fvalue_t *fv)
{ {
g_assert(fv->ftype->ftype == FT_BYTES || ws_assert(fv->ftype->ftype == FT_BYTES ||
fv->ftype->ftype == FT_UINT_BYTES || fv->ftype->ftype == FT_UINT_BYTES ||
fv->ftype->ftype == FT_AX25 || fv->ftype->ftype == FT_AX25 ||
fv->ftype->ftype == FT_VINES || fv->ftype->ftype == FT_VINES ||
@ -620,14 +621,14 @@ fvalue_get(fvalue_t *fv)
IS_FT_STRING(fv->ftype->ftype) || IS_FT_STRING(fv->ftype->ftype) ||
fv->ftype->ftype == FT_UINT_STRING || fv->ftype->ftype == FT_UINT_STRING ||
IS_FT_TIME(fv->ftype->ftype)); IS_FT_TIME(fv->ftype->ftype));
g_assert(fv->ftype->get_value.get_value_ptr); ws_assert(fv->ftype->get_value.get_value_ptr);
return fv->ftype->get_value.get_value_ptr(fv); return fv->ftype->get_value.get_value_ptr(fv);
} }
guint32 guint32
fvalue_get_uinteger(fvalue_t *fv) fvalue_get_uinteger(fvalue_t *fv)
{ {
g_assert(fv->ftype->ftype == FT_IEEE_11073_SFLOAT || ws_assert(fv->ftype->ftype == FT_IEEE_11073_SFLOAT ||
fv->ftype->ftype == FT_IEEE_11073_FLOAT || fv->ftype->ftype == FT_IEEE_11073_FLOAT ||
fv->ftype->ftype == FT_CHAR || fv->ftype->ftype == FT_CHAR ||
fv->ftype->ftype == FT_UINT8 || fv->ftype->ftype == FT_UINT8 ||
@ -637,51 +638,51 @@ fvalue_get_uinteger(fvalue_t *fv)
fv->ftype->ftype == FT_IPXNET || fv->ftype->ftype == FT_IPXNET ||
fv->ftype->ftype == FT_FRAMENUM || fv->ftype->ftype == FT_FRAMENUM ||
fv->ftype->ftype == FT_IPv4); fv->ftype->ftype == FT_IPv4);
g_assert(fv->ftype->get_value.get_value_uinteger); ws_assert(fv->ftype->get_value.get_value_uinteger);
return fv->ftype->get_value.get_value_uinteger(fv); return fv->ftype->get_value.get_value_uinteger(fv);
} }
gint32 gint32
fvalue_get_sinteger(fvalue_t *fv) fvalue_get_sinteger(fvalue_t *fv)
{ {
g_assert(fv->ftype->ftype == FT_INT8 || ws_assert(fv->ftype->ftype == FT_INT8 ||
fv->ftype->ftype == FT_INT16 || fv->ftype->ftype == FT_INT16 ||
fv->ftype->ftype == FT_INT24 || fv->ftype->ftype == FT_INT24 ||
fv->ftype->ftype == FT_INT32); fv->ftype->ftype == FT_INT32);
g_assert(fv->ftype->get_value.get_value_sinteger); ws_assert(fv->ftype->get_value.get_value_sinteger);
return fv->ftype->get_value.get_value_sinteger(fv); return fv->ftype->get_value.get_value_sinteger(fv);
} }
guint64 guint64
fvalue_get_uinteger64(fvalue_t *fv) fvalue_get_uinteger64(fvalue_t *fv)
{ {
g_assert(fv->ftype->ftype == FT_UINT40 || ws_assert(fv->ftype->ftype == FT_UINT40 ||
fv->ftype->ftype == FT_UINT48 || fv->ftype->ftype == FT_UINT48 ||
fv->ftype->ftype == FT_UINT56 || fv->ftype->ftype == FT_UINT56 ||
fv->ftype->ftype == FT_UINT64 || fv->ftype->ftype == FT_UINT64 ||
fv->ftype->ftype == FT_BOOLEAN || fv->ftype->ftype == FT_BOOLEAN ||
fv->ftype->ftype == FT_EUI64); fv->ftype->ftype == FT_EUI64);
g_assert(fv->ftype->get_value.get_value_uinteger64); ws_assert(fv->ftype->get_value.get_value_uinteger64);
return fv->ftype->get_value.get_value_uinteger64(fv); return fv->ftype->get_value.get_value_uinteger64(fv);
} }
gint64 gint64
fvalue_get_sinteger64(fvalue_t *fv) fvalue_get_sinteger64(fvalue_t *fv)
{ {
g_assert(fv->ftype->ftype == FT_INT40 || ws_assert(fv->ftype->ftype == FT_INT40 ||
fv->ftype->ftype == FT_INT48 || fv->ftype->ftype == FT_INT48 ||
fv->ftype->ftype == FT_INT56 || fv->ftype->ftype == FT_INT56 ||
fv->ftype->ftype == FT_INT64); fv->ftype->ftype == FT_INT64);
g_assert(fv->ftype->get_value.get_value_sinteger64); ws_assert(fv->ftype->get_value.get_value_sinteger64);
return fv->ftype->get_value.get_value_sinteger64(fv); return fv->ftype->get_value.get_value_sinteger64(fv);
} }
double double
fvalue_get_floating(fvalue_t *fv) fvalue_get_floating(fvalue_t *fv)
{ {
g_assert(fv->ftype->ftype == FT_FLOAT || ws_assert(fv->ftype->ftype == FT_FLOAT ||
fv->ftype->ftype == FT_DOUBLE); fv->ftype->ftype == FT_DOUBLE);
g_assert(fv->ftype->get_value.get_value_floating); ws_assert(fv->ftype->get_value.get_value_floating);
return fv->ftype->get_value.get_value_floating(fv); return fv->ftype->get_value.get_value_floating(fv);
} }
@ -689,7 +690,7 @@ gboolean
fvalue_eq(const fvalue_t *a, const fvalue_t *b) fvalue_eq(const fvalue_t *a, const fvalue_t *b)
{ {
/* XXX - check compatibility of a and b */ /* XXX - check compatibility of a and b */
g_assert(a->ftype->cmp_eq); ws_assert(a->ftype->cmp_eq);
return a->ftype->cmp_eq(a, b); return a->ftype->cmp_eq(a, b);
} }
@ -697,7 +698,7 @@ gboolean
fvalue_ne(const fvalue_t *a, const fvalue_t *b) fvalue_ne(const fvalue_t *a, const fvalue_t *b)
{ {
/* XXX - check compatibility of a and b */ /* XXX - check compatibility of a and b */
g_assert(a->ftype->cmp_ne); ws_assert(a->ftype->cmp_ne);
return a->ftype->cmp_ne(a, b); return a->ftype->cmp_ne(a, b);
} }
@ -705,7 +706,7 @@ gboolean
fvalue_gt(const fvalue_t *a, const fvalue_t *b) fvalue_gt(const fvalue_t *a, const fvalue_t *b)
{ {
/* XXX - check compatibility of a and b */ /* XXX - check compatibility of a and b */
g_assert(a->ftype->cmp_gt); ws_assert(a->ftype->cmp_gt);
return a->ftype->cmp_gt(a, b); return a->ftype->cmp_gt(a, b);
} }
@ -713,7 +714,7 @@ gboolean
fvalue_ge(const fvalue_t *a, const fvalue_t *b) fvalue_ge(const fvalue_t *a, const fvalue_t *b)
{ {
/* XXX - check compatibility of a and b */ /* XXX - check compatibility of a and b */
g_assert(a->ftype->cmp_ge); ws_assert(a->ftype->cmp_ge);
return a->ftype->cmp_ge(a, b); return a->ftype->cmp_ge(a, b);
} }
@ -721,7 +722,7 @@ gboolean
fvalue_lt(const fvalue_t *a, const fvalue_t *b) fvalue_lt(const fvalue_t *a, const fvalue_t *b)
{ {
/* XXX - check compatibility of a and b */ /* XXX - check compatibility of a and b */
g_assert(a->ftype->cmp_lt); ws_assert(a->ftype->cmp_lt);
return a->ftype->cmp_lt(a, b); return a->ftype->cmp_lt(a, b);
} }
@ -729,7 +730,7 @@ gboolean
fvalue_le(const fvalue_t *a, const fvalue_t *b) fvalue_le(const fvalue_t *a, const fvalue_t *b)
{ {
/* XXX - check compatibility of a and b */ /* XXX - check compatibility of a and b */
g_assert(a->ftype->cmp_le); ws_assert(a->ftype->cmp_le);
return a->ftype->cmp_le(a, b); return a->ftype->cmp_le(a, b);
} }
@ -737,7 +738,7 @@ gboolean
fvalue_bitwise_and(const fvalue_t *a, const fvalue_t *b) fvalue_bitwise_and(const fvalue_t *a, const fvalue_t *b)
{ {
/* XXX - check compatibility of a and b */ /* XXX - check compatibility of a and b */
g_assert(a->ftype->cmp_bitwise_and); ws_assert(a->ftype->cmp_bitwise_and);
return a->ftype->cmp_bitwise_and(a, b); return a->ftype->cmp_bitwise_and(a, b);
} }
@ -745,7 +746,7 @@ gboolean
fvalue_contains(const fvalue_t *a, const fvalue_t *b) fvalue_contains(const fvalue_t *a, const fvalue_t *b)
{ {
/* XXX - check compatibility of a and b */ /* XXX - check compatibility of a and b */
g_assert(a->ftype->cmp_contains); ws_assert(a->ftype->cmp_contains);
return a->ftype->cmp_contains(a, b); return a->ftype->cmp_contains(a, b);
} }
@ -753,7 +754,7 @@ gboolean
fvalue_matches(const fvalue_t *a, const GRegex *b) fvalue_matches(const fvalue_t *a, const GRegex *b)
{ {
/* XXX - check compatibility of a and b */ /* XXX - check compatibility of a and b */
g_assert(a->ftype->cmp_matches); ws_assert(a->ftype->cmp_matches);
return a->ftype->cmp_matches(a, b); return a->ftype->cmp_matches(a, b);
} }

View File

@ -25,6 +25,7 @@
#include "packet.h" #include "packet.h"
#include "wsutil/filesystem.h" #include "wsutil/filesystem.h"
#include "dissectors/packet-ber.h" #include "dissectors/packet-ber.h"
#include <wsutil/ws_assert.h>
#ifdef HAVE_LIBSMI #ifdef HAVE_LIBSMI
#include <smi.h> #include <smi.h>
@ -152,12 +153,12 @@ static oid_info_t* add_oid(const char* name, oid_kind_t kind, const oid_value_ty
c = n; c = n;
} while(++i); } while(++i);
g_assert_not_reached(); ws_assert_not_reached();
return NULL; return NULL;
} }
void oid_add(const char* name, guint oid_len, guint32 *subids) { void oid_add(const char* name, guint oid_len, guint32 *subids) {
g_assert(subids && *subids <= 2); ws_assert(subids && *subids <= 2);
if (oid_len) { if (oid_len) {
gchar* sub = oid_subid2string(NULL, subids,oid_len); gchar* sub = oid_subid2string(NULL, subids,oid_len);
D(3,("\tOid (from subids): %s %s ",name?name:"NULL", sub)); D(3,("\tOid (from subids): %s %s ",name?name:"NULL", sub));
@ -1038,7 +1039,7 @@ guint oid_encoded2subid_sub(wmem_allocator_t *scope, const guint8 *oid_bytes, gi
subid = 0; subid = 0;
} }
g_assert(subids == subid_overflow); ws_assert(subids == subid_overflow);
return n; return n;
} }

View File

@ -10,6 +10,7 @@
*/ */
#include "config.h" #include "config.h"
#undef G_DISABLE_ASSERT
#include <stdio.h> #include <stdio.h>
#include <string.h> #include <string.h>

View File

@ -41,6 +41,7 @@
#include <wsutil/str_util.h> #include <wsutil/str_util.h>
#include <wsutil/wslog.h> #include <wsutil/wslog.h>
#include <wsutil/ws_assert.h>
static gint proto_malformed = -1; static gint proto_malformed = -1;
static dissector_handle_t frame_handle = NULL; static dissector_handle_t frame_handle = NULL;
@ -219,16 +220,16 @@ void
packet_cache_proto_handles(void) packet_cache_proto_handles(void)
{ {
frame_handle = find_dissector("frame"); frame_handle = find_dissector("frame");
g_assert(frame_handle != NULL); ws_assert(frame_handle != NULL);
file_handle = find_dissector("file"); file_handle = find_dissector("file");
g_assert(file_handle != NULL); ws_assert(file_handle != NULL);
data_handle = find_dissector("data"); data_handle = find_dissector("data");
g_assert(data_handle != NULL); ws_assert(data_handle != NULL);
proto_malformed = proto_get_id_by_filter_name("_ws.malformed"); proto_malformed = proto_get_id_by_filter_name("_ws.malformed");
g_assert(proto_malformed != -1); ws_assert(proto_malformed != -1);
} }
/* List of routines that are called before we make a pass through a capture file /* List of routines that are called before we make a pass through a capture file
@ -517,7 +518,7 @@ dissect_record(epan_dissect_t *edt, int file_type_subtype,
* least be processed somewhere, we need to somehow * least be processed somewhere, we need to somehow
* indicate that to our caller. * indicate that to our caller.
*/ */
g_assert_not_reached(); ws_assert_not_reached();
break; break;
} }
@ -603,7 +604,7 @@ dissect_record(epan_dissect_t *edt, int file_type_subtype,
call_dissector_with_data(frame_handle, edt->tvb, &edt->pi, edt->tree, &frame_dissector_data); call_dissector_with_data(frame_handle, edt->tvb, &edt->pi, edt->tree, &frame_dissector_data);
} }
CATCH(BoundsError) { CATCH(BoundsError) {
g_assert_not_reached(); ws_assert_not_reached();
} }
CATCH2(FragmentBoundsError, ReportedBoundsError) { CATCH2(FragmentBoundsError, ReportedBoundsError) {
proto_tree_add_protocol_format(edt->tree, proto_malformed, edt->tvb, 0, 0, proto_tree_add_protocol_format(edt->tree, proto_malformed, edt->tvb, 0, 0,
@ -672,7 +673,7 @@ dissect_file(epan_dissect_t *edt, wtap_rec *rec,
} }
CATCH(BoundsError) { CATCH(BoundsError) {
g_assert_not_reached(); ws_assert_not_reached();
} }
CATCH3(FragmentBoundsError, ContainedBoundsError, ReportedBoundsError) { CATCH3(FragmentBoundsError, ContainedBoundsError, ReportedBoundsError) {
proto_tree_add_protocol_format(edt->tree, proto_malformed, edt->tvb, 0, 0, proto_tree_add_protocol_format(edt->tree, proto_malformed, edt->tvb, 0, 0,
@ -732,7 +733,7 @@ call_dissector_through_handle(dissector_handle_t handle, tvbuff_t *tvb,
len = ((dissector_cb_t)handle->dissector_func)(tvb, pinfo, tree, data, handle->dissector_data); len = ((dissector_cb_t)handle->dissector_func)(tvb, pinfo, tree, data, handle->dissector_data);
} }
else { else {
g_assert_not_reached(); ws_assert_not_reached();
} }
pinfo->current_proto = saved_proto; pinfo->current_proto = saved_proto;
@ -1001,7 +1002,7 @@ find_uint_dtbl_entry(dissector_table_t sub_dissectors, const guint32 pattern)
* But you can't do a uint lookup in any other types * But you can't do a uint lookup in any other types
* of tables. * of tables.
*/ */
g_assert_not_reached(); ws_assert_not_reached();
} }
/* /*
@ -1076,7 +1077,7 @@ dissector_add_uint(const char *name, const guint32 pattern, dissector_handle_t h
* But you can't do a uint lookup in any other types * But you can't do a uint lookup in any other types
* of tables. * of tables.
*/ */
g_assert_not_reached(); ws_assert_not_reached();
} }
#if 0 #if 0
@ -1212,7 +1213,7 @@ void dissector_add_uint_range_with_preference(const char *name, const char* rang
default: default:
ws_error("The dissector table %s (%s) is not an integer type - are you using a buggy plugin?", name, pref_dissector_table->ui_name); ws_error("The dissector table %s (%s) is not an integer type - are you using a buggy plugin?", name, pref_dissector_table->ui_name);
g_assert_not_reached(); ws_assert_not_reached();
} }
range_convert_str(wmem_epan_scope(), range, range_str, max_value); range_convert_str(wmem_epan_scope(), range, range_str, max_value);
@ -1238,7 +1239,7 @@ dissector_delete_uint(const char *name, const guint32 pattern,
dtbl_entry_t *dtbl_entry; dtbl_entry_t *dtbl_entry;
/* sanity check */ /* sanity check */
g_assert(sub_dissectors); ws_assert(sub_dissectors);
/* /*
* Find the entry. * Find the entry.
@ -1289,7 +1290,7 @@ dissector_delete_all_check (gpointer key _U_, gpointer value, gpointer user_data
void dissector_delete_all(const char *name, dissector_handle_t handle) void dissector_delete_all(const char *name, dissector_handle_t handle)
{ {
dissector_table_t sub_dissectors = find_dissector_table(name); dissector_table_t sub_dissectors = find_dissector_table(name);
g_assert (sub_dissectors); ws_assert (sub_dissectors);
g_hash_table_foreach_remove (sub_dissectors->hash_table, dissector_delete_all_check, handle); g_hash_table_foreach_remove (sub_dissectors->hash_table, dissector_delete_all_check, handle);
} }
@ -1298,7 +1299,7 @@ static void
dissector_delete_from_table(gpointer key _U_, gpointer value, gpointer user_data) dissector_delete_from_table(gpointer key _U_, gpointer value, gpointer user_data)
{ {
dissector_table_t sub_dissectors = (dissector_table_t) value; dissector_table_t sub_dissectors = (dissector_table_t) value;
g_assert (sub_dissectors); ws_assert (sub_dissectors);
g_hash_table_foreach_remove(sub_dissectors->hash_table, dissector_delete_all_check, user_data); g_hash_table_foreach_remove(sub_dissectors->hash_table, dissector_delete_all_check, user_data);
sub_dissectors->dissector_handles = g_slist_remove(sub_dissectors->dissector_handles, user_data); sub_dissectors->dissector_handles = g_slist_remove(sub_dissectors->dissector_handles, user_data);
@ -1320,7 +1321,7 @@ dissector_change_uint(const char *name, const guint32 pattern, dissector_handle_
dtbl_entry_t *dtbl_entry; dtbl_entry_t *dtbl_entry;
/* sanity check */ /* sanity check */
g_assert(sub_dissectors); ws_assert(sub_dissectors);
/* /*
* See if the entry already exists. If so, reuse it. * See if the entry already exists. If so, reuse it.
@ -1356,7 +1357,7 @@ dissector_reset_uint(const char *name, const guint32 pattern)
dtbl_entry_t *dtbl_entry; dtbl_entry_t *dtbl_entry;
/* sanity check */ /* sanity check */
g_assert(sub_dissectors); ws_assert(sub_dissectors);
/* /*
* Find the entry. * Find the entry.
@ -1496,7 +1497,7 @@ find_string_dtbl_entry(dissector_table_t const sub_dissectors, const gchar *patt
* But you can't do a string lookup in any other types * But you can't do a string lookup in any other types
* of tables. * of tables.
*/ */
g_assert_not_reached(); ws_assert_not_reached();
} }
if (sub_dissectors->param == TRUE) { if (sub_dissectors->param == TRUE) {
@ -1560,7 +1561,7 @@ dissector_add_string(const char *name, const gchar *pattern,
* But you can't do a string lookup in any other types * But you can't do a string lookup in any other types
* of tables. * of tables.
*/ */
g_assert_not_reached(); ws_assert_not_reached();
} }
dtbl_entry = g_new(dtbl_entry_t, 1); dtbl_entry = g_new(dtbl_entry_t, 1);
@ -1603,7 +1604,7 @@ dissector_delete_string(const char *name, const gchar *pattern,
dtbl_entry_t *dtbl_entry; dtbl_entry_t *dtbl_entry;
/* sanity check */ /* sanity check */
g_assert(sub_dissectors); ws_assert(sub_dissectors);
/* /*
* Find the entry. * Find the entry.
@ -1628,7 +1629,7 @@ dissector_change_string(const char *name, const gchar *pattern,
dtbl_entry_t *dtbl_entry; dtbl_entry_t *dtbl_entry;
/* sanity check */ /* sanity check */
g_assert(sub_dissectors); ws_assert(sub_dissectors);
/* /*
* See if the entry already exists. If so, reuse it. * See if the entry already exists. If so, reuse it.
@ -1664,7 +1665,7 @@ dissector_reset_string(const char *name, const gchar *pattern)
dtbl_entry_t *dtbl_entry; dtbl_entry_t *dtbl_entry;
/* sanity check */ /* sanity check */
g_assert(sub_dissectors); ws_assert(sub_dissectors);
/* /*
* Find the entry. * Find the entry.
@ -1807,7 +1808,7 @@ void dissector_add_custom_table_handle(const char *name, void *pattern, dissecto
return; return;
} }
g_assert(sub_dissectors->type == FT_BYTES); ws_assert(sub_dissectors->type == FT_BYTES);
dtbl_entry = g_new(dtbl_entry_t, 1); dtbl_entry = g_new(dtbl_entry_t, 1);
dtbl_entry->current = handle; dtbl_entry->current = handle;
@ -1864,7 +1865,7 @@ void dissector_add_guid(const char *name, guid_key* guid_val, dissector_handle_t
} }
if (sub_dissectors->type != FT_GUID) { if (sub_dissectors->type != FT_GUID) {
g_assert_not_reached(); ws_assert_not_reached();
} }
dtbl_entry = g_new(dtbl_entry_t, 1); dtbl_entry = g_new(dtbl_entry_t, 1);
@ -2230,8 +2231,8 @@ dissector_table_foreach_func (gpointer key, gpointer value, gpointer user_data)
dissector_foreach_info_t *info; dissector_foreach_info_t *info;
dtbl_entry_t *dtbl_entry; dtbl_entry_t *dtbl_entry;
g_assert(value); ws_assert(value);
g_assert(user_data); ws_assert(user_data);
dtbl_entry = (dtbl_entry_t *)value; dtbl_entry = (dtbl_entry_t *)value;
if (dtbl_entry->current == NULL || if (dtbl_entry->current == NULL ||
@ -2260,8 +2261,8 @@ dissector_all_tables_foreach_func (gpointer key, gpointer value, gpointer user_d
dissector_table_t sub_dissectors; dissector_table_t sub_dissectors;
dissector_foreach_info_t *info; dissector_foreach_info_t *info;
g_assert(value); ws_assert(value);
g_assert(user_data); ws_assert(user_data);
sub_dissectors = (dissector_table_t)value; sub_dissectors = (dissector_table_t)value;
info = (dissector_foreach_info_t *)user_data; info = (dissector_foreach_info_t *)user_data;
@ -2331,8 +2332,8 @@ dissector_table_foreach_changed_func (gpointer key, gpointer value, gpointer use
dtbl_entry_t *dtbl_entry; dtbl_entry_t *dtbl_entry;
dissector_foreach_info_t *info; dissector_foreach_info_t *info;
g_assert(value); ws_assert(value);
g_assert(user_data); ws_assert(user_data);
dtbl_entry = (dtbl_entry_t *)value; dtbl_entry = (dtbl_entry_t *)value;
if (dtbl_entry->initial == dtbl_entry->current) { if (dtbl_entry->initial == dtbl_entry->current) {
@ -2506,7 +2507,7 @@ register_dissector_table(const char *name, const char *ui_name, const int proto,
default: default:
ws_error("The dissector table %s (%s) is registering an unsupported type - are you using a buggy plugin?", name, ui_name); ws_error("The dissector table %s (%s) is registering an unsupported type - are you using a buggy plugin?", name, ui_name);
g_assert_not_reached(); ws_assert_not_reached();
} }
sub_dissectors->dissector_handles = NULL; sub_dissectors->dissector_handles = NULL;
sub_dissectors->ui_name = ui_name; sub_dissectors->ui_name = ui_name;
@ -2745,7 +2746,7 @@ heur_dissector_delete(const char *name, heur_dissector_t dissector, const int pr
GSList *found_entry; GSList *found_entry;
/* sanity check */ /* sanity check */
g_assert(sub_dissectors != NULL); ws_assert(sub_dissectors != NULL);
hdtbl_entry.dissector = dissector; hdtbl_entry.dissector = dissector;
hdtbl_entry.protocol = find_protocol_by_id(proto); hdtbl_entry.protocol = find_protocol_by_id(proto);
@ -2889,8 +2890,8 @@ heur_dissector_table_foreach_func (gpointer data, gpointer user_data)
{ {
heur_dissector_foreach_info_t *info; heur_dissector_foreach_info_t *info;
g_assert(data); ws_assert(data);
g_assert(user_data); ws_assert(user_data);
info = (heur_dissector_foreach_info_t *)user_data; info = (heur_dissector_foreach_info_t *)user_data;
info->caller_func(info->table_name, (heur_dtbl_entry_t *)data, info->caller_func(info->table_name, (heur_dtbl_entry_t *)data,
@ -3160,7 +3161,7 @@ static dissector_handle_t
register_dissector_handle(const char *name, dissector_handle_t handle) register_dissector_handle(const char *name, dissector_handle_t handle)
{ {
/* Make sure the registration is unique */ /* 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);
g_hash_table_insert(registered_dissectors, (gpointer)name, handle); g_hash_table_insert(registered_dissectors, (gpointer)name, handle);
@ -3390,7 +3391,7 @@ gboolean deregister_depend_dissector(const char* parent, const char* dependent)
depend_dissector_list_t sub_dissectors = find_depend_dissector_list(parent); depend_dissector_list_t sub_dissectors = find_depend_dissector_list(parent);
/* sanity check */ /* sanity check */
g_assert(sub_dissectors != NULL); ws_assert(sub_dissectors != NULL);
return remove_depend_dissector_from_list(sub_dissectors, dependent); return remove_depend_dissector_from_list(sub_dissectors, dependent);
} }
@ -3424,7 +3425,7 @@ dissector_dump_decodes_display(const gchar *table_name,
gint proto_id; gint proto_id;
const gchar *decode_as; const gchar *decode_as;
g_assert(sub_dissectors); ws_assert(sub_dissectors);
switch (sub_dissectors->type) { switch (sub_dissectors->type) {
case FT_UINT8: case FT_UINT8:
@ -3432,16 +3433,16 @@ dissector_dump_decodes_display(const gchar *table_name,
case FT_UINT24: case FT_UINT24:
case FT_UINT32: case FT_UINT32:
dtbl_entry = (dtbl_entry_t *)value; dtbl_entry = (dtbl_entry_t *)value;
g_assert(dtbl_entry); ws_assert(dtbl_entry);
handle = dtbl_entry->current; handle = dtbl_entry->current;
g_assert(handle); ws_assert(handle);
proto_id = dissector_handle_get_protocol_index(handle); proto_id = dissector_handle_get_protocol_index(handle);
if (proto_id != -1) { if (proto_id != -1) {
decode_as = proto_get_protocol_filter_name(proto_id); decode_as = proto_get_protocol_filter_name(proto_id);
g_assert(decode_as != NULL); ws_assert(decode_as != NULL);
printf("%s\t%u\t%s\n", table_name, selector, decode_as); printf("%s\t%u\t%s\n", table_name, selector, decode_as);
} }
break; break;

View File

@ -20,6 +20,7 @@
#include <glib.h> #include <glib.h>
#include <epan/epan.h> #include <epan/epan.h>
#include <epan/proto.h> #include <epan/proto.h>
#include <wsutil/ws_assert.h>
#include "plugin_if.h" #include "plugin_if.h"
@ -61,16 +62,16 @@ extern ext_menu_t * ext_menubar_register_menu(int proto_id, const gchar * menula
gchar * name = NULL; gchar * name = NULL;
/* A name for the entry must be provided */ /* A name for the entry must be provided */
g_assert(menulabel != NULL && strlen ( menulabel ) > 0 ); ws_assert(menulabel != NULL && strlen ( menulabel ) > 0 );
/* A protocol must exist for the given id */ /* A protocol must exist for the given id */
g_assert(find_protocol_by_id(proto_id) != NULL); ws_assert(find_protocol_by_id(proto_id) != NULL);
/* Create unique name, which is used by GTK to provide the menu */ /* Create unique name, which is used by GTK to provide the menu */
name = g_strconcat(proto_get_protocol_filter_name(proto_id), "Menu", NULL); name = g_strconcat(proto_get_protocol_filter_name(proto_id), "Menu", NULL);
/* For now, a protocol may only register one main menu */ /* For now, a protocol may only register one main menu */
g_assert(g_list_find(menubar_menunames, name) == NULL); ws_assert(g_list_find(menubar_menunames, name) == NULL);
entry = g_new0(ext_menubar_t, 1); entry = g_new0(ext_menubar_t, 1);
entry->type = EXT_MENUBAR_MENU; entry->type = EXT_MENUBAR_MENU;
@ -95,9 +96,9 @@ extern ext_menu_t * ext_menubar_register_menu(int proto_id, const gchar * menula
extern ext_menu_t * ext_menubar_set_parentmenu(ext_menu_t * menu, const gchar * parentmenu) extern ext_menu_t * ext_menubar_set_parentmenu(ext_menu_t * menu, const gchar * parentmenu)
{ {
g_assert(menu != NULL && menu->parent == NULL); ws_assert(menu != NULL && menu->parent == NULL);
g_assert(parentmenu != 0); ws_assert(parentmenu != 0);
menu->parent_menu = g_strdup(parentmenu); menu->parent_menu = g_strdup(parentmenu);
@ -109,10 +110,10 @@ extern ext_menu_t * ext_menubar_add_submenu(ext_menu_t * parent, const gchar *me
ext_menubar_t * entry = NULL; ext_menubar_t * entry = NULL;
/* A name for the entry must be provided */ /* A name for the entry must be provided */
g_assert(menulabel != NULL && strlen ( menulabel ) > 0 ); ws_assert(menulabel != NULL && strlen ( menulabel ) > 0 );
/* Parent must be a valid parent */ /* Parent must be a valid parent */
g_assert(parent != NULL && parent->type == EXT_MENUBAR_MENU); ws_assert(parent != NULL && parent->type == EXT_MENUBAR_MENU);
parent->submenu_cnt++; parent->submenu_cnt++;
@ -140,9 +141,9 @@ static void ext_menubar_add_generic_entry (
ext_menubar_t * entry = NULL; ext_menubar_t * entry = NULL;
/* A valid parent must exist */ /* A valid parent must exist */
g_assert(parent != NULL && parent->type == EXT_MENUBAR_MENU); ws_assert(parent != NULL && parent->type == EXT_MENUBAR_MENU);
/* A label for the entry must be provided */ /* A label for the entry must be provided */
g_assert(label != NULL && strlen ( label ) > 0 ); ws_assert(label != NULL && strlen ( label ) > 0 );
parent->item_cnt++; parent->item_cnt++;
@ -166,7 +167,7 @@ extern void ext_menubar_add_entry(ext_menu_t * parent, const gchar *label,
const gchar *tooltip, ext_menubar_action_cb callback, gpointer user_data) const gchar *tooltip, ext_menubar_action_cb callback, gpointer user_data)
{ {
/* A callback must be provided */ /* A callback must be provided */
g_assert(callback != NULL); ws_assert(callback != NULL);
ext_menubar_add_generic_entry ( EXT_MENUBAR_ITEM, parent, label, tooltip, callback, user_data ); ext_menubar_add_generic_entry ( EXT_MENUBAR_ITEM, parent, label, tooltip, callback, user_data );
} }
@ -175,7 +176,7 @@ extern void ext_menubar_add_website(ext_menu_t * parent, const gchar *label,
const gchar *tooltip, const gchar *url) const gchar *tooltip, const gchar *url)
{ {
/* An url for the entry must be provided */ /* An url for the entry must be provided */
g_assert(url != NULL && strlen ( url ) > 0 ); ws_assert(url != NULL && strlen ( url ) > 0 );
ext_menubar_add_generic_entry ( EXT_MENUBAR_URL, parent, label, tooltip, NULL, (gpointer) g_strdup(url) ); ext_menubar_add_generic_entry ( EXT_MENUBAR_URL, parent, label, tooltip, NULL, (gpointer) g_strdup(url) );
} }
@ -199,7 +200,7 @@ ext_toolbar_t * ext_toolbar_register_toolbar(const gchar * toolbarlabel)
ext_toolbar_t * entry = NULL; ext_toolbar_t * entry = NULL;
/* A name for the entry must be provided */ /* A name for the entry must be provided */
g_assert(toolbarlabel != NULL && strlen ( toolbarlabel ) > 0 ); ws_assert(toolbarlabel != NULL && strlen ( toolbarlabel ) > 0 );
entry = g_new0(ext_toolbar_t, 1); entry = g_new0(ext_toolbar_t, 1);
entry->type = EXT_TOOLBAR_BAR; entry->type = EXT_TOOLBAR_BAR;
@ -309,11 +310,11 @@ ext_toolbar_add_entry( ext_toolbar_t * parent, ext_toolbar_item_t type, const gc
ext_toolbar_t * entry = NULL; ext_toolbar_t * entry = NULL;
/* A valid parent must exist */ /* A valid parent must exist */
g_assert(parent != NULL && parent->type == EXT_TOOLBAR_BAR); ws_assert(parent != NULL && parent->type == EXT_TOOLBAR_BAR);
/* A label for the entry must be provided */ /* A label for the entry must be provided */
g_assert(label != NULL && strlen ( label ) > 0 ); ws_assert(label != NULL && strlen ( label ) > 0 );
/* A callback must be provided */ /* A callback must be provided */
g_assert(callback != NULL); ws_assert(callback != NULL);
parent->item_cnt++; parent->item_cnt++;

View File

@ -35,6 +35,7 @@
#include <wsutil/file_util.h> #include <wsutil/file_util.h>
#include <wsutil/report_message.h> #include <wsutil/report_message.h>
#include <wsutil/wslog.h> #include <wsutil/wslog.h>
#include <wsutil/ws_assert.h>
#include <epan/prefs-int.h> #include <epan/prefs-int.h>
#include <epan/uat-int.h> #include <epan/uat-int.h>
@ -1183,7 +1184,7 @@ prefs_register_uint_preference(module_t *module, const char *name,
PREF_UINT); PREF_UINT);
preference->varp.uint = var; preference->varp.uint = var;
preference->default_val.uint = *var; preference->default_val.uint = *var;
g_assert(base > 0 && base != 1 && base < 37); ws_assert(base > 0 && base != 1 && base < 37);
preference->info.base = base; preference->info.base = base;
} }
@ -1253,7 +1254,7 @@ unsigned int prefs_set_bool_value(pref_t *pref, gboolean value, pref_source_t so
} }
break; break;
default: default:
g_assert_not_reached(); ws_assert_not_reached();
break; break;
} }
@ -1274,7 +1275,7 @@ void prefs_invert_bool_value(pref_t *pref, pref_source_t source)
*pref->varp.boolp = !(*pref->varp.boolp); *pref->varp.boolp = !(*pref->varp.boolp);
break; break;
default: default:
g_assert_not_reached(); ws_assert_not_reached();
break; break;
} }
} }
@ -1293,7 +1294,7 @@ gboolean prefs_get_bool_value(pref_t *pref, pref_source_t source)
return *pref->varp.boolp; return *pref->varp.boolp;
break; break;
default: default:
g_assert_not_reached(); ws_assert_not_reached();
break; break;
} }
@ -1348,7 +1349,7 @@ unsigned int prefs_set_enum_value(pref_t *pref, gint value, pref_source_t source
} }
break; break;
default: default:
g_assert_not_reached(); ws_assert_not_reached();
break; break;
} }
@ -1376,7 +1377,7 @@ gint prefs_get_enum_value(pref_t *pref, pref_source_t source)
return *pref->varp.enump; return *pref->varp.enump;
break; break;
default: default:
g_assert_not_reached(); ws_assert_not_reached();
break; break;
} }
@ -1439,7 +1440,7 @@ register_string_like_preference(module_t *module, const char *name,
pref->default_val.string = g_strdup(*var); pref->default_val.string = g_strdup(*var);
pref->stashed_val.string = NULL; pref->stashed_val.string = NULL;
if (type == PREF_CUSTOM) { if (type == PREF_CUSTOM) {
g_assert(custom_cbs); ws_assert(custom_cbs);
pref->custom_cbs = *custom_cbs; pref->custom_cbs = *custom_cbs;
} }
} }
@ -1499,7 +1500,7 @@ prefs_set_string_value(pref_t *pref, const char* value, pref_source_t source)
} }
break; break;
default: default:
g_assert_not_reached(); ws_assert_not_reached();
break; break;
} }
@ -1517,7 +1518,7 @@ char* prefs_get_string_value(pref_t *pref, pref_source_t source)
case pref_current: case pref_current:
return *pref->varp.string; return *pref->varp.string;
default: default:
g_assert_not_reached(); ws_assert_not_reached();
break; break;
} }
@ -1686,7 +1687,7 @@ gboolean prefs_set_range_value(pref_t *pref, range_t *value, pref_source_t sourc
} }
break; break;
default: default:
g_assert_not_reached(); ws_assert_not_reached();
break; break;
} }
@ -1706,7 +1707,7 @@ range_t* prefs_get_range_value_real(pref_t *pref, pref_source_t source)
return *pref->varp.range; return *pref->varp.range;
break; break;
default: default:
g_assert_not_reached(); ws_assert_not_reached();
break; break;
} }
@ -1825,7 +1826,7 @@ gboolean prefs_set_color_value(pref_t *pref, color_t value, pref_source_t source
} }
break; break;
default: default:
g_assert_not_reached(); ws_assert_not_reached();
break; break;
} }
@ -1845,7 +1846,7 @@ color_t* prefs_get_color_value(pref_t *pref, pref_source_t source)
return pref->varp.colorp; return pref->varp.colorp;
break; break;
default: default:
g_assert_not_reached(); ws_assert_not_reached();
break; break;
} }
@ -2057,7 +2058,7 @@ pref_stash(pref_t *pref, gpointer unused _U_)
break; break;
case PREF_OBSOLETE: case PREF_OBSOLETE:
g_assert_not_reached(); ws_assert_not_reached();
break; break;
} }
return 0; return 0;
@ -2198,7 +2199,7 @@ pref_unstash(pref_t *pref, gpointer unstash_data_p)
break; break;
case PREF_OBSOLETE: case PREF_OBSOLETE:
g_assert_not_reached(); ws_assert_not_reached();
break; break;
} }
return 0; return 0;
@ -2248,7 +2249,7 @@ reset_stashed_pref(pref_t *pref) {
break; break;
case PREF_OBSOLETE: case PREF_OBSOLETE:
g_assert_not_reached(); ws_assert_not_reached();
break; break;
} }
} }
@ -2293,7 +2294,7 @@ pref_clean_stash(pref_t *pref, gpointer unused _U_)
break; break;
case PREF_OBSOLETE: case PREF_OBSOLETE:
g_assert_not_reached(); ws_assert_not_reached();
break; break;
} }
return 0; return 0;
@ -2624,7 +2625,7 @@ column_format_reset_cb(pref_t* pref)
} }
col_num_pref = prefs_find_preference(gui_column_module, PRS_COL_NUM); col_num_pref = prefs_find_preference(gui_column_module, PRS_COL_NUM);
g_assert(col_num_pref != NULL); /* Should never happen */ ws_assert(col_num_pref != NULL); /* Should never happen */
column_num_reset_cb(col_num_pref); column_num_reset_cb(col_num_pref);
} }
@ -2675,9 +2676,9 @@ column_format_set_cb(pref_t* pref, const gchar* value, unsigned int* changed_fla
free_col_info(*pref->varp.list); free_col_info(*pref->varp.list);
*pref->varp.list = NULL; *pref->varp.list = NULL;
hidden_pref = prefs_find_preference(gui_column_module, PRS_COL_HIDDEN); hidden_pref = prefs_find_preference(gui_column_module, PRS_COL_HIDDEN);
g_assert(hidden_pref != NULL); /* Should never happen */ ws_assert(hidden_pref != NULL); /* Should never happen */
col_num_pref = prefs_find_preference(gui_column_module, PRS_COL_NUM); col_num_pref = prefs_find_preference(gui_column_module, PRS_COL_NUM);
g_assert(col_num_pref != NULL); /* Should never happen */ ws_assert(col_num_pref != NULL); /* Should never happen */
llen = g_list_length(col_l); llen = g_list_length(col_l);
*col_num_pref->varp.uint = llen / 2; *col_num_pref->varp.uint = llen / 2;
col_l_elt = g_list_first(col_l); col_l_elt = g_list_first(col_l);
@ -4765,7 +4766,7 @@ guint prefs_get_uint_value_real(pref_t *pref, pref_source_t source)
return *pref->varp.uint; return *pref->varp.uint;
break; break;
default: default:
g_assert_not_reached(); ws_assert_not_reached();
break; break;
} }
@ -4801,7 +4802,7 @@ unsigned int prefs_set_uint_value(pref_t *pref, guint value, pref_source_t sourc
} }
break; break;
default: default:
g_assert_not_reached(); ws_assert_not_reached();
break; break;
} }
@ -5357,7 +5358,7 @@ deprecated_port_pref(gchar *pref_name, const gchar *value)
default: default:
ws_error("The dissector table %s (%s) is not an integer type - are you using a buggy plugin?", port_range_prefs[i].table_name, get_dissector_table_ui_name(port_range_prefs[i].table_name)); ws_error("The dissector table %s (%s) is not an integer type - are you using a buggy plugin?", port_range_prefs[i].table_name, get_dissector_table_ui_name(port_range_prefs[i].table_name));
g_assert_not_reached(); ws_assert_not_reached();
} }
module = prefs_find_module(port_range_prefs[i].module_name); module = prefs_find_module(port_range_prefs[i].module_name);
@ -6342,7 +6343,7 @@ prefs_pref_is_default(pref_t *pref)
case PREF_STATIC_TEXT: case PREF_STATIC_TEXT:
case PREF_UAT: case PREF_UAT:
return FALSE; return FALSE;
/* g_assert_not_reached(); */ /* ws_assert_not_reached(); */
break; break;
} }
return FALSE; return FALSE;

View File

@ -31,6 +31,7 @@
#include <wsutil/filesystem.h> #include <wsutil/filesystem.h>
#include <version_info.h> #include <version_info.h>
#include <wsutil/utf8_entities.h> #include <wsutil/utf8_entities.h>
#include <wsutil/ws_assert.h>
#include <ftypes/ftypes-int.h> #include <ftypes/ftypes-int.h>
#define PDML_VERSION "0" #define PDML_VERSION "0"
@ -168,7 +169,7 @@ proto_tree_print_node(proto_node *node, gpointer data)
gchar *label_ptr; gchar *label_ptr;
/* dissection with an invisible proto tree? */ /* dissection with an invisible proto tree? */
g_assert(fi); ws_assert(fi);
/* Don't print invisible entries. */ /* Don't print invisible entries. */
if (proto_item_is_hidden(node) && (prefs.display_hidden_proto_items == FALSE)) if (proto_item_is_hidden(node) && (prefs.display_hidden_proto_items == FALSE))
@ -233,7 +234,7 @@ proto_tree_print_node(proto_node *node, gpointer data)
/* If we're printing all levels, or if this node is one with a /* If we're printing all levels, or if this node is one with a
subtree and its subtree is expanded, recurse into the subtree, subtree and its subtree is expanded, recurse into the subtree,
if it exists. */ if it exists. */
g_assert((fi->tree_type >= -1) && (fi->tree_type < num_tree_types)); ws_assert((fi->tree_type >= -1) && (fi->tree_type < num_tree_types));
if ((pdata->print_dissections == print_dissections_expanded) || if ((pdata->print_dissections == print_dissections_expanded) ||
((pdata->print_dissections == print_dissections_as_displayed) && ((pdata->print_dissections == print_dissections_as_displayed) &&
(fi->tree_type >= 0) && tree_expanded(fi->tree_type))) { (fi->tree_type >= 0) && tree_expanded(fi->tree_type))) {
@ -304,8 +305,8 @@ write_pdml_proto_tree(output_fields_t* fields, gchar **protocolfilter, pf_flags
write_pdml_data data; write_pdml_data data;
const color_filter_t *cfp; const color_filter_t *cfp;
g_assert(edt); ws_assert(edt);
g_assert(fh); ws_assert(fh);
cfp = edt->pi.fd->color_filter; cfp = edt->pi.fd->color_filter;
@ -347,8 +348,8 @@ write_ek_proto_tree(output_fields_t* fields,
column_info *cinfo, column_info *cinfo,
FILE *fh) FILE *fh)
{ {
g_assert(edt); ws_assert(edt);
g_assert(fh); ws_assert(fh);
write_json_data data; write_json_data data;
@ -402,8 +403,8 @@ write_ek_proto_tree(output_fields_t* fields,
void void
write_fields_proto_tree(output_fields_t* fields, epan_dissect_t *edt, column_info *cinfo, FILE *fh) write_fields_proto_tree(output_fields_t* fields, epan_dissect_t *edt, column_info *cinfo, FILE *fh)
{ {
g_assert(edt); ws_assert(edt);
g_assert(fh); ws_assert(fh);
/* Create the output */ /* Create the output */
write_specified_fields(FORMAT_CSV, fields, edt, cinfo, fh, NULL); write_specified_fields(FORMAT_CSV, fields, edt, cinfo, fh, NULL);
@ -445,7 +446,7 @@ proto_tree_write_node_pdml(proto_node *node, gpointer data)
gboolean wrap_in_fake_protocol; gboolean wrap_in_fake_protocol;
/* dissection with an invisible proto tree? */ /* dissection with an invisible proto tree? */
g_assert(fi); ws_assert(fi);
/* Will wrap up top-level field items inside a fake protocol wrapper to /* Will wrap up top-level field items inside a fake protocol wrapper to
preserve the PDML schema */ preserve the PDML schema */
@ -608,7 +609,7 @@ proto_tree_write_node_pdml(proto_node *node, gpointer data)
fprintf(pdata->fh, "%" G_GINT64_MODIFIER "X", fvalue_get_uinteger64(&fi->value)); fprintf(pdata->fh, "%" G_GINT64_MODIFIER "X", fvalue_get_uinteger64(&fi->value));
break; break;
default: default:
g_assert_not_reached(); ws_assert_not_reached();
} }
fputs("\" unmaskedvalue=\"", pdata->fh); fputs("\" unmaskedvalue=\"", pdata->fh);
pdml_write_field_hex_value(pdata, fi); pdml_write_field_hex_value(pdata, fi);
@ -971,7 +972,7 @@ write_json_proto_node_hex_dump(proto_node *node, write_json_data *pdata)
json_dumper_value_anyf(pdata->dumper, "\"%" G_GINT64_MODIFIER "X\"", fvalue_get_uinteger64(&fi->value)); json_dumper_value_anyf(pdata->dumper, "\"%" G_GINT64_MODIFIER "X\"", fvalue_get_uinteger64(&fi->value));
break; break;
default: default:
g_assert_not_reached(); ws_assert_not_reached();
} }
} else { } else {
json_write_field_hex_value(pdata, fi); json_write_field_hex_value(pdata, fi);
@ -1194,7 +1195,7 @@ ek_fill_attr(proto_node *node, GSList **attr_list, GHashTable *attr_table, write
fi_parent = PNODE_FINFO(current_node->parent); fi_parent = PNODE_FINFO(current_node->parent);
/* dissection with an invisible proto tree? */ /* dissection with an invisible proto tree? */
g_assert(fi); ws_assert(fi);
if (fi_parent == NULL) { if (fi_parent == NULL) {
node_name = g_strdup(fi->hfinfo->abbrev); node_name = g_strdup(fi->hfinfo->abbrev);
@ -1294,7 +1295,7 @@ ek_write_hex(field_info *fi, write_json_data *pdata)
json_dumper_value_anyf(pdata->dumper, "\"%" G_GINT64_MODIFIER "X\"", fvalue_get_uinteger64(&fi->value)); json_dumper_value_anyf(pdata->dumper, "\"%" G_GINT64_MODIFIER "X\"", fvalue_get_uinteger64(&fi->value));
break; break;
default: default:
g_assert_not_reached(); ws_assert_not_reached();
} }
} else { } else {
json_write_field_hex_value(pdata, fi); json_write_field_hex_value(pdata, fi);
@ -2103,7 +2104,7 @@ print_hex_data_buffer(print_stream_t *stream, const guchar *cp,
gsize output_fields_num_fields(output_fields_t* fields) gsize output_fields_num_fields(output_fields_t* fields)
{ {
g_assert(fields); ws_assert(fields);
if (NULL == fields->fields) { if (NULL == fields->fields) {
return 0; return 0;
@ -2114,7 +2115,7 @@ gsize output_fields_num_fields(output_fields_t* fields)
void output_fields_free(output_fields_t* fields) void output_fields_free(output_fields_t* fields)
{ {
g_assert(fields); ws_assert(fields);
if (NULL != fields->fields) { if (NULL != fields->fields) {
gsize i; gsize i;
@ -2146,8 +2147,8 @@ void output_fields_add(output_fields_t *fields, const gchar *field)
{ {
gchar *field_copy; gchar *field_copy;
g_assert(fields); ws_assert(fields);
g_assert(field); ws_assert(field);
if (NULL == fields->fields) { if (NULL == fields->fields) {
@ -2197,8 +2198,8 @@ gboolean output_fields_set_option(output_fields_t *info, gchar *option)
const gchar *option_name; const gchar *option_name;
const gchar *option_value; const gchar *option_value;
g_assert(info); ws_assert(info);
g_assert(option); ws_assert(option);
if ('\0' == *option) { if ('\0' == *option) {
return FALSE; /* this happens if we're called from tshark -E '' */ return FALSE; /* this happens if we're called from tshark -E '' */
@ -2321,7 +2322,7 @@ void output_fields_list_options(FILE *fh)
gboolean output_fields_has_cols(output_fields_t* fields) gboolean output_fields_has_cols(output_fields_t* fields)
{ {
g_assert(fields); ws_assert(fields);
return fields->includes_col_fields; return fields->includes_col_fields;
} }
@ -2329,9 +2330,9 @@ void write_fields_preamble(output_fields_t* fields, FILE *fh)
{ {
gsize i; gsize i;
g_assert(fields); ws_assert(fields);
g_assert(fh); ws_assert(fh);
g_assert(fields->fields); ws_assert(fields->fields);
if (fields->print_bom) { if (fields->print_bom) {
fputs(UTF8_BOM, fh); fputs(UTF8_BOM, fh);
@ -2409,7 +2410,7 @@ static void format_field_values(output_fields_t* fields, gpointer field_index, g
} }
break; break;
default: default:
g_assert_not_reached(); ws_assert_not_reached();
break; break;
} }
@ -2426,7 +2427,7 @@ static void proto_tree_get_node_field_values(proto_node *node, gpointer data)
fi = PNODE_FINFO(node); fi = PNODE_FINFO(node);
/* dissection with an invisible proto tree? */ /* dissection with an invisible proto tree? */
g_assert(fi); ws_assert(fi);
field_index = g_hash_table_lookup(call_data->fields->field_indicies, fi->hfinfo->abbrev); field_index = g_hash_table_lookup(call_data->fields->field_indicies, fi->hfinfo->abbrev);
if (NULL != field_index) { if (NULL != field_index) {
@ -2451,14 +2452,14 @@ static void write_specified_fields(fields_format format, output_fields_t *fields
write_field_data_t data; write_field_data_t data;
g_assert(fields); ws_assert(fields);
g_assert(fields->fields); ws_assert(fields->fields);
g_assert(edt); ws_assert(edt);
/* JSON formats must go through json_dumper */ /* JSON formats must go through json_dumper */
if (format == FORMAT_JSON || format == FORMAT_EK) { if (format == FORMAT_JSON || format == FORMAT_EK) {
g_assert(!fh && dumper); ws_assert(!fh && dumper);
} else { } else {
g_assert(fh && !dumper); ws_assert(fh && !dumper);
} }
data.fields = fields; data.fields = fields;
@ -2620,7 +2621,7 @@ static void write_specified_fields(fields_format format, output_fields_t *fields
default: default:
fprintf(stderr, "Unknown fields format %d\n", format); fprintf(stderr, "Unknown fields format %d\n", format);
g_assert_not_reached(); ws_assert_not_reached();
break; break;
} }
} }

View File

@ -23,6 +23,7 @@
#include <wsutil/utf8_entities.h> #include <wsutil/utf8_entities.h>
#include <wsutil/json_dumper.h> #include <wsutil/json_dumper.h>
#include <wsutil/wslog.h> #include <wsutil/wslog.h>
#include <wsutil/ws_assert.h>
#include <ftypes/ftypes-int.h> #include <ftypes/ftypes-int.h>
@ -144,7 +145,7 @@ struct ptvcursor {
/** See inlined comments. /** See inlined comments.
@param pi the created protocol item we're about to return */ @param pi the created protocol item we're about to return */
#define TRY_TO_FAKE_THIS_REPR(pi) \ #define TRY_TO_FAKE_THIS_REPR(pi) \
g_assert(pi); \ ws_assert(pi); \
if (!(PTREE_DATA(pi)->visible)) { \ if (!(PTREE_DATA(pi)->visible)) { \
/* If the tree (GUI) isn't visible it's pointless for us to generate the protocol \ /* If the tree (GUI) isn't visible it's pointless for us to generate the protocol \
* items string representation */ \ * items string representation */ \
@ -3707,7 +3708,7 @@ proto_tree_add_item_ret_string_and_length(proto_tree *tree, int hfindex,
break; break;
default: default:
g_assert_not_reached(); ws_assert_not_reached();
} }
return pi; return pi;
@ -3802,7 +3803,7 @@ proto_tree_add_item_ret_display_string_and_length(proto_tree *tree, int hfindex,
break; break;
default: default:
g_assert_not_reached(); ws_assert_not_reached();
} }
new_fi->flags |= (encoding & ENC_LITTLE_ENDIAN) ? FI_LITTLE_ENDIAN : FI_BIG_ENDIAN; new_fi->flags |= (encoding & ENC_LITTLE_ENDIAN) ? FI_LITTLE_ENDIAN : FI_BIG_ENDIAN;
@ -3826,7 +3827,7 @@ proto_tree_add_item_ret_display_string_and_length(proto_tree *tree, int hfindex,
break; break;
default: default:
g_assert_not_reached(); ws_assert_not_reached();
} }
return pi; return pi;
@ -3883,7 +3884,7 @@ proto_tree_add_item_ret_time_string(proto_tree *tree, int hfindex,
proto_tree_set_time(new_fi, &time_stamp); proto_tree_set_time(new_fi, &time_stamp);
break; break;
default: default:
g_assert_not_reached(); ws_assert_not_reached();
} }
new_fi->flags |= (encoding & ENC_LITTLE_ENDIAN) ? FI_LITTLE_ENDIAN : FI_BIG_ENDIAN; new_fi->flags |= (encoding & ENC_LITTLE_ENDIAN) ? FI_LITTLE_ENDIAN : FI_BIG_ENDIAN;
@ -6244,7 +6245,7 @@ new_field_info(proto_tree *tree, header_field_info *hfinfo, tvbuff_t *tvb,
static void static void
proto_tree_set_representation_value(proto_item *pi, const char *format, va_list ap) proto_tree_set_representation_value(proto_item *pi, const char *format, va_list ap)
{ {
g_assert(pi); ws_assert(pi);
/* If the tree (GUI) or item isn't visible it's pointless for us to generate the protocol /* If the tree (GUI) or item isn't visible it's pointless for us to generate the protocol
* items string representation */ * items string representation */
@ -6669,7 +6670,7 @@ proto_custom_set(proto_tree* tree, GSList *field_ids, gint occurrence,
int field_id; int field_id;
int ii = 0; int ii = 0;
g_assert(field_ids != NULL); ws_assert(field_ids != NULL);
while ((field_idx = (int *) g_slist_nth_data(field_ids, ii++))) { while ((field_idx = (int *) g_slist_nth_data(field_ids, ii++))) {
field_id = *field_idx; field_id = *field_idx;
PROTO_REGISTRAR_GET_NTH((guint)field_id, hfinfo); PROTO_REGISTRAR_GET_NTH((guint)field_id, hfinfo);
@ -13090,14 +13091,14 @@ tree_expanded(int tree_type)
if (tree_type == -1) { if (tree_type == -1) {
return FALSE; return FALSE;
} }
g_assert(tree_type >= 0 && tree_type < num_tree_types); ws_assert(tree_type >= 0 && tree_type < num_tree_types);
return tree_is_expanded[tree_type >> 5] & (1U << (tree_type & 31)); return tree_is_expanded[tree_type >> 5] & (1U << (tree_type & 31));
} }
void void
tree_expanded_set(int tree_type, gboolean value) tree_expanded_set(int tree_type, gboolean value)
{ {
g_assert(tree_type >= 0 && tree_type < num_tree_types); ws_assert(tree_type >= 0 && tree_type < num_tree_types);
if (value) if (value)
tree_is_expanded[tree_type >> 5] |= (1U << (tree_type & 31)); tree_is_expanded[tree_type >> 5] |= (1U << (tree_type & 31));

View File

@ -18,6 +18,7 @@
#include <epan/tvbuff-int.h> #include <epan/tvbuff-int.h>
#include <wsutil/str_util.h> #include <wsutil/str_util.h>
#include <wsutil/ws_assert.h>
/* /*
* Functions for reassembly tables where the endpoint addresses, and a * Functions for reassembly tables where the endpoint addresses, and a
@ -2189,7 +2190,7 @@ fragment_add_seq_single_move(reassembly_table *table, const packet_info *pinfo,
if (fh == NULL) { if (fh == NULL) {
/* Shouldn't be called this way. /* Shouldn't be called this way.
* Probably wouldn't hurt to just create fh in this case. */ * Probably wouldn't hurt to just create fh in this case. */
g_assert_not_reached(); ws_assert_not_reached();
return; return;
} }
if (fh->flags & FD_DATALEN_SET && fh->datalen <= offset) { if (fh->flags & FD_DATALEN_SET && fh->datalen <= offset) {

View File

@ -111,7 +111,7 @@ static void
print_fd(fragment_head *fd, gboolean is_head) { print_fd(fragment_head *fd, gboolean is_head) {
int i; int i;
g_assert(fd != NULL); g_assert_true(fd != NULL);
printf(" %16p %16p %3u %3u %3u", fd, fd->next, fd->frame, fd->offset, fd->len); printf(" %16p %16p %3u %3u %3u", fd, fd->next, fd->frame, fd->offset, fd->len);
if (is_head) { if (is_head) {
printf(" %3u %3u", fd->datalen, fd->reassembled_in); printf(" %3u %3u", fd->datalen, fd->reassembled_in);
@ -133,7 +133,7 @@ static void
print_fd_chain(fragment_head *fd_head) { print_fd_chain(fragment_head *fd_head) {
fragment_item *fdp; fragment_item *fdp;
g_assert(fd_head != NULL); g_assert_true(fd_head != NULL);
print_fd(fd_head, TRUE); print_fd(fd_head, TRUE);
for (fdp=fd_head->next; fdp != NULL; fdp=fdp->next) { for (fdp=fd_head->next; fdp != NULL; fdp=fdp->next) {
print_fd(fdp, FALSE); print_fd(fdp, FALSE);

View File

@ -19,6 +19,7 @@
#include <epan/prefs.h> #include <epan/prefs.h>
#include <epan/prefs-int.h> #include <epan/prefs-int.h>
#include <epan/show_exception.h> #include <epan/show_exception.h>
#include <wsutil/ws_assert.h>
#include <wsutil/wslog.h> #include <wsutil/wslog.h>
@ -166,7 +167,7 @@ show_exception(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree,
default: default:
/* XXX - we want to know, if an unknown exception passed until here, don't we? */ /* XXX - we want to know, if an unknown exception passed until here, don't we? */
g_assert_not_reached(); ws_assert_not_reached();
} }
} }

View File

@ -15,6 +15,7 @@
#include "proto.h" #include "proto.h"
#include "packet_info.h" #include "packet_info.h"
#include "srt_table.h" #include "srt_table.h"
#include <wsutil/ws_assert.h>
struct register_srt { struct register_srt {
int proto_id; /* protocol id (0-indexed) */ int proto_id; /* protocol id (0-indexed) */
@ -250,7 +251,7 @@ add_srt_table_data(srt_stat_table *rst, int indx, const nstime_t *req_time, pack
srt_procedure_t *rp; srt_procedure_t *rp;
nstime_t t, delta; nstime_t t, delta;
g_assert(indx >= 0 && indx < rst->num_procs); ws_assert(indx >= 0 && indx < rst->num_procs);
rp=&rst->procedures[indx]; rp=&rst->procedures[indx];
/* calculate time delta between request and reply */ /* calculate time delta between request and reply */

View File

@ -17,6 +17,7 @@
#include <glib.h> #include <glib.h>
#include <epan/stat_tap_ui.h> #include <epan/stat_tap_ui.h>
#include <wsutil/ws_assert.h>
/* structure to keep track of what stats have registered command-line /* structure to keep track of what stats have registered command-line
arguments. arguments.
@ -238,11 +239,11 @@ void stat_tap_init_table_row(stat_tap_table *stat_table, guint table_index, guin
stat_tap_table_item_type* stat_tap_get_field_data(const stat_tap_table *stat_table, guint table_index, guint field_index) stat_tap_table_item_type* stat_tap_get_field_data(const stat_tap_table *stat_table, guint table_index, guint field_index)
{ {
stat_tap_table_item_type* field_value; stat_tap_table_item_type* field_value;
g_assert(table_index < stat_table->num_elements); ws_assert(table_index < stat_table->num_elements);
field_value = stat_table->elements[table_index]; field_value = stat_table->elements[table_index];
g_assert(field_index < stat_table->num_fields); ws_assert(field_index < stat_table->num_fields);
return &field_value[field_index]; return &field_value[field_index];
} }
@ -250,11 +251,11 @@ stat_tap_table_item_type* stat_tap_get_field_data(const stat_tap_table *stat_tab
void stat_tap_set_field_data(stat_tap_table *stat_table, guint table_index, guint field_index, stat_tap_table_item_type* field_data) void stat_tap_set_field_data(stat_tap_table *stat_table, guint table_index, guint field_index, stat_tap_table_item_type* field_data)
{ {
stat_tap_table_item_type* field_value; stat_tap_table_item_type* field_value;
g_assert(table_index < stat_table->num_elements); ws_assert(table_index < stat_table->num_elements);
field_value = stat_table->elements[table_index]; field_value = stat_table->elements[table_index];
g_assert(field_index < stat_table->num_fields); ws_assert(field_index < stat_table->num_fields);
field_value[field_index] = *field_data; field_value[field_index] = *field_data;
} }

View File

@ -30,6 +30,7 @@
#include "strutil.h" #include "strutil.h"
#include "stats_tree.h" #include "stats_tree.h"
#include <wsutil/ws_assert.h>
enum _stat_tree_columns { enum _stat_tree_columns {
COL_NAME, COL_NAME,
@ -273,7 +274,7 @@ stats_tree_register_with_group(const char *tapname, const char *abbr, const char
stats_tree_cfg *cfg = g_new0(stats_tree_cfg, 1); stats_tree_cfg *cfg = g_new0(stats_tree_cfg, 1);
/* at the very least the abbrev and the packet function should be given */ /* at the very least the abbrev and the packet function should be given */
g_assert( tapname && abbr && packet ); ws_assert( tapname && abbr && packet );
cfg->tapname = g_strdup(tapname); cfg->tapname = g_strdup(tapname);
cfg->abbr = g_strdup(abbr); cfg->abbr = g_strdup(abbr);
@ -503,7 +504,7 @@ new_stat_node(stats_tree *st, const gchar *name, int parent_id, stat_node_dataty
node->parent = (stat_node *)g_ptr_array_index(st->parents,parent_id); node->parent = (stat_node *)g_ptr_array_index(st->parents,parent_id);
} else { } else {
/* ??? should we set the parent to be root ??? */ /* ??? should we set the parent to be root ??? */
g_assert_not_reached(); ws_assert_not_reached();
} }
if (node->parent->children) { if (node->parent->children) {
@ -653,7 +654,7 @@ stats_tree_manip_node_int(manip_node_mode mode, stats_tree *st, const char *name
stat_node *node = NULL; stat_node *node = NULL;
stat_node *parent = NULL; stat_node *parent = NULL;
g_assert( parent_id >= 0 && parent_id < (int) st->parents->len ); ws_assert( parent_id >= 0 && parent_id < (int) st->parents->len );
parent = (stat_node *)g_ptr_array_index(st->parents,parent_id); parent = (stat_node *)g_ptr_array_index(st->parents,parent_id);
@ -715,7 +716,7 @@ stats_tree_manip_node_float(manip_node_mode mode, stats_tree *st, const char *na
stat_node *node = NULL; stat_node *node = NULL;
stat_node *parent = NULL; stat_node *parent = NULL;
g_assert(parent_id >= 0 && parent_id < (int)st->parents->len); ws_assert(parent_id >= 0 && parent_id < (int)st->parents->len);
parent = (stat_node *)g_ptr_array_index(st->parents, parent_id); parent = (stat_node *)g_ptr_array_index(st->parents, parent_id);
@ -746,7 +747,7 @@ stats_tree_manip_node_float(manip_node_mode mode, stats_tree *st, const char *na
break; break;
default: default:
//only average is currently supported //only average is currently supported
g_assert_not_reached(); ws_assert_not_reached();
break; break;
} }
@ -763,7 +764,7 @@ stats_tree_get_abbr(const char *opt_arg)
/* XXX: this fails when tshark is given any options /* XXX: this fails when tshark is given any options
after the -z */ after the -z */
g_assert(opt_arg != NULL); ws_assert(opt_arg != NULL);
for (i=0; opt_arg[i] && opt_arg[i] != ','; i++); for (i=0; opt_arg[i] && opt_arg[i] != ','; i++);
@ -922,7 +923,7 @@ stats_tree_tick_range(stats_tree *st, const gchar *name, int parent_id,
if (parent_id >= 0 && parent_id < (int) st->parents->len) { if (parent_id >= 0 && parent_id < (int) st->parents->len) {
parent = (stat_node *)g_ptr_array_index(st->parents,parent_id); parent = (stat_node *)g_ptr_array_index(st->parents,parent_id);
} else { } else {
g_assert_not_reached(); ws_assert_not_reached();
} }
if( parent->hash ) { if( parent->hash ) {
@ -932,7 +933,7 @@ stats_tree_tick_range(stats_tree *st, const gchar *name, int parent_id,
} }
if ( node == NULL ) if ( node == NULL )
g_assert_not_reached(); ws_assert_not_reached();
/* update stats for container node. counter should already be ticked so we only update total and min/max */ /* update stats for container node. counter should already be ticked so we only update total and min/max */
node->total.int_total += value_in_range; node->total.int_total += value_in_range;
@ -1259,7 +1260,7 @@ stats_tree_sort_compare (const stat_node *a, const stat_node *b, gint sort_colum
default: default:
/* no sort comparison found for column - must update this switch statement */ /* no sort comparison found for column - must update this switch statement */
g_assert_not_reached(); ws_assert_not_reached();
} }
/* break tie between items with same primary search result */ /* break tie between items with same primary search result */

View File

@ -18,6 +18,7 @@
#include <epan/reassemble.h> #include <epan/reassemble.h>
#include <epan/stream.h> #include <epan/stream.h>
#include <epan/tvbuff.h> #include <epan/tvbuff.h>
#include <wsutil/ws_assert.h>
typedef struct { typedef struct {
@ -103,7 +104,7 @@ static void cleanup_stream_hash( void ) {
/* init function, call from stream_init() */ /* init function, call from stream_init() */
static void init_stream_hash( void ) { static void init_stream_hash( void ) {
g_assert(stream_hash==NULL); ws_assert(stream_hash==NULL);
stream_hash = g_hash_table_new(stream_hash_func, stream_hash = g_hash_table_new(stream_hash_func,
stream_compare_func); stream_compare_func);
} }
@ -221,7 +222,7 @@ static void cleanup_fragment_hash( void ) {
/* init function, call from stream_init() */ /* init function, call from stream_init() */
static void init_fragment_hash( void ) { static void init_fragment_hash( void ) {
g_assert(fragment_hash==NULL); ws_assert(fragment_hash==NULL);
fragment_hash = g_hash_table_new(fragment_hash_func, fragment_hash = g_hash_table_new(fragment_hash_func,
fragment_compare_func); fragment_compare_func);
} }

View File

@ -19,6 +19,7 @@
#include <epan/proto.h> #include <epan/proto.h>
#include <epan/packet_info.h> #include <epan/packet_info.h>
#include <epan/tvbparse.h> #include <epan/tvbparse.h>
#include <wsutil/ws_assert.h>
#define TVBPARSE_DEBUG_ALL 0xffffffff #define TVBPARSE_DEBUG_ALL 0xffffffff
@ -737,7 +738,7 @@ tvbparse_wanted_t* tvbparse_some(const int id,
tvbparse_wanted_t* w = wmem_new0(wmem_epan_scope(), tvbparse_wanted_t); tvbparse_wanted_t* w = wmem_new0(wmem_epan_scope(), tvbparse_wanted_t);
g_assert(from <= to); ws_assert(from <= to);
w->condition = cond_some; w->condition = cond_some;
w->id = id; w->id = id;
@ -920,7 +921,7 @@ tvbparse_wanted_t* tvbparse_ft(int id,
return w; return w;
} else { } else {
g_assert(! "unsupported ftenum" ); ws_assert(! "unsupported ftenum" );
return NULL; return NULL;
} }
} }
@ -1153,12 +1154,12 @@ tvbparse_wanted_t* tvbparse_ft_numcmp(int id,
w->control.number.value.i = va_arg(ap,gdouble); w->control.number.value.i = va_arg(ap,gdouble);
break; break;
default: default:
g_assert(! "comparison unsupported"); ws_assert(! "comparison unsupported");
} }
w->control.number.extract = extracts[little_endian][ftenum]; w->control.number.extract = extracts[little_endian][ftenum];
g_assert(w->control.number.extract && "extraction unsupported"); ws_assert(w->control.number.extract && "extraction unsupported");
w->id = id; w->id = id;
w->condition = cond_ft_comp; w->condition = cond_ft_comp;

View File

@ -32,6 +32,7 @@
#include "wsutil/unicode-utils.h" #include "wsutil/unicode-utils.h"
#include "wsutil/nstime.h" #include "wsutil/nstime.h"
#include "wsutil/time_util.h" #include "wsutil/time_util.h"
#include <wsutil/ws_assert.h>
#include "tvbuff.h" #include "tvbuff.h"
#include "tvbuff-int.h" #include "tvbuff-int.h"
#include "strutil.h" #include "strutil.h"
@ -70,7 +71,7 @@ tvb_new(const struct tvb_ops *ops)
tvbuff_t *tvb; tvbuff_t *tvb;
gsize size = ops->tvb_size; gsize size = ops->tvb_size;
g_assert(size >= sizeof(*tvb)); ws_assert(size >= sizeof(*tvb));
tvb = (tvbuff_t *) g_slice_alloc(size); tvb = (tvbuff_t *) g_slice_alloc(size);
@ -4433,7 +4434,7 @@ tvb_get_varint(tvbuff_t *tvb, guint offset, guint maxlen, guint64 *value, const
*value = tvb_get_ntoh64(tvb, offset) & G_GUINT64_CONSTANT(0x3FFFFFFFFFFFFFFF); *value = tvb_get_ntoh64(tvb, offset) & G_GUINT64_CONSTANT(0x3FFFFFFFFFFFFFFF);
return 8; return 8;
default: /* No Possible */ default: /* No Possible */
g_assert_not_reached(); ws_assert_not_reached();
break; break;
} }

View File

@ -25,6 +25,7 @@
#include <wsutil/file_util.h> #include <wsutil/file_util.h>
#include <wsutil/str_util.h> #include <wsutil/str_util.h>
#include <wsutil/report_message.h> #include <wsutil/report_message.h>
#include <wsutil/ws_assert.h>
#include <wsutil/filesystem.h> #include <wsutil/filesystem.h>
#include <epan/packet.h> #include <epan/packet.h>
@ -64,7 +65,7 @@ uat_t* uat_new(const char* name,
g_ptr_array_add(all_uats,uat); g_ptr_array_add(all_uats,uat);
/* Check params */ /* Check params */
g_assert(name && size && filename && data_ptr && numitems_ptr); ws_assert(name && size && filename && data_ptr && numitems_ptr);
/* Set uat values from inputs */ /* Set uat values from inputs */
uat->name = g_strdup(name); uat->name = g_strdup(name);
@ -153,7 +154,7 @@ void uat_update_record(uat_t *uat, const void *record, gboolean valid_rec) {
} }
if (pos == uat->raw_data->len) { if (pos == uat->raw_data->len) {
/* Data is not within list?! */ /* Data is not within list?! */
g_assert_not_reached(); ws_assert_not_reached();
} }
valid = &g_array_index(uat->valid_data, gboolean, pos); valid = &g_array_index(uat->valid_data, gboolean, pos);
@ -165,7 +166,7 @@ void uat_swap(uat_t* uat, guint a, guint b) {
void* tmp; void* tmp;
gboolean tmp_bool; gboolean tmp_bool;
g_assert( a < uat->raw_data->len && b < uat->raw_data->len ); ws_assert( a < uat->raw_data->len && b < uat->raw_data->len );
if (a == b) return; if (a == b) return;
@ -184,7 +185,7 @@ void uat_swap(uat_t* uat, guint a, guint b) {
void uat_insert_record_idx(uat_t* uat, guint idx, const void *src_record) { void uat_insert_record_idx(uat_t* uat, guint idx, const void *src_record) {
/* Allow insert before an existing item or append after the last item. */ /* Allow insert before an existing item or append after the last item. */
g_assert( idx <= uat->raw_data->len ); ws_assert( idx <= uat->raw_data->len );
/* Store a copy of the record and invoke copy_cb to clone pointers too. */ /* Store a copy of the record and invoke copy_cb to clone pointers too. */
g_array_insert_vals(uat->raw_data, idx, src_record, 1); g_array_insert_vals(uat->raw_data, idx, src_record, 1);
@ -203,7 +204,7 @@ void uat_insert_record_idx(uat_t* uat, guint idx, const void *src_record) {
void uat_remove_record_idx(uat_t* uat, guint idx) { void uat_remove_record_idx(uat_t* uat, guint idx) {
g_assert( idx < uat->raw_data->len ); ws_assert( idx < uat->raw_data->len );
if (uat->free_cb) { if (uat->free_cb) {
uat->free_cb(UAT_INDEX_PTR(uat,idx)); uat->free_cb(UAT_INDEX_PTR(uat,idx));
@ -295,7 +296,7 @@ char *uat_fld_tostr(void *rec, uat_field_t *f) {
break; break;
} }
default: default:
g_assert_not_reached(); ws_assert_not_reached();
out = NULL; out = NULL;
break; break;
} }
@ -350,7 +351,7 @@ static void putfld(FILE* fp, void* rec, uat_field_t* f) {
break; break;
} }
default: default:
g_assert_not_reached(); ws_assert_not_reached();
} }
g_free(fld_ptr); g_free(fld_ptr);

View File

@ -18,6 +18,7 @@
#include "proto.h" #include "proto.h"
#include "to_str.h" #include "to_str.h"
#include "value_string.h" #include "value_string.h"
#include <wsutil/ws_assert.h>
#include <wsutil/wslog.h> #include <wsutil/wslog.h>
@ -370,7 +371,7 @@ _try_val_to_str_index(const guint32 val, value_string_ext *vse)
i = val - vse->_vs_first_value; i = val - vse->_vs_first_value;
if (i < vse->_vs_num_entries) { if (i < vse->_vs_num_entries) {
g_assert (val == vse->_vs_p[i].value); ws_assert (val == vse->_vs_p[i].value);
return &(vse->_vs_p[i]); return &(vse->_vs_p[i]);
} }
return NULL; return NULL;
@ -484,7 +485,7 @@ _try_val_to_str_ext_init(const guint32 val, value_string_ext *vse)
vse->_vs_match2 = _try_val_to_str_index; vse->_vs_match2 = _try_val_to_str_index;
break; break;
default: default:
g_assert_not_reached(); ws_assert_not_reached();
break; break;
} }
@ -655,7 +656,7 @@ _try_val64_to_str_index(const guint64 val, val64_string_ext *vse)
i = val - vse->_vs_first_value; i = val - vse->_vs_first_value;
if (i < vse->_vs_num_entries) { if (i < vse->_vs_num_entries) {
g_assert (val == vse->_vs_p[i].value); ws_assert (val == vse->_vs_p[i].value);
return &(vse->_vs_p[i]); return &(vse->_vs_p[i]);
} }
return NULL; return NULL;
@ -769,7 +770,7 @@ _try_val64_to_str_ext_init(const guint64 val, val64_string_ext *vse)
vse->_vs_match2 = _try_val64_to_str_index; vse->_vs_match2 = _try_val64_to_str_index;
break; break;
default: default:
g_assert_not_reached(); ws_assert_not_reached();
break; break;
} }

View File

@ -42,6 +42,7 @@
#include <wsutil/ws_pipe.h> #include <wsutil/ws_pipe.h>
#include <wsutil/tempfile.h> #include <wsutil/tempfile.h>
#include <wsutil/wslog.h> #include <wsutil/wslog.h>
#include <wsutil/ws_assert.h>
#include "capture_opts.h" #include "capture_opts.h"
@ -457,7 +458,7 @@ static gpointer
extcap_run_all(const char *argv[], extcap_run_cb_t output_cb, gsize data_size, guint *count) extcap_run_all(const char *argv[], extcap_run_cb_t output_cb, gsize data_size, guint *count)
{ {
/* Need enough space for at least 'extcap_path'. */ /* Need enough space for at least 'extcap_path'. */
g_assert(data_size >= sizeof(char *)); ws_assert(data_size >= sizeof(char *));
GSList *paths = extcap_get_extcap_paths(); GSList *paths = extcap_get_extcap_paths();
int i = 0; int i = 0;

View File

@ -20,6 +20,7 @@
#include <errno.h> #include <errno.h>
#include <wsutil/wslog.h> #include <wsutil/wslog.h>
#include <wsutil/ws_assert.h>
/* /*
* If we have getopt_long() in the system library, include <getopt.h>. * If we have getopt_long() in the system library, include <getopt.h>.
* Otherwise, we're using our own getopt_long() (either because the * Otherwise, we're using our own getopt_long() (either because the
@ -84,9 +85,9 @@ void extcap_base_set_util_info(extcap_parameters * extcap, const char * exename,
{ {
extcap->exename = g_path_get_basename(exename); extcap->exename = g_path_get_basename(exename);
g_assert(major); ws_assert(major);
if (!minor) if (!minor)
g_assert(!release); ws_assert(!release);
extcap->version = g_strdup_printf("%s%s%s%s%s", extcap->version = g_strdup_printf("%s%s%s%s%s",
major, major,

63
file.c
View File

@ -23,6 +23,7 @@
#include <wsutil/filesystem.h> #include <wsutil/filesystem.h>
#include <wsutil/json_dumper.h> #include <wsutil/json_dumper.h>
#include <wsutil/wslog.h> #include <wsutil/wslog.h>
#include <wsutil/ws_assert.h>
#include <version_info.h> #include <version_info.h>
#include <wiretap/merge.h> #include <wiretap/merge.h>
@ -153,7 +154,7 @@ cf_callback_invoke(int event, gpointer data)
GList *cb_item = cf_callbacks; GList *cb_item = cf_callbacks;
/* there should be at least one interested */ /* there should be at least one interested */
g_assert(cb_item != NULL); ws_assert(cb_item != NULL);
while (cb_item != NULL) { while (cb_item != NULL) {
cb = (cf_callback_data_t *)cb_item->data; cb = (cf_callback_data_t *)cb_item->data;
@ -191,7 +192,7 @@ cf_callback_remove(cf_callback_t func, gpointer user_data)
cb_item = g_list_next(cb_item); cb_item = g_list_next(cb_item);
} }
g_assert_not_reached(); ws_assert_not_reached();
} }
void void
@ -363,8 +364,8 @@ cf_close(capture_file *cf)
return; /* Nothing to do */ return; /* Nothing to do */
/* Die if we're in the middle of reading a file. */ /* Die if we're in the middle of reading a file. */
g_assert(cf->state != FILE_READ_IN_PROGRESS); ws_assert(cf->state != FILE_READ_IN_PROGRESS);
g_assert(!cf->read_lock); ws_assert(!cf->read_lock);
cf_callback_invoke(cf_cb_file_closing, cf); cf_callback_invoke(cf_cb_file_closing, cf);
@ -508,7 +509,7 @@ cf_read(capture_file *cf, gboolean reloading)
column_info *cinfo; column_info *cinfo;
volatile gboolean create_proto_tree; volatile gboolean create_proto_tree;
guint tap_flags; guint tap_flags;
gboolean compiled; gboolean compiled _U_;
volatile gboolean is_read_aborted = FALSE; volatile gboolean is_read_aborted = FALSE;
/* The update_progress_dlg call below might end up accepting a user request to /* The update_progress_dlg call below might end up accepting a user request to
@ -528,7 +529,7 @@ cf_read(capture_file *cf, gboolean reloading)
* cf_filter IFF the filter was valid. * cf_filter IFF the filter was valid.
*/ */
compiled = dfilter_compile(cf->dfilter, &dfcode, NULL); compiled = dfilter_compile(cf->dfilter, &dfcode, NULL);
g_assert(!cf->dfilter || (compiled && dfcode)); ws_assert(!cf->dfilter || (compiled && dfcode));
/* Get the union of the flags for all tap listeners. */ /* Get the union of the flags for all tap listeners. */
tap_flags = union_of_tap_listener_flags(); tap_flags = union_of_tap_listener_flags();
@ -632,7 +633,7 @@ cf_read(capture_file *cf, gboolean reloading)
* session. If that did happen, it could blow up when read_record tries * session. If that did happen, it could blow up when read_record tries
* to use the destroyed edt.session, so detect it right here. * to use the destroyed edt.session, so detect it right here.
*/ */
g_assert(edt.session == cf->epan); ws_assert(edt.session == cf->epan);
} }
if (cf->state == FILE_READ_ABORTED) { if (cf->state == FILE_READ_ABORTED) {
@ -718,7 +719,7 @@ cf_read(capture_file *cf, gboolean reloading)
} }
/* It is safe again to execute redissections. */ /* It is safe again to execute redissections. */
g_assert(cf->read_lock); ws_assert(cf->read_lock);
cf->read_lock = FALSE; cf->read_lock = FALSE;
if (is_read_aborted) { if (is_read_aborted) {
@ -781,14 +782,14 @@ cf_continue_tail(capture_file *cf, volatile int to_read, wtap_rec *rec,
epan_dissect_t edt; epan_dissect_t edt;
gboolean create_proto_tree; gboolean create_proto_tree;
guint tap_flags; guint tap_flags;
gboolean compiled; gboolean compiled _U_;
/* Compile the current display filter. /* Compile the current display filter.
* We assume this will not fail since cf->dfilter is only set in * We assume this will not fail since cf->dfilter is only set in
* cf_filter IFF the filter was valid. * cf_filter IFF the filter was valid.
*/ */
compiled = dfilter_compile(cf->dfilter, &dfcode, NULL); compiled = dfilter_compile(cf->dfilter, &dfcode, NULL);
g_assert(!cf->dfilter || (compiled && dfcode)); ws_assert(!cf->dfilter || (compiled && dfcode));
/* Get the union of the flags for all tap listeners. */ /* Get the union of the flags for all tap listeners. */
tap_flags = union_of_tap_listener_flags(); tap_flags = union_of_tap_listener_flags();
@ -917,14 +918,14 @@ cf_finish_tail(capture_file *cf, wtap_rec *rec, Buffer *buf, int *err)
epan_dissect_t edt; epan_dissect_t edt;
gboolean create_proto_tree; gboolean create_proto_tree;
guint tap_flags; guint tap_flags;
gboolean compiled; gboolean compiled _U_;
/* Compile the current display filter. /* Compile the current display filter.
* We assume this will not fail since cf->dfilter is only set in * We assume this will not fail since cf->dfilter is only set in
* cf_filter IFF the filter was valid. * cf_filter IFF the filter was valid.
*/ */
compiled = dfilter_compile(cf->dfilter, &dfcode, NULL); compiled = dfilter_compile(cf->dfilter, &dfcode, NULL);
g_assert(!cf->dfilter || (compiled && dfcode)); ws_assert(!cf->dfilter || (compiled && dfcode));
/* Get the union of the flags for all tap listeners. */ /* Get the union of the flags for all tap listeners. */
tap_flags = union_of_tap_listener_flags(); tap_flags = union_of_tap_listener_flags();
@ -1316,7 +1317,7 @@ merge_callback(merge_event event, int num _U_,
guint i; guint i;
callback_data_t *cb_data = (callback_data_t*) data; callback_data_t *cb_data = (callback_data_t*) data;
g_assert(cb_data != NULL); ws_assert(cb_data != NULL);
switch (event) { switch (event) {
@ -1646,13 +1647,13 @@ rescan_packets(capture_file *cf, const char *action, const char *action_item, gb
gboolean create_proto_tree; gboolean create_proto_tree;
guint tap_flags; guint tap_flags;
gboolean add_to_packet_list = FALSE; gboolean add_to_packet_list = FALSE;
gboolean compiled; gboolean compiled _U_;
guint32 frames_count; guint32 frames_count;
gboolean queued_rescan_type = RESCAN_NONE; gboolean queued_rescan_type = RESCAN_NONE;
/* Rescan in progress, clear pending actions. */ /* Rescan in progress, clear pending actions. */
cf->redissection_queued = RESCAN_NONE; cf->redissection_queued = RESCAN_NONE;
g_assert(!cf->read_lock); ws_assert(!cf->read_lock);
cf->read_lock = TRUE; cf->read_lock = TRUE;
wtap_rec_init(&rec); wtap_rec_init(&rec);
@ -1663,7 +1664,7 @@ rescan_packets(capture_file *cf, const char *action, const char *action_item, gb
* cf_filter IFF the filter was valid. * cf_filter IFF the filter was valid.
*/ */
compiled = dfilter_compile(cf->dfilter, &dfcode, NULL); compiled = dfilter_compile(cf->dfilter, &dfcode, NULL);
g_assert(!cf->dfilter || (compiled && dfcode)); ws_assert(!cf->dfilter || (compiled && dfcode));
/* Get the union of the flags for all tap listeners. */ /* Get the union of the flags for all tap listeners. */
tap_flags = union_of_tap_listener_flags(); tap_flags = union_of_tap_listener_flags();
@ -1812,7 +1813,7 @@ rescan_packets(capture_file *cf, const char *action, const char *action_item, gb
/* let's not divide by zero. I should never be started /* let's not divide by zero. I should never be started
* with count == 0, so let's assert that * with count == 0, so let's assert that
*/ */
g_assert(cf->count > 0); ws_assert(cf->count > 0);
progbar_val = (gfloat) count / frames_count; progbar_val = (gfloat) count / frames_count;
if (progbar != NULL) { if (progbar != NULL) {
@ -1948,9 +1949,9 @@ rescan_packets(capture_file *cf, const char *action, const char *action_item, gb
it's before or after that frame) and make that the current frame. it's before or after that frame) and make that the current frame.
If the next and previous displayed frames are equidistant from the If the next and previous displayed frames are equidistant from the
selected frame, choose the next one. */ selected frame, choose the next one. */
g_assert(following_frame == NULL || ws_assert(following_frame == NULL ||
following_frame->num >= selected_frame->num); following_frame->num >= selected_frame->num);
g_assert(preceding_frame == NULL || ws_assert(preceding_frame == NULL ||
preceding_frame->num <= selected_frame->num); preceding_frame->num <= selected_frame->num);
if (following_frame == NULL) { if (following_frame == NULL) {
/* No frame after the selected frame passed the filter, so we /* No frame after the selected frame passed the filter, so we
@ -2000,7 +2001,7 @@ rescan_packets(capture_file *cf, const char *action, const char *action_item, gb
dfilter_free(dfcode); dfilter_free(dfcode);
/* It is safe again to execute redissections. */ /* It is safe again to execute redissections. */
g_assert(cf->read_lock); ws_assert(cf->read_lock);
cf->read_lock = FALSE; cf->read_lock = FALSE;
/* If another rescan (due to dfilter change) or redissection (due to profile /* If another rescan (due to dfilter change) or redissection (due to profile
@ -2167,7 +2168,7 @@ process_specified_records(capture_file *cf, packet_range_t *range,
/* let's not divide by zero. I should never be started /* let's not divide by zero. I should never be started
* with count == 0, so let's assert that * with count == 0, so let's assert that
*/ */
g_assert(cf->count > 0); ws_assert(cf->count > 0);
progbar_val = (gfloat) progbar_count / cf->count; progbar_val = (gfloat) progbar_count / cf->count;
g_snprintf(progbar_status_str, sizeof(progbar_status_str), g_snprintf(progbar_status_str, sizeof(progbar_status_str),
@ -2219,7 +2220,7 @@ process_specified_records(capture_file *cf, packet_range_t *range,
destroy_progress_dlg(progbar); destroy_progress_dlg(progbar);
g_timer_destroy(prog_timer); g_timer_destroy(prog_timer);
g_assert(cf->read_lock); ws_assert(cf->read_lock);
cf->read_lock = FALSE; cf->read_lock = FALSE;
wtap_rec_cleanup(&rec); wtap_rec_cleanup(&rec);
@ -2314,7 +2315,7 @@ cf_retap_packets(capture_file *cf)
return CF_READ_ERROR; return CF_READ_ERROR;
} }
g_assert_not_reached(); ws_assert_not_reached();
return CF_READ_OK; return CF_READ_OK;
} }
@ -3124,7 +3125,7 @@ match_subtree_text(proto_node *node, gpointer data)
size_t c_match = 0; size_t c_match = 0;
/* dissection with an invisible proto tree? */ /* dissection with an invisible proto tree? */
g_assert(fi); ws_assert(fi);
if (mdata->frame_matched) { if (mdata->frame_matched) {
/* We already had a match; don't bother doing any more work. */ /* We already had a match; don't bother doing any more work. */
@ -3291,7 +3292,7 @@ cf_find_packet_data(capture_file *cf, const guint8 *string, size_t string_size,
return find_packet(cf, match_wide, &info, dir); return find_packet(cf, match_wide, &info, dir);
default: default:
g_assert_not_reached(); ws_assert_not_reached();
return FALSE; return FALSE;
} }
} else } else
@ -3338,7 +3339,7 @@ match_narrow_and_wide(capture_file *cf, frame_data *fdata,
} }
} }
else { else {
g_assert(i>=c_match); ws_assert(i>=c_match);
i -= (guint32)c_match; i -= (guint32)c_match;
c_match = 0; c_match = 0;
} }
@ -3387,7 +3388,7 @@ match_narrow(capture_file *cf, frame_data *fdata,
} }
} }
else { else {
g_assert(i>=c_match); ws_assert(i>=c_match);
i -= (guint32)c_match; i -= (guint32)c_match;
c_match = 0; c_match = 0;
} }
@ -3437,7 +3438,7 @@ match_wide(capture_file *cf, frame_data *fdata,
i += 1; i += 1;
} }
else { else {
g_assert(i>=(c_match*2)); ws_assert(i>=(c_match*2));
i -= (guint32)c_match*2; i -= (guint32)c_match*2;
c_match = 0; c_match = 0;
} }
@ -3481,7 +3482,7 @@ match_binary(capture_file *cf, frame_data *fdata,
} }
} }
else { else {
g_assert(i>=c_match); ws_assert(i>=c_match);
i -= (guint32)c_match; i -= (guint32)c_match;
c_match = 0; c_match = 0;
} }
@ -3659,7 +3660,7 @@ find_packet(capture_file *cf, ws_match_function match_function,
/* let's not divide by zero. I should never be started /* let's not divide by zero. I should never be started
* with count == 0, so let's assert that * with count == 0, so let's assert that
*/ */
g_assert(cf->count > 0); ws_assert(cf->count > 0);
progbar_val = (gfloat) count / cf->count; progbar_val = (gfloat) count / cf->count;
@ -3819,7 +3820,7 @@ cf_goto_framenum(capture_file *cf)
if (cf->finfo_selected) { if (cf->finfo_selected) {
hfinfo = cf->finfo_selected->hfinfo; hfinfo = cf->finfo_selected->hfinfo;
g_assert(hfinfo); ws_assert(hfinfo);
if (hfinfo->type == FT_FRAMENUM) { if (hfinfo->type == FT_FRAMENUM) {
framenum = fvalue_get_uinteger(&cf->finfo_selected->value); framenum = fvalue_get_uinteger(&cf->finfo_selected->value);
if (framenum != 0) if (framenum != 0)

View File

@ -21,6 +21,7 @@
#include <wsutil/file_util.h> #include <wsutil/file_util.h>
#include <wsutil/filesystem.h> #include <wsutil/filesystem.h>
#include <wsutil/ws_assert.h>
#include <epan/strutil.h> #include <epan/strutil.h>
@ -124,8 +125,8 @@ fileset_is_file_in_set(const char *fname1, const char *fname2)
/* just to be sure ... */ /* just to be sure ... */
g_assert(fileset_filename_match_pattern(fname1)); ws_assert(fileset_filename_match_pattern(fname1));
g_assert(fileset_filename_match_pattern(fname2)); ws_assert(fileset_filename_match_pattern(fname2));
dup_f1 = g_strdup(fname1); dup_f1 = g_strdup(fname1);
dup_f2 = g_strdup(fname2); dup_f2 = g_strdup(fname2);

View File

@ -41,6 +41,7 @@
#include <wsutil/file_util.h> #include <wsutil/file_util.h>
#include <wsutil/privileges.h> #include <wsutil/privileges.h>
#include <wsutil/strnatcmp.h> #include <wsutil/strnatcmp.h>
#include <wsutil/ws_assert.h>
#include <cli_main.h> #include <cli_main.h>
#include <version_info.h> #include <version_info.h>
@ -388,7 +389,7 @@ main(int argc, char *argv[])
case MERGE_USER_ABORTED: case MERGE_USER_ABORTED:
/* we don't catch SIGINT/SIGTERM (yet?), so we couldn't have aborted */ /* we don't catch SIGINT/SIGTERM (yet?), so we couldn't have aborted */
g_assert_not_reached(); ws_assert_not_reached();
break; break;
case MERGE_ERR_CANT_OPEN_INFILE: case MERGE_ERR_CANT_OPEN_INFILE:

View File

@ -11,6 +11,7 @@
*/ */
#include "mate.h" #include "mate.h"
#include <wsutil/ws_assert.h>
typedef struct _mate_range mate_range; typedef struct _mate_range mate_range;
@ -429,7 +430,7 @@ static void analyze_gop(mate_config* mc, mate_gop* gop) {
} }
/** Can't get here because of "breaks" above */ /** Can't get here because of "breaks" above */
g_assert_not_reached(); ws_assert_not_reached();
} }
} /* while */ } /* while */

View File

@ -382,7 +382,6 @@ gboolean ringbuf_is_initialized(void)
const gchar *ringbuf_current_filename(void) const gchar *ringbuf_current_filename(void)
{ {
/* g_assert(ringbuf_is_initialized()); */
return rb_data.files[rb_data.curr_file_num % rb_data.num_files].name; return rb_data.files[rb_data.curr_file_num % rb_data.num_files].name;
} }

View File

@ -21,6 +21,7 @@
#include <wsutil/wsjson.h> #include <wsutil/wsjson.h>
#include <wsutil/json_dumper.h> #include <wsutil/json_dumper.h>
#include <wsutil/ws_assert.h>
#include <file.h> #include <file.h>
#include <epan/epan_dissect.h> #include <epan/epan_dissect.h>
@ -2714,7 +2715,7 @@ sharkd_session_process_frame_cb_tree(epan_dissect_t *edt, proto_tree *tree, tvbu
{ {
const char *severity = try_val_to_str(FI_GET_FLAG(finfo, PI_SEVERITY_MASK), expert_severity_vals); const char *severity = try_val_to_str(FI_GET_FLAG(finfo, PI_SEVERITY_MASK), expert_severity_vals);
g_assert(severity != NULL); ws_assert(severity != NULL);
sharkd_json_value_string("s", severity); sharkd_json_value_string("s", severity);
} }

View File

@ -14,6 +14,7 @@
#include <glib.h> #include <glib.h>
#include <wsutil/file_util.h> #include <wsutil/file_util.h>
#include <wsutil/ws_assert.h>
#include "sync_pipe.h" #include "sync_pipe.h"
@ -28,7 +29,7 @@ pipe_write_header(int pipe_fd, char indicator, int length)
guchar header[1+3]; /* indicator + 3-byte len */ guchar header[1+3]; /* indicator + 3-byte len */
g_assert(length <= SP_MAX_MSG_LEN); ws_assert(length <= SP_MAX_MSG_LEN);
/* write header (indicator + 3-byte len) */ /* write header (indicator + 3-byte len) */
header[0] = indicator; header[0] = indicator;

View File

@ -48,6 +48,7 @@
#include <wsutil/privileges.h> #include <wsutil/privileges.h>
#include <wsutil/report_message.h> #include <wsutil/report_message.h>
#include <wsutil/wslog.h> #include <wsutil/wslog.h>
#include <wsutil/ws_assert.h>
#include <cli_main.h> #include <cli_main.h>
#include <version_info.h> #include <version_info.h>
@ -896,7 +897,7 @@ main(int argc, char *argv[])
break; break;
default: default:
g_assert_not_reached(); ws_assert_not_reached();
} }
} }
} }
@ -1239,7 +1240,7 @@ local_wtap_read(capture_file *cf, wtap_rec *file_rec _U_, int *err, gchar **err_
* but the read routine didn't set this packet's * but the read routine didn't set this packet's
* encapsulation type. * encapsulation type.
*/ */
g_assert(wth->rec.rec_header.packet_header.pkt_encap != WTAP_ENCAP_PER_PACKET); ws_assert(wth->rec.rec_header.packet_header.pkt_encap != WTAP_ENCAP_PER_PACKET);
#endif #endif
return TRUE; /* success */ return TRUE; /* success */
@ -1647,7 +1648,7 @@ write_preamble(capture_file *cf)
return !ferror(stdout); return !ferror(stdout);
default: default:
g_assert_not_reached(); ws_assert_not_reached();
return FALSE; return FALSE;
} }
} }
@ -1947,7 +1948,7 @@ print_packet(capture_file *cf, epan_dissect_t *edt)
write_psml_columns(edt, stdout, FALSE); write_psml_columns(edt, stdout, FALSE);
return !ferror(stdout); return !ferror(stdout);
case WRITE_FIELDS: /*No non-verbose "fields" format */ case WRITE_FIELDS: /*No non-verbose "fields" format */
g_assert_not_reached(); ws_assert_not_reached();
break; break;
} }
} }
@ -2009,7 +2010,7 @@ write_finale(void)
return !ferror(stdout); return !ferror(stdout);
default: default:
g_assert_not_reached(); ws_assert_not_reached();
return FALSE; return FALSE;
} }
} }

View File

@ -59,6 +59,7 @@
#include <wsutil/report_message.h> #include <wsutil/report_message.h>
#include <wsutil/please_report_bug.h> #include <wsutil/please_report_bug.h>
#include <wsutil/wslog.h> #include <wsutil/wslog.h>
#include <wsutil/ws_assert.h>
#include <cli_main.h> #include <cli_main.h>
#include <version_info.h> #include <version_info.h>
#include <wiretap/wtap_opttypes.h> #include <wiretap/wtap_opttypes.h>
@ -1974,7 +1975,7 @@ main(int argc, char *argv[])
break; break;
default: default:
g_assert_not_reached(); ws_assert_not_reached();
} }
} }
} }
@ -2618,7 +2619,7 @@ capture_input_cfilter_error(capture_session *cap_session, guint i, const char *e
dfilter_t *rfcode = NULL; dfilter_t *rfcode = NULL;
interface_options *interface_opts; interface_options *interface_opts;
g_assert(i < capture_opts->ifaces->len); ws_assert(i < capture_opts->ifaces->len);
interface_opts = &g_array_index(capture_opts->ifaces, interface_options, i); interface_opts = &g_array_index(capture_opts->ifaces, interface_options, i);
if (dfilter_compile(interface_opts->cfilter, &rfcode, NULL) && rfcode != NULL) { if (dfilter_compile(interface_opts->cfilter, &rfcode, NULL) && rfcode != NULL) {
@ -2659,7 +2660,7 @@ capture_input_new_file(capture_session *cap_session, gchar *new_file)
} }
ws_message("File: \"%s\"", new_file); ws_message("File: \"%s\"", new_file);
g_assert(cap_session->state == CAPTURE_PREPARING || cap_session->state == CAPTURE_RUNNING); ws_assert(cap_session->state == CAPTURE_PREPARING || cap_session->state == CAPTURE_RUNNING);
/* free the old filename */ /* free the old filename */
if (capture_opts->save_file != NULL) { if (capture_opts->save_file != NULL) {
@ -3837,7 +3838,7 @@ process_packet_single_pass(capture_file *cf, epan_dissect_t *edt, gint64 offset,
if (print_packet_info) { if (print_packet_info) {
/* We're printing packet information; print the information for /* We're printing packet information; print the information for
this packet. */ this packet. */
g_assert(edt); ws_assert(edt);
print_packet(cf, edt); print_packet(cf, edt);
/* If we're doing "line-buffering", flush the standard output /* If we're doing "line-buffering", flush the standard output
@ -3895,7 +3896,7 @@ write_preamble(capture_file *cf)
return TRUE; return TRUE;
default: default:
g_assert_not_reached(); ws_assert_not_reached();
return FALSE; return FALSE;
} }
} }
@ -4230,7 +4231,7 @@ print_packet(capture_file *cf, epan_dissect_t *edt)
case WRITE_FIELDS: case WRITE_FIELDS:
if (print_summary) { if (print_summary) {
/*No non-verbose "fields" format */ /*No non-verbose "fields" format */
g_assert_not_reached(); ws_assert_not_reached();
} }
if (print_details) { if (print_details) {
write_fields_proto_tree(output_fields, edt, &cf->cinfo, stdout); write_fields_proto_tree(output_fields, edt, &cf->cinfo, stdout);
@ -4241,7 +4242,7 @@ print_packet(capture_file *cf, epan_dissect_t *edt)
case WRITE_JSON: case WRITE_JSON:
if (print_summary) if (print_summary)
g_assert_not_reached(); ws_assert_not_reached();
if (print_details) { if (print_details) {
write_json_proto_tree(output_fields, print_dissections_expanded, write_json_proto_tree(output_fields, print_dissections_expanded,
print_hex, protocolfilter, protocolfilter_flags, print_hex, protocolfilter, protocolfilter_flags,
@ -4252,7 +4253,7 @@ print_packet(capture_file *cf, epan_dissect_t *edt)
case WRITE_JSON_RAW: case WRITE_JSON_RAW:
if (print_summary) if (print_summary)
g_assert_not_reached(); ws_assert_not_reached();
if (print_details) { if (print_details) {
write_json_proto_tree(output_fields, print_dissections_none, TRUE, write_json_proto_tree(output_fields, print_dissections_none, TRUE,
protocolfilter, protocolfilter_flags, protocolfilter, protocolfilter_flags,
@ -4267,7 +4268,7 @@ print_packet(capture_file *cf, epan_dissect_t *edt)
return !ferror(stdout); return !ferror(stdout);
default: default:
g_assert_not_reached(); ws_assert_not_reached();
} }
if (print_hex) { if (print_hex) {
@ -4311,7 +4312,7 @@ write_finale(void)
return TRUE; return TRUE;
default: default:
g_assert_not_reached(); ws_assert_not_reached();
return FALSE; return FALSE;
} }
} }

View File

@ -42,6 +42,7 @@
#include "wsutil/str_util.h" #include "wsutil/str_util.h"
#include <wsutil/filesystem.h> #include <wsutil/filesystem.h>
#include <wsutil/wslog.h> #include <wsutil/wslog.h>
#include <wsutil/ws_assert.h>
typedef struct if_stat_cache_item_s { typedef struct if_stat_cache_item_s {
char *name; char *name;
@ -69,7 +70,7 @@ capture_callback_invoke(int event, capture_session *cap_session)
GList *cb_item = capture_callbacks; GList *cb_item = capture_callbacks;
/* there should be at least one interested */ /* there should be at least one interested */
g_assert(cb_item != NULL); ws_assert(cb_item != NULL);
while(cb_item != NULL) { while(cb_item != NULL) {
cb = (capture_callback_data_t *)cb_item->data; cb = (capture_callback_data_t *)cb_item->data;
@ -107,7 +108,7 @@ capture_callback_remove(capture_callback_t func, gpointer user_data)
cb_item = g_list_next(cb_item); cb_item = g_list_next(cb_item);
} }
g_assert_not_reached(); ws_assert_not_reached();
} }
/** /**
@ -383,7 +384,7 @@ capture_input_new_file(capture_session *cap_session, gchar *new_file)
} }
ws_message("File: \"%s\"", new_file); ws_message("File: \"%s\"", new_file);
g_assert(cap_session->state == CAPTURE_PREPARING || cap_session->state == CAPTURE_RUNNING); ws_assert(cap_session->state == CAPTURE_PREPARING || cap_session->state == CAPTURE_RUNNING);
/* free the old filename */ /* free the old filename */
if(capture_opts->save_file != NULL) { if(capture_opts->save_file != NULL) {
@ -515,7 +516,7 @@ capture_input_new_packets(capture_session *cap_session, int to_read)
capture_options *capture_opts = cap_session->capture_opts; capture_options *capture_opts = cap_session->capture_opts;
int err; int err;
g_assert(capture_opts->save_file); ws_assert(capture_opts->save_file);
if(capture_opts->real_time_mode) { if(capture_opts->real_time_mode) {
/* Read from the capture file the number of records the child told us it added. */ /* Read from the capture file the number of records the child told us it added. */
@ -560,7 +561,7 @@ capture_input_drops(capture_session *cap_session, guint32 dropped, const char* i
ws_info("%u packet%s dropped", dropped, plurality(dropped, "", "s")); ws_info("%u packet%s dropped", dropped, plurality(dropped, "", "s"));
} }
g_assert(cap_session->state == CAPTURE_RUNNING); ws_assert(cap_session->state == CAPTURE_RUNNING);
cf_set_drops_known((capture_file *)cap_session->cf, TRUE); cf_set_drops_known((capture_file *)cap_session->cf, TRUE);
cf_set_drops((capture_file *)cap_session->cf, dropped); cf_set_drops((capture_file *)cap_session->cf, dropped);
@ -574,7 +575,7 @@ capture_input_drops(capture_session *cap_session, guint32 dropped, const char* i
The secondary message might be a null string. The secondary message might be a null string.
*/ */
static void static void
capture_input_error(capture_session *cap_session, char *error_msg, capture_input_error(capture_session *cap_session _U_, char *error_msg,
char *secondary_error_msg) char *secondary_error_msg)
{ {
gchar *safe_error_msg; gchar *safe_error_msg;
@ -582,7 +583,7 @@ capture_input_error(capture_session *cap_session, char *error_msg,
ws_message("Error message from child: \"%s\", \"%s\"", error_msg, secondary_error_msg); ws_message("Error message from child: \"%s\", \"%s\"", error_msg, secondary_error_msg);
g_assert(cap_session->state == CAPTURE_PREPARING || cap_session->state == CAPTURE_RUNNING); ws_assert(cap_session->state == CAPTURE_PREPARING || cap_session->state == CAPTURE_RUNNING);
safe_error_msg = simple_dialog_format_message(error_msg); safe_error_msg = simple_dialog_format_message(error_msg);
if (*secondary_error_msg != '\0') { if (*secondary_error_msg != '\0') {
@ -619,8 +620,8 @@ capture_input_cfilter_error(capture_session *cap_session, guint i,
ws_message("Capture filter error message from child: \"%s\"", error_message); ws_message("Capture filter error message from child: \"%s\"", error_message);
g_assert(cap_session->state == CAPTURE_PREPARING || cap_session->state == CAPTURE_RUNNING); ws_assert(cap_session->state == CAPTURE_PREPARING || cap_session->state == CAPTURE_RUNNING);
g_assert(i < capture_opts->ifaces->len); ws_assert(i < capture_opts->ifaces->len);
interface_opts = &g_array_index(capture_opts->ifaces, interface_options, i); interface_opts = &g_array_index(capture_opts->ifaces, interface_options, i);
safe_cfilter = simple_dialog_format_message(interface_opts->cfilter); safe_cfilter = simple_dialog_format_message(interface_opts->cfilter);
@ -665,7 +666,7 @@ capture_input_closed(capture_session *cap_session, gchar *msg)
int err; int err;
ws_message("Capture stopped."); ws_message("Capture stopped.");
g_assert(cap_session->state == CAPTURE_PREPARING || cap_session->state == CAPTURE_RUNNING); ws_assert(cap_session->state == CAPTURE_PREPARING || cap_session->state == CAPTURE_RUNNING);
if (msg != NULL) if (msg != NULL)
simple_dialog(ESD_TYPE_ERROR, ESD_BTN_OK, "%s", msg); simple_dialog(ESD_TYPE_ERROR, ESD_BTN_OK, "%s", msg);
@ -822,7 +823,7 @@ capture_stat_start(capture_options *capture_opts)
device = &g_array_index(capture_opts->all_ifaces, interface_t, i); device = &g_array_index(capture_opts->all_ifaces, interface_t, i);
if (device->type != IF_PIPE) { if (device->type != IF_PIPE) {
sc_item = g_new0(if_stat_cache_item_t, 1); sc_item = g_new0(if_stat_cache_item_t, 1);
g_assert(device->if_info.name); ws_assert(device->if_info.name);
sc_item->name = g_strdup(device->if_info.name); sc_item->name = g_strdup(device->if_info.name);
sc->cache_list = g_list_prepend(sc->cache_list, sc_item); sc->cache_list = g_list_prepend(sc->cache_list, sc_item);
} }

View File

@ -19,6 +19,7 @@
#include <epan/tap.h> #include <epan/tap.h>
#include <epan/stat_tap_ui.h> #include <epan/stat_tap_ui.h>
#include <epan/expert.h> #include <epan/expert.h>
#include <wsutil/ws_assert.h>
void register_tap_listener_expert_info(void); void register_tap_listener_expert_info(void);
@ -98,7 +99,7 @@ expert_stat_packet(void *tapdata, packet_info *pinfo _U_, epan_dissect_t *edt _U
severity_level = error_level; severity_level = error_level;
break; break;
default: default:
g_assert_not_reached(); ws_assert_not_reached();
return TAP_PACKET_DONT_REDRAW; return TAP_PACKET_DONT_REDRAW;
} }

View File

@ -24,6 +24,7 @@
#include <epan/follow.h> #include <epan/follow.h>
#include <epan/stat_tap_ui.h> #include <epan/stat_tap_ui.h>
#include <epan/tap.h> #include <epan/tap.h>
#include <wsutil/ws_assert.h>
void register_tap_listener_follow(void); void register_tap_listener_follow(void);
@ -71,11 +72,11 @@ static const char * follow_str_type(cli_follow_info_t* cli_follow_info)
case SHOW_RAW: return "raw"; case SHOW_RAW: return "raw";
case SHOW_YAML: return "yaml"; case SHOW_YAML: return "yaml";
default: default:
g_assert_not_reached(); ws_assert_not_reached();
break; break;
} }
g_assert_not_reached(); ws_assert_not_reached();
return "<unknown-mode>"; return "<unknown-mode>";
} }
@ -245,7 +246,7 @@ static void follow_draw(void *contextp)
break; break;
default: default:
g_assert_not_reached(); ws_assert_not_reached();
} }
/* Print data */ /* Print data */
@ -316,7 +317,7 @@ static void follow_draw(void *contextp)
break; break;
default: default:
g_assert_not_reached(); ws_assert_not_reached();
} }
} }

View File

@ -17,6 +17,7 @@
#include <epan/tap.h> #include <epan/tap.h>
#include <epan/stat_tap_ui.h> #include <epan/stat_tap_ui.h>
#include "globals.h" #include "globals.h"
#include <wsutil/ws_assert.h>
#define CALC_TYPE_FRAMES 0 #define CALC_TYPE_FRAMES 0
#define CALC_TYPE_BYTES 1 #define CALC_TYPE_BYTES 1
@ -195,7 +196,7 @@ iostat_packet(void *arg, packet_info *pinfo, epan_dissect_t *edt, const void *du
* "Can't happen"; see the checks * "Can't happen"; see the checks
* in register_io_tap(). * in register_io_tap().
*/ */
g_assert_not_reached(); ws_assert_not_reached();
break; break;
} }
} }
@ -271,7 +272,7 @@ iostat_packet(void *arg, packet_info *pinfo, epan_dissect_t *edt, const void *du
* "Can't happen"; see the checks * "Can't happen"; see the checks
* in register_io_tap(). * in register_io_tap().
*/ */
g_assert_not_reached(); ws_assert_not_reached();
break; break;
} }
} }
@ -340,7 +341,7 @@ iostat_packet(void *arg, packet_info *pinfo, epan_dissect_t *edt, const void *du
* "Can't happen"; see the checks * "Can't happen"; see the checks
* in register_io_tap(). * in register_io_tap().
*/ */
g_assert_not_reached(); ws_assert_not_reached();
break; break;
} }
} }
@ -399,7 +400,7 @@ iostat_packet(void *arg, packet_info *pinfo, epan_dissect_t *edt, const void *du
* "Can't happen"; see the checks * "Can't happen"; see the checks
* in register_io_tap(). * in register_io_tap().
*/ */
g_assert_not_reached(); ws_assert_not_reached();
break; break;
} }
} }

View File

@ -35,6 +35,7 @@
#include <ui/cmdarg_err.h> #include <ui/cmdarg_err.h>
#include <ui/exit_codes.h> #include <ui/exit_codes.h>
#include <wsutil/filesystem.h> #include <wsutil/filesystem.h>
#include <wsutil/ws_assert.h>
#include <epan/ex-opt.h> #include <epan/ex-opt.h>
#include <epan/packet.h> #include <epan/packet.h>
@ -521,7 +522,7 @@ void commandline_other_options(int argc, char *argv[], gboolean opt_reset)
exit_application(1); exit_application(1);
break; break;
default: default:
g_assert_not_reached(); ws_assert_not_reached();
} }
break; break;
case PREFS_SET_OBSOLETE: case PREFS_SET_OBSOLETE:
@ -530,7 +531,7 @@ void commandline_other_options(int argc, char *argv[], gboolean opt_reset)
exit_application(1); exit_application(1);
break; break;
default: default:
g_assert_not_reached(); ws_assert_not_reached();
} }
break; break;
} }

View File

@ -15,6 +15,7 @@
#include "epan/prefs.h" #include "epan/prefs.h"
#include "wsutil/time_util.h" #include "wsutil/time_util.h"
#include <wsutil/ws_assert.h>
#include "console.h" #include "console.h"

View File

@ -23,6 +23,7 @@
#include "wsutil/file_util.h" #include "wsutil/file_util.h"
#include "wsutil/filesystem.h" #include "wsutil/filesystem.h"
#include <wsutil/ws_assert.h>
#include "ui/cmdarg_err.h" #include "ui/cmdarg_err.h"
#include "version_info.h" #include "version_info.h"
@ -63,8 +64,8 @@ display_dissector_names(const gchar *table _U_, gpointer handle, gpointer output
if (proto_id != -1) { if (proto_id != -1) {
proto_filter_name = proto_get_protocol_filter_name(proto_id); proto_filter_name = proto_get_protocol_filter_name(proto_id);
proto_ui_name = proto_get_protocol_name(proto_id); proto_ui_name = proto_get_protocol_name(proto_id);
g_assert(proto_filter_name != NULL); ws_assert(proto_filter_name != NULL);
g_assert(proto_ui_name != NULL); ws_assert(proto_ui_name != NULL);
if ((prev_display_dissector_name == NULL) || if ((prev_display_dissector_name == NULL) ||
(strcmp(prev_display_dissector_name, proto_filter_name) != 0)) { (strcmp(prev_display_dissector_name, proto_filter_name) != 0)) {
@ -141,14 +142,14 @@ find_protocol_name_func(const gchar *table _U_, gpointer handle, gpointer user_d
const gchar *protocol_filter_name; const gchar *protocol_filter_name;
protocol_name_search_t search_info; protocol_name_search_t search_info;
g_assert(handle); ws_assert(handle);
search_info = (protocol_name_search_t)user_data; search_info = (protocol_name_search_t)user_data;
proto_id = dissector_handle_get_protocol_index((dissector_handle_t)handle); proto_id = dissector_handle_get_protocol_index((dissector_handle_t)handle);
if (proto_id != -1) { if (proto_id != -1) {
protocol_filter_name = proto_get_protocol_filter_name(proto_id); protocol_filter_name = proto_get_protocol_filter_name(proto_id);
g_assert(protocol_filter_name != NULL); ws_assert(protocol_filter_name != NULL);
if (strcmp(protocol_filter_name, search_info->searched_name) == 0) { if (strcmp(protocol_filter_name, search_info->searched_name) == 0) {
/* Found a match */ /* Found a match */
if (search_info->nb_match == 0) { if (search_info->nb_match == 0) {
@ -186,9 +187,9 @@ gboolean decode_as_command_option(const gchar *cl_param)
/* The following code will allocate and copy the command-line options in a string pointed by decoded_param */ /* The following code will allocate and copy the command-line options in a string pointed by decoded_param */
g_assert(cl_param); ws_assert(cl_param);
decoded_param = g_strdup(cl_param); decoded_param = g_strdup(cl_param);
g_assert(decoded_param); ws_assert(decoded_param);
/* The lines below will parse this string (modifying it) to extract all /* The lines below will parse this string (modifying it) to extract all
@ -358,7 +359,7 @@ gboolean decode_as_command_option(const gchar *cl_param)
default: default:
/* There are currently no dissector tables with any types other /* There are currently no dissector tables with any types other
than the ones listed above. */ than the ones listed above. */
g_assert_not_reached(); ws_assert_not_reached();
} }
if (remaining_param == NULL) { if (remaining_param == NULL) {
@ -482,7 +483,7 @@ gboolean decode_as_command_option(const gchar *cl_param)
default: default:
/* There are currently no dissector tables with any types other /* There are currently no dissector tables with any types other
than the ones listed above. */ than the ones listed above. */
g_assert_not_reached(); ws_assert_not_reached();
} }
g_free(decoded_param); /* "Decode As" rule has been successfully added */ g_free(decoded_param); /* "Decode As" rule has been successfully added */
return TRUE; return TRUE;

View File

@ -33,6 +33,7 @@
#include <ui/clopts_common.h> #include <ui/clopts_common.h>
#include <ui/cmdarg_err.h> #include <ui/cmdarg_err.h>
#include <wsutil/file_util.h> #include <wsutil/file_util.h>
#include <wsutil/ws_assert.h>
#include "ui/dissect_opts.h" #include "ui/dissect_opts.h"
@ -146,7 +147,7 @@ dissect_opts_handle_opt(int opt, char *optarg_str_p)
break; break;
default: default:
/* the caller is responsible to send us only the right opt's */ /* the caller is responsible to send us only the right opt's */
g_assert_not_reached(); ws_assert_not_reached();
} }
return TRUE; return TRUE;
} }

View File

@ -21,6 +21,7 @@
#include <wsutil/filesystem.h> #include <wsutil/filesystem.h>
#include <wsutil/report_message.h> #include <wsutil/report_message.h>
#include <wsutil/wslog.h> #include <wsutil/wslog.h>
#include <wsutil/ws_assert.h>
#include "ui/filter_files.h" #include "ui/filter_files.h"
@ -144,7 +145,7 @@ read_filter_list(filter_list_type_t list_type)
break; break;
default: default:
g_assert_not_reached(); ws_assert_not_reached();
return; return;
} }
@ -383,7 +384,7 @@ get_filter_list(filter_list_type_t list_type)
break; break;
default: default:
g_assert_not_reached(); ws_assert_not_reached();
flpp = NULL; flpp = NULL;
} }
return flpp; return flpp;
@ -461,7 +462,7 @@ save_filter_list(filter_list_type_t list_type)
break; break;
default: default:
g_assert_not_reached(); ws_assert_not_reached();
return; return;
} }

View File

@ -18,6 +18,7 @@
#include "help_url.h" #include "help_url.h"
#include "urls.h" #include "urls.h"
#include "wsutil/filesystem.h" #include "wsutil/filesystem.h"
#include <wsutil/ws_assert.h>
// To do: // To do:
// - Automatically generate part or all of this, e.g. by parsing // - Automatically generate part or all of this, e.g. by parsing
@ -303,7 +304,7 @@ topic_action_url(topic_action_e action)
case(TOPIC_ACTION_NONE): case(TOPIC_ACTION_NONE):
default: default:
g_assert_not_reached(); ws_assert_not_reached();
url = g_strdup(WS_HOME_PAGE_URL); url = g_strdup(WS_HOME_PAGE_URL);
} }

View File

@ -40,7 +40,7 @@ GString *check_field_unit(const char *field_name, int *hf_index, io_graph_item_u
if (item_unit >= IOG_ITEM_UNIT_CALC_SUM) { if (item_unit >= IOG_ITEM_UNIT_CALC_SUM) {
header_field_info *hfi; header_field_info *hfi;
const char *item_unit_names[NUM_IOG_ITEM_UNITS] = { const char *item_unit_names[NUM_IOG_ITEM_UNITS+1] = {
"Packets", "Packets",
"Bytes", "Bytes",
"Bits", "Bits",
@ -50,7 +50,8 @@ GString *check_field_unit(const char *field_name, int *hf_index, io_graph_item_u
"MAX", "MAX",
"MIN", "MIN",
"AVG", "AVG",
"LOAD" "LOAD",
NULL
}; };
/* There was no field specified */ /* There was no field specified */
@ -104,7 +105,7 @@ GString *check_field_unit(const char *field_name, int *hf_index, io_graph_item_u
case IOG_ITEM_UNIT_CALC_LOAD: case IOG_ITEM_UNIT_CALC_LOAD:
break; break;
default: default:
g_assert(item_unit < NUM_IOG_ITEM_UNITS); ws_assert(item_unit < NUM_IOG_ITEM_UNITS);
err_str = g_string_new(""); err_str = g_string_new("");
g_string_printf(err_str, "\"%s\" is a relative-time field. %s calculations are not supported on it.", g_string_printf(err_str, "\"%s\" is a relative-time field. %s calculations are not supported on it.",
field_name, field_name,

View File

@ -14,6 +14,7 @@
#define __IO_GRAPH_ITEM_H__ #define __IO_GRAPH_ITEM_H__
#include "cfile.h" #include "cfile.h"
#include <wsutil/ws_assert.h>
#ifdef __cplusplus #ifdef __cplusplus
extern "C" { extern "C" {
@ -381,7 +382,7 @@ update_io_graph_item(io_graph_item_t *items, int idx, packet_info *pinfo, epan_d
* type is compatible" check in * type is compatible" check in
* filter_callback(). * filter_callback().
*/ */
g_assert_not_reached(); ws_assert_not_reached();
} }
break; break;
} }

View File

@ -21,6 +21,8 @@
#include "packet_range.h" #include "packet_range.h"
#include <wsutil/ws_assert.h>
/* (re-)calculate the packet counts (except the user specified range) */ /* (re-)calculate the packet counts (except the user specified range) */
static void packet_range_calc(packet_range_t *range) { static void packet_range_calc(packet_range_t *range) {
guint32 framenum; guint32 framenum;
@ -54,7 +56,7 @@ static void packet_range_calc(packet_range_t *range) {
range->displayed_ignored_mark_range_cnt = 0; range->displayed_ignored_mark_range_cnt = 0;
range->displayed_ignored_user_range_cnt = 0; range->displayed_ignored_user_range_cnt = 0;
g_assert(range->cf != NULL); ws_assert(range->cf != NULL);
/* XXX - this doesn't work unless you have a full set of frame_data /* XXX - this doesn't work unless you have a full set of frame_data
* structures for all packets in the capture, which is not, * structures for all packets in the capture, which is not,
@ -160,7 +162,7 @@ static void packet_range_calc_user(packet_range_t *range) {
range->displayed_user_range_cnt = 0; range->displayed_user_range_cnt = 0;
range->displayed_ignored_user_range_cnt = 0; range->displayed_ignored_user_range_cnt = 0;
g_assert(range->cf != NULL); ws_assert(range->cf != NULL);
/* XXX - this doesn't work unless you have a full set of frame_data /* XXX - this doesn't work unless you have a full set of frame_data
* structures for all packets in the capture, which is not, * structures for all packets in the capture, which is not,
@ -210,7 +212,7 @@ static void packet_range_calc_selection(packet_range_t *range) {
range->displayed_selection_range_cnt = 0; range->displayed_selection_range_cnt = 0;
range->displayed_ignored_selection_range_cnt = 0; range->displayed_ignored_selection_range_cnt = 0;
g_assert(range->cf != NULL); ws_assert(range->cf != NULL);
if (range->cf->provider.frames != NULL) { if (range->cf->provider.frames != NULL) {
for (framenum = 1; framenum <= range->cf->count; framenum++) { for (framenum = 1; framenum <= range->cf->count; framenum++) {
@ -292,7 +294,7 @@ range_process_e packet_range_process_packet(packet_range_t *range, frame_data *f
return range_process_next; return range_process_next;
} }
g_assert(range->cf != NULL); ws_assert(range->cf != NULL);
switch(range->process) { switch(range->process) {
case(range_process_all): case(range_process_all):
@ -329,7 +331,7 @@ range_process_e packet_range_process_packet(packet_range_t *range, frame_data *f
} }
break; break;
default: default:
g_assert_not_reached(); ws_assert_not_reached();
} }
/* This packet has to pass the display filter but didn't? /* This packet has to pass the display filter but didn't?
@ -361,7 +363,7 @@ void packet_range_convert_str(packet_range_t *range, const gchar *es)
if (range->user_range != NULL) if (range->user_range != NULL)
wmem_free(NULL, range->user_range); wmem_free(NULL, range->user_range);
g_assert(range->cf != NULL); ws_assert(range->cf != NULL);
ret = range_convert_str(NULL, &new_range, es, range->cf->count); ret = range_convert_str(NULL, &new_range, es, range->cf->count);
if (ret != CVT_NO_ERROR) { if (ret != CVT_NO_ERROR) {
@ -388,7 +390,7 @@ void packet_range_convert_selection_str(packet_range_t *range, const char *es)
if (range->selection_range != NULL) if (range->selection_range != NULL)
wmem_free(NULL, range->selection_range); wmem_free(NULL, range->selection_range);
g_assert(range->cf != NULL); ws_assert(range->cf != NULL);
ret = range_convert_str(NULL, &new_range, es, range->cf->count); ret = range_convert_str(NULL, &new_range, es, range->cf->count);
if (ret != CVT_NO_ERROR) { if (ret != CVT_NO_ERROR) {

View File

@ -24,6 +24,7 @@
#include "ui/recent.h" #include "ui/recent.h"
#include <wsutil/file_util.h> #include <wsutil/file_util.h>
#include <wsutil/ws_assert.h>
static GList *current_profiles = NULL; static GList *current_profiles = NULL;
static GList *edited_profiles = NULL; static GList *edited_profiles = NULL;
@ -268,7 +269,7 @@ empty_profile_list(gboolean edit_list)
*flpp = remove_profile_entry(*flpp, g_list_first(*flpp)); *flpp = remove_profile_entry(*flpp, g_list_first(*flpp));
} }
g_assert(g_list_length(*flpp) == 0); ws_assert(g_list_length(*flpp) == 0);
if ( ! edited_profiles ) if ( ! edited_profiles )
edited_profiles = NULL; edited_profiles = NULL;
} }
@ -279,7 +280,7 @@ empty_profile_list(gboolean edit_list)
*flpp = remove_profile_entry(*flpp, g_list_first(*flpp)); *flpp = remove_profile_entry(*flpp, g_list_first(*flpp));
} }
g_assert(g_list_length(*flpp) == 0); ws_assert(g_list_length(*flpp) == 0);
if ( ! current_profiles ) if ( ! current_profiles )
current_profiles = NULL; current_profiles = NULL;
} }

View File

@ -18,6 +18,7 @@
#include "ui/progress_dlg.h" #include "ui/progress_dlg.h"
#include "epan/epan_dissect.h" #include "epan/epan_dissect.h"
#include "epan/proto.h" #include "epan/proto.h"
#include <wsutil/ws_assert.h>
/* Update the progress bar this many times when scanning the packet list. */ /* Update the progress bar this many times when scanning the packet list. */
#define N_PROGBAR_UPDATES 100 #define N_PROGBAR_UPDATES 100
@ -88,7 +89,7 @@ process_node(proto_node *ptree_node, GNode *parent_stat_node, ph_stats_t *ps)
finfo = PNODE_FINFO(ptree_node); finfo = PNODE_FINFO(ptree_node);
/* We don't fake protocol nodes we expect them to have a field_info. /* We don't fake protocol nodes we expect them to have a field_info.
* Dissection with faked proto tree? */ * Dissection with faked proto tree? */
g_assert(finfo); ws_assert(finfo);
/* If the field info isn't related to a protocol but to a field, /* If the field info isn't related to a protocol but to a field,
* don't count them, as they don't belong to any protocol. * don't count them, as they don't belong to any protocol.
@ -255,7 +256,7 @@ ph_stats_new(capture_file *cf)
/* let's not divide by zero. I should never be started /* let's not divide by zero. I should never be started
* with count == 0, so let's assert that * with count == 0, so let's assert that
*/ */
g_assert(cf->count > 0); ws_assert(cf->count > 0);
progbar_val = (gfloat) count / cf->count; progbar_val = (gfloat) count / cf->count;

View File

@ -29,6 +29,7 @@
#include "ui/alert_box.h" #include "ui/alert_box.h"
#include "ui/simple_dialog.h" #include "ui/simple_dialog.h"
#include <wsutil/utf8_entities.h> #include <wsutil/utf8_entities.h>
#include <wsutil/ws_assert.h>
#include "wsutil/file_util.h" #include "wsutil/file_util.h"
#include "wsutil/str_util.h" #include "wsutil/str_util.h"
@ -111,7 +112,7 @@ FollowStreamDialog::FollowStreamDialog(QWidget &parent, CaptureFile &cf, follow_
follower_ = get_follow_by_name("SIP"); follower_ = get_follow_by_name("SIP");
break; break;
default : default :
g_assert_not_reached(); ws_assert_not_reached();
} }
memset(&follow_info_, 0, sizeof(follow_info_)); memset(&follow_info_, 0, sizeof(follow_info_));
@ -537,7 +538,7 @@ FollowStreamDialog::readStream()
break; break;
default : default :
g_assert_not_reached(); ws_assert_not_reached();
ret = (frs_return_t)0; ret = (frs_return_t)0;
break; break;
} }

View File

@ -17,6 +17,7 @@
#include "epan/uat-int.h" #include "epan/uat-int.h"
#include <wsutil/utf8_entities.h> #include <wsutil/utf8_entities.h>
#include <wsutil/ws_assert.h>
#include <ui/qt/utils/qt_ui_utils.h> #include <ui/qt/utils/qt_ui_utils.h>
@ -2095,7 +2096,7 @@ void IOGraph::reloadValueUnitField()
// Check if a packet is available at the given interval (idx). // Check if a packet is available at the given interval (idx).
bool IOGraph::hasItemToShow(int idx, double value) const bool IOGraph::hasItemToShow(int idx, double value) const
{ {
g_assert(idx < max_io_items_); ws_assert(idx < max_io_items_);
bool result = false; bool result = false;
@ -2141,7 +2142,7 @@ void IOGraph::setInterval(int interval)
// Get the value at the given interval (idx) for the current value unit. // Get the value at the given interval (idx) for the current value unit.
double IOGraph::getItemValue(int idx, const capture_file *cap_file) const double IOGraph::getItemValue(int idx, const capture_file *cap_file) const
{ {
g_assert(idx < max_io_items_); ws_assert(idx < max_io_items_);
return get_io_graph_item(items_, val_units_, idx, hf_index_, cap_file, interval_, cur_idx_); return get_io_graph_item(items_, val_units_, idx, hf_index_, cap_file, interval_, cur_idx_);
} }

View File

@ -22,6 +22,7 @@ DIAG_ON(frame-larger-than=)
#include <epan/epan_dissect.h> #include <epan/epan_dissect.h>
#include <wsutil/filesystem.h> #include <wsutil/filesystem.h>
#include <wsutil/wslog.h> #include <wsutil/wslog.h>
#include <wsutil/ws_assert.h>
#include <version_info.h> #include <version_info.h>
#include <epan/prefs.h> #include <epan/prefs.h>
#include <epan/stats_tree_priv.h> #include <epan/stats_tree_priv.h>
@ -1380,7 +1381,7 @@ bool MainWindow::saveCaptureFile(capture_file *cf, bool dont_reopen) {
default: default:
/* Squelch warnings that discard_comments is being used /* Squelch warnings that discard_comments is being used
uninitialized. */ uninitialized. */
g_assert_not_reached(); ws_assert_not_reached();
return false; return false;
} }

View File

@ -29,6 +29,8 @@
#include <ui/qt/packet_diagram.h> #include <ui/qt/packet_diagram.h>
#include <ui/qt/proto_tree.h> #include <ui/qt/proto_tree.h>
#include <wsutil/ws_assert.h>
/* /*
* The generated Ui_MainWindow::setupUi() can grow larger than our configured limit, * The generated Ui_MainWindow::setupUi() can grow larger than our configured limit,
* so turn off -Wframe-larger-than= for ui_main_window.h. * so turn off -Wframe-larger-than= for ui_main_window.h.
@ -60,7 +62,7 @@ QWidget* MainWindow::getLayoutWidget(layout_pane_content_e type) {
case layout_pane_content_pdiagram: case layout_pane_content_pdiagram:
return packet_diagram_; return packet_diagram_;
default: default:
g_assert_not_reached(); ws_assert_not_reached();
return NULL; return NULL;
} }
} }
@ -116,7 +118,7 @@ void MainWindow::layoutPanes()
break; break;
default: default:
g_assert_not_reached(); ws_assert_not_reached();
} }
switch(prefs.gui_layout_type) { switch(prefs.gui_layout_type) {
@ -139,7 +141,7 @@ void MainWindow::layoutPanes()
parents[2] = &master_split_; parents[2] = &master_split_;
break; break;
default: default:
g_assert_not_reached(); ws_assert_not_reached();
} }
if (parents[0] == &extra_split_) { if (parents[0] == &extra_split_) {

View File

@ -45,6 +45,7 @@ DIAG_ON(frame-larger-than=)
#include "wsutil/file_util.h" #include "wsutil/file_util.h"
#include "wsutil/filesystem.h" #include "wsutil/filesystem.h"
#include <wsutil/wslog.h> #include <wsutil/wslog.h>
#include <wsutil/ws_assert.h>
#include "epan/addr_resolv.h" #include "epan/addr_resolv.h"
#include "epan/column.h" #include "epan/column.h"
@ -463,7 +464,7 @@ void MainWindow::queuedFilterAction(QString action_filter, FilterAction::Action
} }
break; break;
default: default:
g_assert_not_reached(); ws_assert_not_reached();
break; break;
} }
@ -492,7 +493,7 @@ void MainWindow::queuedFilterAction(QString action_filter, FilterAction::Action
break; break;
} }
default: default:
g_assert_not_reached(); ws_assert_not_reached();
break; break;
} }
} }
@ -960,10 +961,10 @@ void MainWindow::pipeTimeout() {
} }
void MainWindow::pipeActivated(int source) { void MainWindow::pipeActivated(int source) {
#ifdef _WIN32
Q_UNUSED(source) Q_UNUSED(source)
#else
g_assert(source == pipe_source_); #ifndef _WIN32
ws_assert(source == pipe_source_);
pipe_notifier_->setEnabled(false); pipe_notifier_->setEnabled(false);
if (pipe_input_cb_(pipe_source_, pipe_user_data_)) { if (pipe_input_cb_(pipe_source_, pipe_user_data_)) {

View File

@ -21,6 +21,7 @@
#include <ui/qt/utils/qt_ui_utils.h> #include <ui/qt/utils/qt_ui_utils.h>
#include <wsutil/file_util.h> #include <wsutil/file_util.h>
#include <wsutil/ws_assert.h>
#include <QVector> #include <QVector>
@ -199,7 +200,7 @@ QVariant DecodeAsModel::headerData(int section, Qt::Orientation orientation, int
case colProtocol: case colProtocol:
return tr("Current"); return tr("Current");
default: default:
g_assert_not_reached(); ws_assert_not_reached();
} }
return QVariant(); return QVariant();
@ -548,7 +549,7 @@ QString DecodeAsModel::entryString(const gchar *table_name, gconstpointer value)
break; break;
default: default:
g_assert_not_reached(); ws_assert_not_reached();
break; break;
} }
entry_str = QString("%1").arg(int_to_qstring(num_val, width, 16)); entry_str = QString("%1").arg(int_to_qstring(num_val, width, 16));
@ -578,7 +579,7 @@ QString DecodeAsModel::entryString(const gchar *table_name, gconstpointer value)
return "0"; return "0";
default: default:
g_assert_not_reached(); ws_assert_not_reached();
break; break;
} }
return entry_str; return entry_str;

View File

@ -12,6 +12,7 @@
#include <ui/qt/models/uat_delegate.h> #include <ui/qt/models/uat_delegate.h>
#include "epan/value_string.h" #include "epan/value_string.h"
#include <wsutil/ws_assert.h>
#include <QComboBox> #include <QComboBox>
#include <QEvent> #include <QEvent>
#include <QFileDialog> #include <QFileDialog>
@ -128,7 +129,7 @@ QWidget *UatDelegate::createEditor(QWidget *parent, const QStyleOptionViewItem &
break; break;
default: default:
g_assert_not_reached(); ws_assert_not_reached();
break; break;
} }

View File

@ -9,6 +9,7 @@
#include "voip_calls_info_model.h" #include "voip_calls_info_model.h"
#include <wsutil/utf8_entities.h> #include <wsutil/utf8_entities.h>
#include <wsutil/ws_assert.h>
#include <ui/qt/utils/qt_ui_utils.h> #include <ui/qt/utils/qt_ui_utils.h>
#include <QDateTime> #include <QDateTime>
@ -101,7 +102,7 @@ QVariant VoipCallsInfoModel::data(const QModelIndex &index, int role) const
return call_info->call_comment; return call_info->call_comment;
} }
case ColumnCount: case ColumnCount:
g_assert_not_reached(); ws_assert_not_reached();
} }
return QVariant(); return QVariant();
} }
@ -131,7 +132,7 @@ QVariant VoipCallsInfoModel::headerData(int section, Qt::Orientation orientation
case Comments: case Comments:
return tr("Comments"); return tr("Comments");
case ColumnCount: case ColumnCount:
g_assert_not_reached(); ws_assert_not_reached();
} }
} }
return QVariant(); return QVariant();

View File

@ -9,6 +9,7 @@
#include "packet_range_group_box.h" #include "packet_range_group_box.h"
#include <ui_packet_range_group_box.h> #include <ui_packet_range_group_box.h>
#include <wsutil/ws_assert.h>
PacketRangeGroupBox::PacketRangeGroupBox(QWidget *parent) : PacketRangeGroupBox::PacketRangeGroupBox(QWidget *parent) :
QGroupBox(parent), QGroupBox(parent),
@ -211,7 +212,7 @@ void PacketRangeGroupBox::updateCounts() {
break; break;
default: default:
g_assert_not_reached(); ws_assert_not_reached();
return; return;
} }
@ -238,7 +239,7 @@ void PacketRangeGroupBox::updateCounts() {
displayed_ignored_cnt = range_->displayed_ignored_user_range_cnt; displayed_ignored_cnt = range_->displayed_ignored_user_range_cnt;
break; break;
default: default:
g_assert_not_reached(); ws_assert_not_reached();
} }
if (displayed_checked) if (displayed_checked)

View File

@ -12,7 +12,7 @@
#include "file.h" #include "file.h"
#include <epan/tap.h> #include <epan/tap.h>
#include <wsutil/ws_assert.h>
#include <ui/service_response_time.h> #include <ui/service_response_time.h>
#include "rpc_service_response_time_dialog.h" #include "rpc_service_response_time_dialog.h"
@ -332,7 +332,7 @@ const QString ServiceResponseTimeDialog::filterExpression()
QTreeWidgetItem *ti = statsTreeWidget()->selectedItems()[0]; QTreeWidgetItem *ti = statsTreeWidget()->selectedItems()[0];
if (ti->type() == srt_row_type_) { if (ti->type() == srt_row_type_) {
SrtTableTreeWidgetItem *srtt_ti = static_cast<SrtTableTreeWidgetItem *>(ti->parent()); SrtTableTreeWidgetItem *srtt_ti = static_cast<SrtTableTreeWidgetItem *>(ti->parent());
g_assert(srtt_ti); ws_assert(srtt_ti);
QString field = srtt_ti->filterField(); QString field = srtt_ti->filterField();
QString value = ti->text(SRT_COLUMN_INDEX); QString value = ti->text(SRT_COLUMN_INDEX);
if (!field.isEmpty() && !value.isEmpty()) { if (!field.isEmpty() && !value.isEmpty()) {

View File

@ -55,6 +55,7 @@
#include "ui/voip_calls.h" #include "ui/voip_calls.h"
#include "wsutil/glib-compat.h" #include "wsutil/glib-compat.h"
#include <wsutil/ws_assert.h>
#define DUMP_PTR1(p) printf("#=> %p\n",(void *)p) #define DUMP_PTR1(p) printf("#=> %p\n",(void *)p)
#define DUMP_PTR2(p) printf("==> %p\n",(void *)p) #define DUMP_PTR2(p) printf("==> %p\n",(void *)p)
@ -2042,7 +2043,7 @@ h225_calls_packet(void *tap_offset_ptr, packet_info *pinfo, epan_dissect_t *edt,
while (list) while (list)
{ {
tmp_listinfo=(voip_calls_info_t *)list->data; tmp_listinfo=(voip_calls_info_t *)list->data;
g_assert(tmp_listinfo != NULL); ws_assert(tmp_listinfo != NULL);
if (tmp_listinfo->protocol == VOIP_H323) { if (tmp_listinfo->protocol == VOIP_H323) {
tmp_h323info = (h323_calls_info_t *)tmp_listinfo->prot_info; tmp_h323info = (h323_calls_info_t *)tmp_listinfo->prot_info;
if (tmp_h323info->requestSeqNum == pi->requestSeqNum) { if (tmp_h323info->requestSeqNum == pi->requestSeqNum) {
@ -2060,7 +2061,7 @@ h225_calls_packet(void *tap_offset_ptr, packet_info *pinfo, epan_dissect_t *edt,
tmp_listinfo=(voip_calls_info_t *)list->data; tmp_listinfo=(voip_calls_info_t *)list->data;
if (tmp_listinfo->protocol == VOIP_H323) { if (tmp_listinfo->protocol == VOIP_H323) {
tmp_h323info = (h323_calls_info_t *)tmp_listinfo->prot_info; tmp_h323info = (h323_calls_info_t *)tmp_listinfo->prot_info;
g_assert(tmp_h323info != NULL); ws_assert(tmp_h323info != NULL);
if ( (memcmp(tmp_h323info->guid, &guid_allzero, GUID_LEN) != 0) && (memcmp(tmp_h323info->guid, &pi->guid,GUID_LEN)==0) ) { if ( (memcmp(tmp_h323info->guid, &guid_allzero, GUID_LEN) != 0) && (memcmp(tmp_h323info->guid, &pi->guid,GUID_LEN)==0) ) {
callsinfo = (voip_calls_info_t*)(list->data); callsinfo = (voip_calls_info_t*)(list->data);
break; break;
@ -2088,7 +2089,7 @@ h225_calls_packet(void *tap_offset_ptr, packet_info *pinfo, epan_dissect_t *edt,
callsinfo->free_prot_info = free_h225_info; callsinfo->free_prot_info = free_h225_info;
tmp_h323info = (h323_calls_info_t *)callsinfo->prot_info; tmp_h323info = (h323_calls_info_t *)callsinfo->prot_info;
g_assert(tmp_h323info != NULL); ws_assert(tmp_h323info != NULL);
tmp_h323info->guid = (e_guid_t *)g_memdup2(&pi->guid, sizeof pi->guid); tmp_h323info->guid = (e_guid_t *)g_memdup2(&pi->guid, sizeof pi->guid);
/* DUMP_PTR1(tmp_h323info->guid); */ /* DUMP_PTR1(tmp_h323info->guid); */
@ -2120,7 +2121,7 @@ h225_calls_packet(void *tap_offset_ptr, packet_info *pinfo, epan_dissect_t *edt,
/* XXX: it is supposed to be initialized isn't it? */ /* XXX: it is supposed to be initialized isn't it? */
g_assert(tmp_h323info != NULL); ws_assert(tmp_h323info != NULL);
/* change the status */ /* change the status */
if (pi->msg_type == H225_CS) { if (pi->msg_type == H225_CS) {
@ -2756,7 +2757,7 @@ mgcp_calls_packet(void *tap_offset_ptr, packet_info *pinfo, epan_dissect_t *edt,
g_queue_push_tail(tapinfo->callsinfos, callsinfo); g_queue_push_tail(tapinfo->callsinfos, callsinfo);
} }
g_assert(tmp_mgcpinfo != NULL); ws_assert(tmp_mgcpinfo != NULL);
/* change call state and add to graph */ /* change call state and add to graph */
switch (pi->mgcp_type) switch (pi->mgcp_type)

View File

@ -26,6 +26,7 @@
#include "wsutil/file_util.h" #include "wsutil/file_util.h"
#include "wsutil/str_util.h" #include "wsutil/str_util.h"
#include "wsutil/unicode-utils.h" #include "wsutil/unicode-utils.h"
#include <wsutil/ws_assert.h>
#include "wsutil/filesystem.h" #include "wsutil/filesystem.h"
#include "epan/prefs.h" #include "epan/prefs.h"
@ -459,7 +460,7 @@ win32_merge_file (HWND h_wnd, const wchar_t *title, GString *file_name, GString
*merge_type = -1; *merge_type = -1;
break; break;
default: default:
g_assert_not_reached(); ws_assert_not_reached();
} }
} }
@ -630,7 +631,7 @@ print_update_dynamic(HWND dlg_hwnd, print_args_t *args) {
args->print_dissections = print_dissections_expanded; args->print_dissections = print_dissections_expanded;
break; break;
default: default:
g_assert_not_reached(); ws_assert_not_reached();
} }
EnableWindow(cur_ctrl, TRUE); EnableWindow(cur_ctrl, TRUE);
} else { } else {
@ -684,7 +685,7 @@ format_handle_wm_initdialog(HWND dlg_hwnd, print_args_t *args) {
SendMessage(cur_ctrl, CB_SETCURSEL, 2, 0); SendMessage(cur_ctrl, CB_SETCURSEL, 2, 0);
break; break;
default: default:
g_assert_not_reached(); ws_assert_not_reached();
} }
/* Set the "Packet bytes" box */ /* Set the "Packet bytes" box */
@ -1510,7 +1511,7 @@ range_update_dynamics(HWND dlg_hwnd, packet_range_t *range) {
break; break;
default: default:
g_assert_not_reached(); ws_assert_not_reached();
} }
/* RANGE_REMOVE_IGNORED_PACKETS */ /* RANGE_REMOVE_IGNORED_PACKETS */
@ -1536,7 +1537,7 @@ range_update_dynamics(HWND dlg_hwnd, packet_range_t *range) {
displayed_ignored_cnt = range->displayed_ignored_user_range_cnt; displayed_ignored_cnt = range->displayed_ignored_user_range_cnt;
break; break;
default: default:
g_assert_not_reached(); ws_assert_not_reached();
} }
cur_ctrl = GetDlgItem(dlg_hwnd, EWFD_REMOVE_IGN_CB); cur_ctrl = GetDlgItem(dlg_hwnd, EWFD_REMOVE_IGN_CB);
@ -1597,7 +1598,7 @@ range_handle_wm_initdialog(HWND dlg_hwnd, packet_range_t *range) {
cur_ctrl = GetDlgItem(dlg_hwnd, EWFD_RANGE_BTN); cur_ctrl = GetDlgItem(dlg_hwnd, EWFD_RANGE_BTN);
break; break;
default: default:
g_assert_not_reached(); ws_assert_not_reached();
} }
SendMessage(cur_ctrl, BM_SETCHECK, TRUE, 0); SendMessage(cur_ctrl, BM_SETCHECK, TRUE, 0);
} }