forked from osmocom/wireshark
Replace g_assert() with ws_assert() in places
This commit is contained in:
parent
ef0f022f86
commit
4aff36d501
|
@ -12,6 +12,7 @@
|
|||
#include "wtap-int.h"
|
||||
#include "file_wrappers.h"
|
||||
#include "capsa.h"
|
||||
#include <wsutil/ws_assert.h>
|
||||
|
||||
/*
|
||||
* A file begins with a header containing:
|
||||
|
@ -368,7 +369,7 @@ capsa_read_packet(wtap *wth, FILE_T fh, wtap_rec *rec,
|
|||
break;
|
||||
|
||||
default:
|
||||
g_assert_not_reached();
|
||||
ws_assert_not_reached();
|
||||
*err = WTAP_ERR_INTERNAL;
|
||||
*err_info = g_strdup_printf("capsa: format indicator is %u", capsa->format_indicator);
|
||||
return -1;
|
||||
|
|
|
@ -18,6 +18,7 @@
|
|||
#ifdef HAVE_PLUGINS
|
||||
#include <wsutil/plugins.h>
|
||||
#endif
|
||||
#include <wsutil/ws_assert.h>
|
||||
|
||||
#include "wtap-int.h"
|
||||
#include "wtap_modules.h"
|
||||
|
@ -461,7 +462,7 @@ static void
|
|||
set_heuristic_routine(void)
|
||||
{
|
||||
guint i;
|
||||
g_assert(open_info_arr != NULL);
|
||||
ws_assert(open_info_arr != NULL);
|
||||
|
||||
for (i = 0; i < open_info_arr->len; i++) {
|
||||
if (open_routines[i].type == OPEN_INFO_HEURISTIC) {
|
||||
|
@ -469,10 +470,10 @@ set_heuristic_routine(void)
|
|||
break;
|
||||
}
|
||||
/* sanity check */
|
||||
g_assert(open_routines[i].type == OPEN_INFO_MAGIC);
|
||||
ws_assert(open_routines[i].type == OPEN_INFO_MAGIC);
|
||||
}
|
||||
|
||||
g_assert(heuristic_open_routine_idx > 0);
|
||||
ws_assert(heuristic_open_routine_idx > 0);
|
||||
}
|
||||
|
||||
void
|
||||
|
@ -1255,7 +1256,7 @@ void
|
|||
wtap_init_file_type_subtypes(void)
|
||||
{
|
||||
/* Don't do this twice. */
|
||||
g_assert(file_type_subtype_table_arr == NULL);
|
||||
ws_assert(file_type_subtype_table_arr == NULL);
|
||||
|
||||
/*
|
||||
* Estimate the number of file types/subtypes as twice the
|
||||
|
@ -1833,7 +1834,7 @@ wtap_pcap_file_type_subtype(void)
|
|||
* Make sure pcap was registered as a file type/subtype;
|
||||
* it's one of our "native" formats.
|
||||
*/
|
||||
g_assert(pcap_file_type_subtype != -1);
|
||||
ws_assert(pcap_file_type_subtype != -1);
|
||||
return pcap_file_type_subtype;
|
||||
}
|
||||
|
||||
|
@ -1847,7 +1848,7 @@ wtap_pcap_nsec_file_type_subtype(void)
|
|||
* Make sure nanosecond-resolution pcap was registered
|
||||
* as a file type/subtype; it's one of our "native" formats.
|
||||
*/
|
||||
g_assert(pcap_nsec_file_type_subtype != -1);
|
||||
ws_assert(pcap_nsec_file_type_subtype != -1);
|
||||
return pcap_nsec_file_type_subtype;
|
||||
}
|
||||
|
||||
|
@ -1861,7 +1862,7 @@ wtap_pcapng_file_type_subtype(void)
|
|||
* Make sure pcapng was registered as a file type/subtype;
|
||||
* it's one of our "native" formats.
|
||||
*/
|
||||
g_assert(pcapng_file_type_subtype != -1);
|
||||
ws_assert(pcapng_file_type_subtype != -1);
|
||||
return pcapng_file_type_subtype;
|
||||
}
|
||||
|
||||
|
|
|
@ -21,6 +21,7 @@
|
|||
#include "wtap-int.h"
|
||||
#include "file_wrappers.h"
|
||||
#include <wsutil/file_util.h>
|
||||
#include <wsutil/ws_assert.h>
|
||||
|
||||
#ifdef HAVE_ZLIB
|
||||
#define ZLIB_CONST
|
||||
|
@ -1072,7 +1073,7 @@ file_seek(FILE_T file, gint64 offset, int whence, int *err)
|
|||
guint n;
|
||||
|
||||
if (whence != SEEK_SET && whence != SEEK_CUR && whence != SEEK_END) {
|
||||
g_assert_not_reached();
|
||||
ws_assert_not_reached();
|
||||
/*
|
||||
*err = EINVAL;
|
||||
return -1;
|
||||
|
|
|
@ -147,6 +147,7 @@ Number S/R Length Timer MAC Address MAC Address
|
|||
|
||||
#include <wsutil/str_util.h>
|
||||
#include <wsutil/strtoi.h>
|
||||
#include <wsutil/ws_assert.h>
|
||||
|
||||
#define ISERIES_LINE_LENGTH 270
|
||||
#define ISERIES_HDR_LINES_TO_CHECK 100
|
||||
|
@ -1015,7 +1016,7 @@ iseries_UNICODE_to_ASCII (guint8 * buf, guint bytes)
|
|||
if (buf[i] == 0x0A)
|
||||
break;
|
||||
}
|
||||
g_assert(bufptr < buf + bytes);
|
||||
ws_assert(bufptr < buf + bytes);
|
||||
*bufptr = '\0';
|
||||
return i;
|
||||
}
|
||||
|
|
|
@ -18,6 +18,7 @@
|
|||
#include "pcap-encap.h"
|
||||
#include "libpcap.h"
|
||||
#include "erf-common.h"
|
||||
#include <wsutil/ws_assert.h>
|
||||
|
||||
/* See source to the "libpcap" library for information on the "libpcap"
|
||||
file format. */
|
||||
|
@ -584,7 +585,7 @@ done:
|
|||
break;
|
||||
|
||||
default:
|
||||
g_assert_not_reached();
|
||||
ws_assert_not_reached();
|
||||
}
|
||||
|
||||
/*
|
||||
|
@ -969,7 +970,7 @@ static int libpcap_read_header(wtap *wth, FILE_T fh, int *err, gchar **err_info,
|
|||
break;
|
||||
|
||||
default:
|
||||
g_assert_not_reached();
|
||||
ws_assert_not_reached();
|
||||
bytes_to_read = 0;
|
||||
}
|
||||
if (!wtap_read_bytes_or_eof(fh, hdr, bytes_to_read, err, err_info))
|
||||
|
|
|
@ -31,6 +31,7 @@
|
|||
#include <wsutil/filesystem.h>
|
||||
#include "wsutil/os_version_info.h"
|
||||
#include <wsutil/wslog.h>
|
||||
#include <wsutil/ws_assert.h>
|
||||
|
||||
|
||||
|
||||
|
@ -70,7 +71,7 @@ merge_idb_merge_mode_to_string(const int mode)
|
|||
static void
|
||||
cleanup_in_file(merge_in_file_t *in_file)
|
||||
{
|
||||
g_assert(in_file != NULL);
|
||||
ws_assert(in_file != NULL);
|
||||
|
||||
wtap_close(in_file->wth);
|
||||
in_file->wth = NULL;
|
||||
|
@ -83,17 +84,17 @@ cleanup_in_file(merge_in_file_t *in_file)
|
|||
}
|
||||
|
||||
static void
|
||||
add_idb_index_map(merge_in_file_t *in_file, const guint orig_index, const guint found_index)
|
||||
add_idb_index_map(merge_in_file_t *in_file, const guint orig_index _U_, const guint found_index)
|
||||
{
|
||||
g_assert(in_file != NULL);
|
||||
g_assert(in_file->idb_index_map != NULL);
|
||||
ws_assert(in_file != NULL);
|
||||
ws_assert(in_file->idb_index_map != NULL);
|
||||
|
||||
/*
|
||||
* we didn't really need the orig_index, since just appending to the array
|
||||
* should result in the orig_index being its location in the array; but we
|
||||
* pass it into this function to do a sanity check here
|
||||
*/
|
||||
g_assert(orig_index == in_file->idb_index_map->len);
|
||||
ws_assert(orig_index == in_file->idb_index_map->len);
|
||||
|
||||
g_array_append_val(in_file->idb_index_map, found_index);
|
||||
}
|
||||
|
@ -465,7 +466,7 @@ is_duplicate_idb(const wtap_block_t idb1, const wtap_block_t idb2)
|
|||
char *idb1_if_hardware, *idb2_if_hardware;
|
||||
char *idb1_if_os, *idb2_if_os;
|
||||
|
||||
g_assert(idb1 && idb2);
|
||||
ws_assert(idb1 && idb2);
|
||||
idb1_mand = (wtapng_if_descr_mandatory_t*)wtap_block_get_mandatory_data(idb1);
|
||||
idb2_mand = (wtapng_if_descr_mandatory_t*)wtap_block_get_mandatory_data(idb2);
|
||||
|
||||
|
@ -627,18 +628,18 @@ all_idbs_are_duplicates(const merge_in_file_t *in_files, const guint in_file_cou
|
|||
wtap_block_t first_file_idb, other_file_idb;
|
||||
guint i, j;
|
||||
|
||||
g_assert(in_files != NULL);
|
||||
ws_assert(in_files != NULL);
|
||||
|
||||
/* get the first file's info */
|
||||
first_idb_list = wtap_file_get_idb_info(in_files[0].wth);
|
||||
g_assert(first_idb_list->interface_data);
|
||||
ws_assert(first_idb_list->interface_data);
|
||||
|
||||
first_idb_list_size = first_idb_list->interface_data->len;
|
||||
|
||||
/* now compare the other input files with that */
|
||||
for (i = 1; i < in_file_count; i++) {
|
||||
other_idb_list = wtap_file_get_idb_info(in_files[i].wth);
|
||||
g_assert(other_idb_list->interface_data);
|
||||
ws_assert(other_idb_list->interface_data);
|
||||
other_idb_list_size = other_idb_list->interface_data->len;
|
||||
|
||||
if (other_idb_list_size != first_idb_list_size) {
|
||||
|
@ -687,10 +688,10 @@ find_duplicate_idb(const wtap_block_t input_file_idb,
|
|||
wtap_block_t merged_idb;
|
||||
guint i;
|
||||
|
||||
g_assert(input_file_idb != NULL);
|
||||
g_assert(merged_idb_list != NULL);
|
||||
g_assert(merged_idb_list->interface_data != NULL);
|
||||
g_assert(found_index != NULL);
|
||||
ws_assert(input_file_idb != NULL);
|
||||
ws_assert(merged_idb_list != NULL);
|
||||
ws_assert(merged_idb_list->interface_data != NULL);
|
||||
ws_assert(found_index != NULL);
|
||||
|
||||
for (i = 0; i < merged_idb_list->interface_data->len; i++) {
|
||||
merged_idb = g_array_index(merged_idb_list->interface_data, wtap_block_t, i);
|
||||
|
@ -712,9 +713,9 @@ add_idb_to_merged_file(wtapng_iface_descriptions_t *merged_idb_list,
|
|||
wtap_block_t idb = wtap_block_create(WTAP_BLOCK_IF_ID_AND_INFO);
|
||||
wtapng_if_descr_mandatory_t* idb_mand;
|
||||
|
||||
g_assert(merged_idb_list != NULL);
|
||||
g_assert(merged_idb_list->interface_data != NULL);
|
||||
g_assert(input_file_idb != NULL);
|
||||
ws_assert(merged_idb_list != NULL);
|
||||
ws_assert(merged_idb_list->interface_data != NULL);
|
||||
ws_assert(input_file_idb != NULL);
|
||||
|
||||
wtap_block_copy(idb, input_file_idb);
|
||||
idb_mand = (wtapng_if_descr_mandatory_t*)wtap_block_get_mandatory_data(idb);
|
||||
|
@ -812,9 +813,9 @@ static gboolean
|
|||
map_rec_interface_id(wtap_rec *rec, const merge_in_file_t *in_file)
|
||||
{
|
||||
guint current_interface_id = 0;
|
||||
g_assert(rec != NULL);
|
||||
g_assert(in_file != NULL);
|
||||
g_assert(in_file->idb_index_map != NULL);
|
||||
ws_assert(rec != NULL);
|
||||
ws_assert(in_file != NULL);
|
||||
ws_assert(in_file->idb_index_map != NULL);
|
||||
|
||||
if (rec->presence_flags & WTAP_HAS_INTERFACE_ID) {
|
||||
current_interface_id = rec->rec_header.packet_header.interface_id;
|
||||
|
@ -1000,15 +1001,15 @@ merge_files_common(const gchar* out_filename, /* normal output mode */
|
|||
wtapng_iface_descriptions_t *idb_inf = NULL;
|
||||
GArray *dsb_combined = NULL;
|
||||
|
||||
g_assert(in_file_count > 0);
|
||||
g_assert(in_filenames != NULL);
|
||||
g_assert(err != NULL);
|
||||
g_assert(err_info != NULL);
|
||||
g_assert(err_fileno != NULL);
|
||||
g_assert(err_framenum != NULL);
|
||||
ws_assert(in_file_count > 0);
|
||||
ws_assert(in_filenames != NULL);
|
||||
ws_assert(err != NULL);
|
||||
ws_assert(err_info != NULL);
|
||||
ws_assert(err_fileno != NULL);
|
||||
ws_assert(err_framenum != NULL);
|
||||
|
||||
/* if a callback was given, it has to have a callback function ptr */
|
||||
g_assert((cb != NULL) ? (cb->callback_func != NULL) : TRUE);
|
||||
ws_assert((cb != NULL) ? (cb->callback_func != NULL) : TRUE);
|
||||
|
||||
ws_debug("merge_files: begin");
|
||||
|
||||
|
@ -1116,7 +1117,7 @@ merge_files(const gchar* out_filename, const int file_type,
|
|||
int *err, gchar **err_info, guint *err_fileno,
|
||||
guint32 *err_framenum)
|
||||
{
|
||||
g_assert(out_filename != NULL);
|
||||
ws_assert(out_filename != NULL);
|
||||
|
||||
return merge_files_common(out_filename, NULL, NULL,
|
||||
file_type, in_filenames, in_file_count,
|
||||
|
@ -1138,7 +1139,7 @@ merge_files_to_tempfile(gchar **out_filenamep, const char *pfx,
|
|||
int *err, gchar **err_info, guint *err_fileno,
|
||||
guint32 *err_framenum)
|
||||
{
|
||||
g_assert(out_filenamep != NULL);
|
||||
ws_assert(out_filenamep != NULL);
|
||||
|
||||
/* no temporary file name yet */
|
||||
*out_filenamep = NULL;
|
||||
|
|
|
@ -12,6 +12,7 @@
|
|||
#include "wtap-int.h"
|
||||
#include "file_wrappers.h"
|
||||
#include "netscaler.h"
|
||||
#include <wsutil/ws_assert.h>
|
||||
|
||||
/* Defines imported from netscaler code: nsperfrc.h */
|
||||
|
||||
|
@ -2188,7 +2189,7 @@ static gboolean nstrace_add_signature(wtap_dumper *wdh, int *err)
|
|||
nstrace->page_offset += (guint16) sig35.sig_RecordSize;
|
||||
} else
|
||||
{
|
||||
g_assert_not_reached();
|
||||
ws_assert_not_reached();
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
|
@ -2256,7 +2257,7 @@ nstrace_add_abstime(wtap_dumper *wdh, const wtap_rec *rec,
|
|||
|
||||
} else
|
||||
{
|
||||
g_assert_not_reached();
|
||||
ws_assert_not_reached();
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
|
@ -2299,7 +2300,7 @@ static gboolean nstrace_dump(wtap_dumper *wdh, const wtap_rec *rec,
|
|||
return FALSE;
|
||||
} else
|
||||
{
|
||||
g_assert_not_reached();
|
||||
ws_assert_not_reached();
|
||||
return FALSE;
|
||||
}
|
||||
}
|
||||
|
@ -2403,13 +2404,13 @@ static gboolean nstrace_dump(wtap_dumper *wdh, const wtap_rec *rec,
|
|||
nstrace->page_offset += (guint16) rec->rec_header.packet_header.caplen;
|
||||
} else
|
||||
{
|
||||
g_assert_not_reached();
|
||||
ws_assert_not_reached();
|
||||
return FALSE;
|
||||
}
|
||||
break;
|
||||
|
||||
default:
|
||||
g_assert_not_reached();
|
||||
ws_assert_not_reached();
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
|
|
|
@ -30,6 +30,7 @@
|
|||
#include "wsutil/os_version_info.h"
|
||||
#include "wsutil/str_util.h"
|
||||
#include <wsutil/inet_addr.h>
|
||||
#include <wsutil/ws_assert.h>
|
||||
|
||||
|
||||
#include "nettrace_3gpp_32_423.h"
|
||||
|
@ -449,7 +450,7 @@ nettrace_msg_to_packet(nettrace_3gpp_32_423_file_info_t *file_info, wtap_rec *re
|
|||
|
||||
if (exported_pdu_info.presence_flags & EXP_PDU_TAG_COL_PROT_BIT) {
|
||||
/* The assert prevents static code analyzers to raise warnings */
|
||||
g_assert(exported_pdu_info.proto_col_str);
|
||||
ws_assert(exported_pdu_info.proto_col_str);
|
||||
exp_pdu_tags_len += 4 + (int)strlen(exported_pdu_info.proto_col_str);
|
||||
}
|
||||
|
||||
|
|
|
@ -47,6 +47,7 @@
|
|||
#include "wtap-int.h"
|
||||
#include "file_wrappers.h"
|
||||
#include "ngsniffer.h"
|
||||
#include <wsutil/ws_assert.h>
|
||||
|
||||
/* Magic number in Sniffer files. */
|
||||
static const char ngsniffer_magic[] = {
|
||||
|
@ -1115,7 +1116,7 @@ ngsniffer_seek_read(wtap *wth, gint64 seek_off,
|
|||
/*
|
||||
* "Can't happen".
|
||||
*/
|
||||
g_assert_not_reached();
|
||||
ws_assert_not_reached();
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
|
@ -2500,7 +2501,7 @@ ng_read_bytes_or_eof(wtap *wth, void *buffer, unsigned int nbytes, gboolean is_r
|
|||
random stream open, allocate the first element for the
|
||||
list of blobs, and make it the last element as well. */
|
||||
if (wth->random_fh != NULL) {
|
||||
g_assert(ngsniffer->first_blob == NULL);
|
||||
ws_assert(ngsniffer->first_blob == NULL);
|
||||
blob = g_new(blob_info_t,1);
|
||||
blob->blob_comp_offset = comp_stream->comp_offset;
|
||||
blob->blob_uncomp_offset = comp_stream->uncomp_offset;
|
||||
|
@ -2829,7 +2830,7 @@ ng_file_seek_rand(wtap *wth, gint64 offset, int *err, gchar **err_info)
|
|||
the blob, as otherwise it'd mean we need to seek before
|
||||
the beginning or after the end of this blob. */
|
||||
delta = offset - ngsniffer->rand.uncomp_offset;
|
||||
g_assert(delta >= 0 && (unsigned long)delta < ngsniffer->rand.nbytes);
|
||||
ws_assert(delta >= 0 && (unsigned long)delta < ngsniffer->rand.nbytes);
|
||||
}
|
||||
|
||||
/* OK, the place to which we're seeking is in the buffer; adjust
|
||||
|
|
|
@ -26,6 +26,7 @@
|
|||
#include <wsutil/wslog.h>
|
||||
#include <wsutil/strtoi.h>
|
||||
#include <wsutil/glib-compat.h>
|
||||
#include <wsutil/ws_assert.h>
|
||||
|
||||
#include "wtap-int.h"
|
||||
#include "file_wrappers.h"
|
||||
|
@ -412,7 +413,7 @@ static GHashTable *option_handlers[NUM_BT_INDICES];
|
|||
static gboolean
|
||||
get_block_type_index(guint block_type, guint *bt_index)
|
||||
{
|
||||
g_assert(bt_index);
|
||||
ws_assert(bt_index);
|
||||
|
||||
switch (block_type) {
|
||||
|
||||
|
@ -3258,7 +3259,7 @@ pcapng_seek_read(wtap *wth, gint64 seek_off,
|
|||
* First, make sure we have at least one section; if we don't, that's
|
||||
* an internal error.
|
||||
*/
|
||||
g_assert(pcapng->sections->len >= 1);
|
||||
ws_assert(pcapng->sections->len >= 1);
|
||||
|
||||
/*
|
||||
* Now scan backwards through the array to find the first section
|
||||
|
@ -3278,7 +3279,7 @@ pcapng_seek_read(wtap *wth, gint64 seek_off,
|
|||
* If that's section 0, something's wrong; that section should
|
||||
* have an offset of 0.
|
||||
*/
|
||||
g_assert(section_number != 0);
|
||||
ws_assert(section_number != 0);
|
||||
section_number--;
|
||||
}
|
||||
|
||||
|
@ -4844,7 +4845,7 @@ static void write_wtap_idb_option(wtap_block_t block _U_, guint option_id, wtap_
|
|||
break;
|
||||
|
||||
default:
|
||||
g_assert_not_reached();
|
||||
ws_assert_not_reached();
|
||||
return;
|
||||
}
|
||||
|
||||
|
|
|
@ -27,6 +27,7 @@
|
|||
|
||||
#include <wsutil/epochs.h>
|
||||
#include <wsutil/802_11-utils.h>
|
||||
#include <wsutil/ws_assert.h>
|
||||
|
||||
#include "wtap-int.h"
|
||||
#include "file_wrappers.h"
|
||||
|
@ -172,7 +173,7 @@ wtap_open_return_val peekclassic_open(wtap *wth, int *err, gchar **err_info)
|
|||
* is zero, and check some other fields; this isn't perfect,
|
||||
* and we may have to add more checks at some point.
|
||||
*/
|
||||
g_assert(sizeof(ep_hdr.master) == PEEKCLASSIC_MASTER_HDR_SIZE);
|
||||
ws_assert(sizeof(ep_hdr.master) == PEEKCLASSIC_MASTER_HDR_SIZE);
|
||||
if (!wtap_read_bytes(wth->fh, &ep_hdr.master,
|
||||
(int)sizeof(ep_hdr.master), err, err_info)) {
|
||||
if (*err != WTAP_ERR_SHORT_READ)
|
||||
|
@ -201,7 +202,7 @@ wtap_open_return_val peekclassic_open(wtap *wth, int *err, gchar **err_info)
|
|||
case 6:
|
||||
case 7:
|
||||
/* get the secondary header */
|
||||
g_assert(sizeof(ep_hdr.secondary.v567) ==
|
||||
ws_assert(sizeof(ep_hdr.secondary.v567) ==
|
||||
PEEKCLASSIC_V567_HDR_SIZE);
|
||||
if (!wtap_read_bytes(wth->fh, &ep_hdr.secondary.v567,
|
||||
(int)sizeof(ep_hdr.secondary.v567), err, err_info)) {
|
||||
|
@ -343,7 +344,7 @@ wtap_open_return_val peekclassic_open(wtap *wth, int *err, gchar **err_info)
|
|||
|
||||
default:
|
||||
/* this is impossible */
|
||||
g_assert_not_reached();
|
||||
ws_assert_not_reached();
|
||||
}
|
||||
|
||||
wth->snapshot_length = 0; /* not available in header */
|
||||
|
|
|
@ -14,6 +14,8 @@
|
|||
#include <errno.h>
|
||||
#include <string.h>
|
||||
|
||||
#include <wsutil/ws_assert.h>
|
||||
|
||||
/*
|
||||
pppdump records
|
||||
Daniel Thompson (STMicroelectronics) <daniel.thompson@st.com>
|
||||
|
@ -457,7 +459,7 @@ process_data(pppdump_t *state, FILE_T fh, pkt_t *pkt, int n, guint8 *pd,
|
|||
pid->offset = pkt->id_offset;
|
||||
pid->num_bytes_to_skip =
|
||||
pkt->sd_offset - pkt->id_offset - 3;
|
||||
g_assert(pid->num_bytes_to_skip >= 0);
|
||||
ws_assert(pid->num_bytes_to_skip >= 0);
|
||||
}
|
||||
|
||||
num_bytes--;
|
||||
|
@ -557,7 +559,7 @@ collate(pppdump_t* state, FILE_T fh, int *err, gchar **err_info, guint8 *pd,
|
|||
* sequential processing.
|
||||
*/
|
||||
if (state->num_bytes > 0) {
|
||||
g_assert(num_bytes_to_skip == 0);
|
||||
ws_assert(num_bytes_to_skip == 0);
|
||||
pkt = state->pkt;
|
||||
num_written = process_data(state, fh, pkt, state->num_bytes,
|
||||
pd, err, err_info, pid);
|
||||
|
@ -631,7 +633,7 @@ collate(pppdump_t* state, FILE_T fh, int *err, gchar **err_info, guint8 *pd,
|
|||
if (n == 0)
|
||||
continue;
|
||||
|
||||
g_assert(num_bytes_to_skip < n);
|
||||
ws_assert(num_bytes_to_skip < n);
|
||||
while (num_bytes_to_skip) {
|
||||
if (file_getc(fh) == EOF)
|
||||
goto done;
|
||||
|
|
|
@ -16,6 +16,7 @@
|
|||
#include "file_wrappers.h"
|
||||
|
||||
#include "vwr.h"
|
||||
#include <wsutil/ws_assert.h>
|
||||
|
||||
/* platform-specific definitions for portability */
|
||||
|
||||
|
@ -3362,7 +3363,7 @@ vwr_process_rec_data(FILE_T fh, int rec_size,
|
|||
break;
|
||||
default:
|
||||
g_free(rec);
|
||||
g_assert_not_reached();
|
||||
ws_assert_not_reached();
|
||||
return ret;
|
||||
}
|
||||
|
||||
|
|
|
@ -19,6 +19,7 @@
|
|||
#include "file_wrappers.h"
|
||||
#include <wsutil/file_util.h>
|
||||
#include <wsutil/buffer.h>
|
||||
#include <wsutil/ws_assert.h>
|
||||
#ifdef HAVE_PLUGINS
|
||||
#include <wsutil/plugins.h>
|
||||
#endif
|
||||
|
@ -209,9 +210,9 @@ wtap_add_generated_idb(wtap *wth)
|
|||
wtapng_if_descr_mandatory_t *if_descr_mand;
|
||||
int snaplen;
|
||||
|
||||
g_assert(wth->file_encap != WTAP_ENCAP_UNKNOWN &&
|
||||
ws_assert(wth->file_encap != WTAP_ENCAP_UNKNOWN &&
|
||||
wth->file_encap != WTAP_ENCAP_PER_PACKET);
|
||||
g_assert(wth->file_tsprec != WTAP_TSPREC_UNKNOWN &&
|
||||
ws_assert(wth->file_tsprec != WTAP_TSPREC_UNKNOWN &&
|
||||
wth->file_tsprec != WTAP_TSPREC_PER_PACKET);
|
||||
|
||||
idb = wtap_block_create(WTAP_BLOCK_IF_ID_AND_INFO);
|
||||
|
@ -257,7 +258,7 @@ wtap_add_generated_idb(wtap *wth)
|
|||
/*
|
||||
* Don't do this.
|
||||
*/
|
||||
g_assert_not_reached();
|
||||
ws_assert_not_reached();
|
||||
break;
|
||||
}
|
||||
snaplen = wth->snapshot_length;
|
||||
|
@ -316,7 +317,7 @@ wtap_get_debug_if_descr(const wtap_block_t if_descr,
|
|||
guint8 tmp8;
|
||||
if_filter_opt_t if_filter;
|
||||
|
||||
g_assert(if_descr);
|
||||
ws_assert(if_descr);
|
||||
|
||||
if_descr_mand = (wtapng_if_descr_mandatory_t*)wtap_block_get_mandatory_data(if_descr);
|
||||
if (wtap_block_get_string_option_value(if_descr, OPT_IDB_NAME, &tmp_content) == WTAP_OPTTYPE_SUCCESS) {
|
||||
|
@ -1557,7 +1558,7 @@ wtap_read(wtap *wth, wtap_rec *rec, Buffer *buf, int *err,
|
|||
* but the read routine didn't set this packet's
|
||||
* encapsulation type.
|
||||
*/
|
||||
g_assert(rec->rec_header.packet_header.pkt_encap != WTAP_ENCAP_PER_PACKET);
|
||||
ws_assert(rec->rec_header.packet_header.pkt_encap != WTAP_ENCAP_PER_PACKET);
|
||||
}
|
||||
|
||||
return TRUE; /* success */
|
||||
|
@ -1702,7 +1703,7 @@ wtap_seek_read(wtap *wth, gint64 seek_off, wtap_rec *rec, Buffer *buf,
|
|||
* but the read routine didn't set this packet's
|
||||
* encapsulation type.
|
||||
*/
|
||||
g_assert(rec->rec_header.packet_header.pkt_encap != WTAP_ENCAP_PER_PACKET);
|
||||
ws_assert(rec->rec_header.packet_header.pkt_encap != WTAP_ENCAP_PER_PACKET);
|
||||
}
|
||||
|
||||
return TRUE;
|
||||
|
|
|
@ -15,6 +15,7 @@
|
|||
#include "wtap_opttypes.h"
|
||||
#include "wtap-int.h"
|
||||
#include "pcapng_module.h"
|
||||
#include <wsutil/ws_assert.h>
|
||||
|
||||
#include <wsutil/glib-compat.h>
|
||||
|
||||
|
@ -120,15 +121,15 @@ static void wtap_opttype_block_register(wtap_blocktype_t *blocktype)
|
|||
block_type = blocktype->block_type;
|
||||
|
||||
/* Check input */
|
||||
g_assert(block_type < MAX_WTAP_BLOCK_TYPE_VALUE);
|
||||
ws_assert(block_type < MAX_WTAP_BLOCK_TYPE_VALUE);
|
||||
|
||||
/* Don't re-register. */
|
||||
g_assert(blocktype_list[block_type] == NULL);
|
||||
ws_assert(blocktype_list[block_type] == NULL);
|
||||
|
||||
/* Sanity check */
|
||||
g_assert(blocktype->name);
|
||||
g_assert(blocktype->description);
|
||||
g_assert(blocktype->create);
|
||||
ws_assert(blocktype->name);
|
||||
ws_assert(blocktype->description);
|
||||
ws_assert(blocktype->create);
|
||||
|
||||
/*
|
||||
* Initialize the set of supported options.
|
||||
|
|
|
@ -11,6 +11,7 @@
|
|||
#include <string.h>
|
||||
|
||||
#include "buffer.h"
|
||||
#include <wsutil/ws_assert.h>
|
||||
|
||||
#define SMALL_BUFFER_SIZE (2 * 1024) /* Everyone still uses 1500 byte frames, right? */
|
||||
static GPtrArray *small_buffers = NULL; /* Guaranteed to be at least SMALL_BUFFER_SIZE */
|
||||
|
@ -20,13 +21,13 @@ static GPtrArray *small_buffers = NULL; /* Guaranteed to be at least SMALL_BUFFE
|
|||
void
|
||||
ws_buffer_init(Buffer* buffer, gsize space)
|
||||
{
|
||||
g_assert(buffer);
|
||||
ws_assert(buffer);
|
||||
if (G_UNLIKELY(!small_buffers)) small_buffers = g_ptr_array_sized_new(1024);
|
||||
|
||||
if (space <= SMALL_BUFFER_SIZE) {
|
||||
if (small_buffers->len > 0) {
|
||||
buffer->data = (guint8*) g_ptr_array_remove_index(small_buffers, small_buffers->len - 1);
|
||||
g_assert(buffer->data);
|
||||
ws_assert(buffer->data);
|
||||
} else {
|
||||
buffer->data = (guint8*)g_malloc(SMALL_BUFFER_SIZE);
|
||||
}
|
||||
|
@ -43,9 +44,9 @@ ws_buffer_init(Buffer* buffer, gsize space)
|
|||
void
|
||||
ws_buffer_free(Buffer* buffer)
|
||||
{
|
||||
g_assert(buffer);
|
||||
ws_assert(buffer);
|
||||
if (buffer->allocated == SMALL_BUFFER_SIZE) {
|
||||
g_assert(buffer->data);
|
||||
ws_assert(buffer->data);
|
||||
g_ptr_array_add(small_buffers, buffer->data);
|
||||
} else {
|
||||
g_free(buffer->data);
|
||||
|
@ -61,7 +62,7 @@ ws_buffer_free(Buffer* buffer)
|
|||
void
|
||||
ws_buffer_assure_space(Buffer* buffer, gsize space)
|
||||
{
|
||||
g_assert(buffer);
|
||||
ws_assert(buffer);
|
||||
gsize available_at_end = buffer->allocated - buffer->first_free;
|
||||
gsize space_used;
|
||||
gboolean space_at_beginning;
|
||||
|
@ -100,7 +101,7 @@ ws_buffer_assure_space(Buffer* buffer, gsize space)
|
|||
void
|
||||
ws_buffer_append(Buffer* buffer, guint8 *from, gsize bytes)
|
||||
{
|
||||
g_assert(buffer);
|
||||
ws_assert(buffer);
|
||||
ws_buffer_assure_space(buffer, bytes);
|
||||
memcpy(buffer->data + buffer->first_free, from, bytes);
|
||||
buffer->first_free += bytes;
|
||||
|
@ -109,7 +110,7 @@ ws_buffer_append(Buffer* buffer, guint8 *from, gsize bytes)
|
|||
void
|
||||
ws_buffer_remove_start(Buffer* buffer, gsize bytes)
|
||||
{
|
||||
g_assert(buffer);
|
||||
ws_assert(buffer);
|
||||
if (buffer->start + bytes > buffer->first_free) {
|
||||
g_error("ws_buffer_remove_start trying to remove %" G_GINT64_MODIFIER "u bytes. s=%" G_GINT64_MODIFIER "u ff=%" G_GINT64_MODIFIER "u!\n",
|
||||
(guint64)bytes, (guint64)buffer->start,
|
||||
|
@ -129,7 +130,7 @@ ws_buffer_remove_start(Buffer* buffer, gsize bytes)
|
|||
void
|
||||
ws_buffer_clean(Buffer* buffer)
|
||||
{
|
||||
g_assert(buffer);
|
||||
ws_assert(buffer);
|
||||
ws_buffer_remove_start(buffer, ws_buffer_length(buffer));
|
||||
}
|
||||
#endif
|
||||
|
@ -138,7 +139,7 @@ ws_buffer_clean(Buffer* buffer)
|
|||
void
|
||||
ws_buffer_increase_length(Buffer* buffer, gsize bytes)
|
||||
{
|
||||
g_assert(buffer);
|
||||
ws_assert(buffer);
|
||||
buffer->first_free += bytes;
|
||||
}
|
||||
#endif
|
||||
|
@ -147,7 +148,7 @@ ws_buffer_increase_length(Buffer* buffer, gsize bytes)
|
|||
gsize
|
||||
ws_buffer_length(Buffer* buffer)
|
||||
{
|
||||
g_assert(buffer);
|
||||
ws_assert(buffer);
|
||||
return buffer->first_free - buffer->start;
|
||||
}
|
||||
#endif
|
||||
|
@ -156,7 +157,7 @@ ws_buffer_length(Buffer* buffer)
|
|||
guint8 *
|
||||
ws_buffer_start_ptr(Buffer* buffer)
|
||||
{
|
||||
g_assert(buffer);
|
||||
ws_assert(buffer);
|
||||
return buffer->data + buffer->start;
|
||||
}
|
||||
#endif
|
||||
|
@ -165,7 +166,7 @@ ws_buffer_start_ptr(Buffer* buffer)
|
|||
guint8 *
|
||||
ws_buffer_end_ptr(Buffer* buffer)
|
||||
{
|
||||
g_assert(buffer);
|
||||
ws_assert(buffer);
|
||||
return buffer->data + buffer->first_free;
|
||||
}
|
||||
#endif
|
||||
|
@ -174,7 +175,7 @@ ws_buffer_end_ptr(Buffer* buffer)
|
|||
void
|
||||
ws_buffer_append_buffer(Buffer* buffer, Buffer* src_buffer)
|
||||
{
|
||||
g_assert(buffer);
|
||||
ws_assert(buffer);
|
||||
ws_buffer_append(buffer, ws_buffer_start_ptr(src_buffer), ws_buffer_length(src_buffer));
|
||||
}
|
||||
#endif
|
||||
|
|
|
@ -44,6 +44,7 @@
|
|||
#include <wsutil/privileges.h>
|
||||
#include <wsutil/file_util.h>
|
||||
#include <wsutil/utf8_entities.h>
|
||||
#include <wsutil/ws_assert.h>
|
||||
|
||||
#include <wiretap/wtap.h> /* for WTAP_ERR_SHORT_WRITE */
|
||||
|
||||
|
@ -104,7 +105,7 @@ get_basename(const char *path)
|
|||
{
|
||||
const char *filename;
|
||||
|
||||
g_assert(path != NULL);
|
||||
ws_assert(path != NULL);
|
||||
filename = find_last_pathname_separator(path);
|
||||
if (filename == NULL) {
|
||||
/*
|
||||
|
@ -131,7 +132,7 @@ get_dirname(char *path)
|
|||
{
|
||||
char *separator;
|
||||
|
||||
g_assert(path != NULL);
|
||||
ws_assert(path != NULL);
|
||||
separator = find_last_pathname_separator(path);
|
||||
if (separator == NULL) {
|
||||
/*
|
||||
|
|
|
@ -34,6 +34,8 @@
|
|||
#define _NTOP_SRC_CAST_
|
||||
#endif
|
||||
|
||||
#include <wsutil/ws_assert.h>
|
||||
|
||||
/*
|
||||
* We assume and require an inet_pton/inet_ntop that supports AF_INET
|
||||
* and AF_INET6.
|
||||
|
@ -54,7 +56,7 @@ _inet_pton(int af, const gchar *src, gpointer dst)
|
|||
g_critical("ws_inet_pton6: EAFNOSUPPORT");
|
||||
}
|
||||
else {
|
||||
g_assert_not_reached();
|
||||
ws_assert_not_reached();
|
||||
}
|
||||
errno = EAFNOSUPPORT;
|
||||
}
|
||||
|
|
|
@ -26,6 +26,7 @@
|
|||
#include <wsutil/report_message.h>
|
||||
|
||||
#include <wsutil/plugins.h>
|
||||
#include <wsutil/ws_assert.h>
|
||||
|
||||
typedef struct _plugin {
|
||||
GModule *handle; /* handle returned by g_module_open */
|
||||
|
@ -60,7 +61,7 @@ type_to_dir(plugin_type_e type)
|
|||
g_error("Unknown plugin type: %u. Aborting.", (unsigned) type);
|
||||
break;
|
||||
}
|
||||
g_assert_not_reached();
|
||||
ws_assert_not_reached();
|
||||
}
|
||||
|
||||
static inline const char *
|
||||
|
@ -77,7 +78,7 @@ type_to_name(plugin_type_e type)
|
|||
g_error("Unknown plugin type: %u. Aborting.", (unsigned) type);
|
||||
break;
|
||||
}
|
||||
g_assert_not_reached();
|
||||
ws_assert_not_reached();
|
||||
}
|
||||
|
||||
static void
|
||||
|
|
|
@ -17,6 +17,7 @@
|
|||
#include <glib.h>
|
||||
|
||||
#include "privileges.h"
|
||||
#include <wsutil/ws_assert.h>
|
||||
|
||||
#ifdef _WIN32
|
||||
#include <windows.h>
|
||||
|
@ -148,7 +149,7 @@ init_process_policies(void)
|
|||
gboolean
|
||||
started_with_special_privs(void)
|
||||
{
|
||||
g_assert(init_process_policies_called);
|
||||
ws_assert(init_process_policies_called);
|
||||
#ifdef HAVE_ISSETUGID
|
||||
return issetugid();
|
||||
#else
|
||||
|
|
|
@ -12,13 +12,14 @@
|
|||
#define __WSUTIL_SIGN_EXT_H__
|
||||
|
||||
#include <glib.h>
|
||||
#include <wsutil/ws_assert.h>
|
||||
|
||||
/* sign extension routines */
|
||||
|
||||
static inline guint32
|
||||
ws_sign_ext32(guint32 val, int no_of_bits)
|
||||
{
|
||||
g_assert (no_of_bits >= 0 && no_of_bits <= 32);
|
||||
ws_assert (no_of_bits >= 0 && no_of_bits <= 32);
|
||||
|
||||
if ((no_of_bits == 0) || (no_of_bits == 32))
|
||||
return val;
|
||||
|
@ -38,7 +39,7 @@ ws_sign_ext32(guint32 val, int no_of_bits)
|
|||
static inline guint64
|
||||
ws_sign_ext64(guint64 val, int no_of_bits)
|
||||
{
|
||||
g_assert (no_of_bits >= 0 && no_of_bits <= 64);
|
||||
ws_assert (no_of_bits >= 0 && no_of_bits <= 64);
|
||||
|
||||
if ((no_of_bits == 0) || (no_of_bits == 64))
|
||||
return val;
|
||||
|
|
|
@ -19,6 +19,7 @@
|
|||
|
||||
#include <wsutil/socket.h>
|
||||
#include <wsutil/inet_addr.h>
|
||||
#include <wsutil/ws_assert.h>
|
||||
|
||||
#ifdef _WIN32
|
||||
#include <wsutil/win32-utils.h>
|
||||
|
@ -143,7 +144,7 @@ ws_socket_ptoa(struct sockaddr_storage *dst, const gchar *src,
|
|||
ret = 0;
|
||||
}
|
||||
else {
|
||||
g_assert_not_reached();
|
||||
ws_assert_not_reached();
|
||||
}
|
||||
|
||||
out:
|
||||
|
|
|
@ -11,6 +11,7 @@
|
|||
#include <config.h>
|
||||
|
||||
#include "str_util.h"
|
||||
#include <wsutil/ws_assert.h>
|
||||
|
||||
int
|
||||
ws_xton(char ch)
|
||||
|
@ -205,7 +206,7 @@ format_size(gint64 size, format_size_flags_e flags)
|
|||
g_string_append(human_str, "packets/s");
|
||||
break;
|
||||
default:
|
||||
g_assert_not_reached();
|
||||
ws_assert_not_reached();
|
||||
}
|
||||
|
||||
ret_val = g_string_free(human_str, FALSE);
|
||||
|
|
|
@ -14,13 +14,14 @@
|
|||
|
||||
#include "strtoi.h"
|
||||
#include <errno.h>
|
||||
#include <wsutil/ws_assert.h>
|
||||
|
||||
gboolean ws_strtoi64(const gchar* str, const gchar** endptr, gint64* cint)
|
||||
{
|
||||
gchar* end;
|
||||
gint64 val;
|
||||
|
||||
g_assert(cint);
|
||||
ws_assert(cint);
|
||||
|
||||
if (!str) {
|
||||
errno = EINVAL;
|
||||
|
@ -151,7 +152,7 @@ gboolean ws_basestrtou64(const gchar* str, const gchar** endptr, guint64* cint,
|
|||
gchar* end;
|
||||
guint64 val;
|
||||
|
||||
g_assert(cint);
|
||||
ws_assert(cint);
|
||||
|
||||
if (!str) {
|
||||
errno = EINVAL;
|
||||
|
|
Loading…
Reference in New Issue