Try to discourage the use of APIs via counting.

Add the ability to specify maximum function counts for each group to
checkAPIs. Add maximum counts for the "termoutput" and "abort" groups
where needed. Show summaries in various checkAPI targets.

Switch uses of ws_g_warning back to plain g_warning.

Change-Id: I5cbddc8c671729e424eed8551f69116d16491976
Reviewed-on: https://code.wireshark.org/review/29721
Petri-Dish: Peter Wu <peter@lekensteyn.nl>
Tested-by: Petri Dish Buildbot
Reviewed-by: Peter Wu <peter@lekensteyn.nl>
This commit is contained in:
Gerald Combs 2018-09-18 10:09:31 -07:00 committed by Peter Wu
parent ca8304249e
commit 8f08a4e74e
37 changed files with 190 additions and 181 deletions

View File

@ -437,7 +437,7 @@ CHECKAPI(
NAME
epan
SWITCHES
-g termoutput -build
--group termoutput:10 --summary-group termoutput --build
SOURCES
${LIBWIRESHARK_NONGENERATED_FILES}
)

View File

@ -21,7 +21,6 @@
#include <wsutil/filesystem.h>
#include <wsutil/file_util.h>
#include <wsutil/ws_printf.h> /* ws_g_warning */
#include <epan/packet.h>
#include "color_filters.h"
@ -628,7 +627,7 @@ read_filters_file(const gchar *path, FILE *f, gpointer user_data, color_filter_a
gchar *local_err_msg = NULL;
if (!disabled && !dfilter_compile(filter_exp, &temp_dfilter, &local_err_msg)) {
ws_g_warning("Could not compile \"%s\" in colorfilters file \"%s\".\n%s",
g_warning("Could not compile \"%s\" in colorfilters file \"%s\".\n%s",
name, path, local_err_msg);
g_free(local_err_msg);
prefs.unknown_colorfilters = TRUE;

View File

@ -23,7 +23,6 @@
#include "disabled_protos.h"
#include <wsutil/file_util.h>
#include <wsutil/ws_printf.h> /* ws_g_warning */
#include <wsutil/report_message.h>
#define ENABLED_PROTOCOLS_FILE_NAME "enabled_protos"
@ -321,7 +320,7 @@ read_protos_list_file(const char *ff_path, FILE *ff, GList **flp)
if (c != EOF && c != '\n' && c != '#') {
/* Non-white-space after the protocol name; warn about it,
in case we come up with a reason to use it. */
ws_g_warning("'%s' line %d has extra stuff after the protocol name.",
g_warning("'%s' line %d has extra stuff after the protocol name.",
ff_path, line);
}
}
@ -336,7 +335,7 @@ read_protos_list_file(const char *ff_path, FILE *ff, GList **flp)
goto error; /* I/O error */
else {
/* EOF, not error; no newline seen before EOF */
ws_g_warning("'%s' line %d doesn't have a newline.", ff_path,
g_warning("'%s' line %d doesn't have a newline.", ff_path,
line);
}
break; /* nothing more to read */
@ -642,7 +641,7 @@ read_heur_dissector_list_file(const char *ff_path, FILE *ff, GList **flp)
if (c != EOF && c != '\n' && c != '#') {
/* Non-white-space after the protocol name; warn about it,
in case we come up with a reason to use it. */
ws_g_warning("'%s' line %d has extra stuff after the protocol name.",
g_warning("'%s' line %d has extra stuff after the protocol name.",
ff_path, line);
}
}
@ -657,7 +656,7 @@ read_heur_dissector_list_file(const char *ff_path, FILE *ff, GList **flp)
goto error; /* I/O error */
else {
/* EOF, not error; no newline seen before EOF */
ws_g_warning("'%s' line %d doesn't have a newline.", ff_path,
g_warning("'%s' line %d doesn't have a newline.", ff_path,
line);
}
break; /* nothing more to read */

View File

@ -1971,7 +1971,9 @@ CHECKAPI(
NAME
dissectors
SWITCHES
-g abort -g termoutput -build --file ${CHECKAPI_FILE_LIST}
--group abort
--group termoutput:5 --summary-group termoutput
--build --file ${CHECKAPI_FILE_LIST}
SOURCES
${DISSECTOR_SUPPORT_SRC}
${DISSECTOR_HEADERS}

View File

@ -22,8 +22,6 @@
#include <epan/proto_data.h>
#include <epan/uat.h>
#include <wsutil/ws_printf.h> /* ws_g_warning */
#include "packet-per.h"
#include "packet-isup.h"
#include "packet-umts_fp.h"
@ -48,7 +46,7 @@
#define DEBUG_NBAP 0
#if DEBUG_NBAP
#include <epan/to_str.h>
#define nbap_debug(...) ws_g_warning(__VA_ARGS__)
#define nbap_debug(...) g_warning(__VA_ARGS__)
#else
#define nbap_debug(...)
#endif

View File

@ -16,7 +16,6 @@
#include <epan/packet.h>
#include <epan/prefs.h>
#include <wsutil/ws_printf.h> /* ws_g_warning */
#include <wsutil/wsgcrypt.h>
#include <epan/expert.h>
#include <stdio.h>
@ -787,7 +786,7 @@ dissect_btmesh_msg(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree, void *da
cry_error = gcry_cipher_setkey(cipher_hd, record->encryptionkey, 16);
if (cry_error) {
ws_g_warning("gcry_cipher_setkey failed\n");
g_warning("gcry_cipher_setkey failed\n");
gcry_cipher_close(cipher_hd);
return offset;
}
@ -795,7 +794,7 @@ dissect_btmesh_msg(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree, void *da
/* Load nonce */
cry_error = gcry_cipher_setiv(cipher_hd, &networknonce, 13);
if (cry_error) {
ws_g_warning("gcry_cipher_setiv failed\n");
g_warning("gcry_cipher_setiv failed\n");
gcry_cipher_close(cipher_hd);
return offset;
}
@ -807,7 +806,7 @@ dissect_btmesh_msg(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree, void *da
cry_error = gcry_cipher_ctl(cipher_hd, GCRYCTL_SET_CCM_LENGTHS, ccm_lengths, sizeof(ccm_lengths));
if (cry_error) {
ws_g_warning("gcry_cipher_ctl failed %s enc_data_len %u\n",
g_warning("gcry_cipher_ctl failed %s enc_data_len %u\n",
gcry_strerror(cry_error),
enc_data_len);
gcry_cipher_close(cipher_hd);
@ -819,7 +818,7 @@ dissect_btmesh_msg(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree, void *da
cry_error = gcry_cipher_decrypt(cipher_hd, decrypted_data, enc_data_len, tvb_get_ptr(tvb, enc_offset, enc_data_len), enc_data_len);
if (cry_error) {
expert_add_info(pinfo, item, &ei_btmesh_decrypt_failed);
ws_g_warning("gcry_cipher_decrypt failed %s\n", gcry_strerror(cry_error));
g_warning("gcry_cipher_decrypt failed %s\n", gcry_strerror(cry_error));
gcry_cipher_close(cipher_hd);
return offset;
}

View File

@ -21,7 +21,6 @@
#include "packet-dcerpc.h"
#include "packet-dcerpc-nt.h"
#include "packet-windows-common.h"
#include <wsutil/ws_printf.h> /* ws_g_warning */
int hf_nt_cs_len = -1;
@ -778,7 +777,7 @@ void dcerpc_store_polhnd_name(e_ctx_hnd *policy_hnd, packet_info *pinfo,
if (pol->name && name) {
#ifdef DEBUG_HASH_COLL
if (strcmp(pol->name, name) != 0)
ws_g_warning("dcerpc_smb: pol_hash name collision %s/%s\n", value->name, name);
g_warning("dcerpc_smb: pol_hash name collision %s/%s\n", value->name, name);
#endif
/* pol->name is wmem_file_scope() allocated, don't free it now */
}

View File

@ -229,7 +229,6 @@ Notes:
#include <epan/etypes.h>
#include <epan/to_str.h>
#include <epan/stats_tree.h>
#include <wsutil/ws_printf.h> /* for ws_g_warning */
#define F5FILEINFOTAP_SRC
#include "packet-f5ethtrailer.h"
#undef F5FILEINFOTAP_SRC
@ -2206,17 +2205,17 @@ static void proto_init_f5ethtrailer(void)
error_string = register_tap_listener("ip", &tap_ip_enabled, NULL, TL_REQUIRES_NOTHING, NULL, ip_tap_pkt, NULL, NULL);
if (error_string) {
ws_g_warning("Unable to register tap \"ip\" for f5ethtrailer: %s", error_string->str);
g_warning("Unable to register tap \"ip\" for f5ethtrailer: %s", error_string->str);
g_string_free(error_string, TRUE);
}
error_string = register_tap_listener("ipv6", &tap_ipv6_enabled, NULL, TL_REQUIRES_NOTHING, NULL, ipv6_tap_pkt, NULL, NULL);
if (error_string) {
ws_g_warning("Unable to register tap \"ipv6\" for f5ethtrailer: %s", error_string->str);
g_warning("Unable to register tap \"ipv6\" for f5ethtrailer: %s", error_string->str);
g_string_free(error_string, TRUE);
}
error_string = register_tap_listener("tcp", &tap_tcp_enabled, NULL, TL_REQUIRES_NOTHING, NULL, tcp_tap_pkt, NULL, NULL);
if (error_string) {
ws_g_warning("Unable to register tap \"tcp\" for f5ethtrailer: %s", error_string->str);
g_warning("Unable to register tap \"tcp\" for f5ethtrailer: %s", error_string->str);
g_string_free(error_string, TRUE);
}
}

View File

@ -30,8 +30,6 @@
#include <epan/proto_data.h>
#include <epan/uat.h>
#include <wsutil/ws_printf.h> /* ws_g_warning */
#include "packet-per.h"
#include "packet-isup.h"
#include "packet-umts_fp.h"
@ -56,7 +54,7 @@
#define DEBUG_NBAP 0
#if DEBUG_NBAP
#include <epan/to_str.h>
#define nbap_debug(...) ws_g_warning(__VA_ARGS__)
#define nbap_debug(...) g_warning(__VA_ARGS__)
#else
#define nbap_debug(...)
#endif

View File

@ -26,7 +26,6 @@
#include <epan/proto_data.h>
#include <epan/uat.h>
#include <wsutil/file_util.h>
#include <wsutil/ws_printf.h> /* ws_g_warning */
#include <wsutil/wsgcrypt.h>
#include <wsutil/curve25519.h>
@ -912,7 +911,7 @@ wg_process_response(tvbuff_t *tvb, wg_handshake_state_t *hs)
// XXX when multiple responses are linkable to a single handshake state,
// they should probably fork into a new state or be discarded when equal.
if (hs->initiator_recv_cipher || hs->responder_recv_cipher) {
ws_g_warning("%s FIXME multiple responses linked to a single session", G_STRFUNC);
g_warning("%s FIXME multiple responses linked to a single session", G_STRFUNC);
return;
}
DISSECTOR_ASSERT(!hs->initiator_recv_cipher);
@ -1836,7 +1835,7 @@ proto_register_wg(void)
&pref_keylog_file, FALSE);
if (!wg_decrypt_init()) {
ws_g_warning("%s: decryption will not be possible due to lack of algorithms support", G_STRFUNC);
g_warning("%s: decryption will not be possible due to lack of algorithms support", G_STRFUNC);
}
wg_ephemeral_keys = wmem_map_new_autoreset(wmem_epan_scope(), wmem_file_scope(), g_int_hash, wg_pubkey_equal);

View File

@ -12,7 +12,6 @@
#include <stdarg.h>
#include <wsutil/wsgcrypt.h>
#include <wsutil/ws_printf.h> /* ws_g_warning */
#ifdef HAVE_LIBGNUTLS
#include <gnutls/gnutls.h>
@ -407,7 +406,7 @@ epan_get_frame_ts(const epan_t *session, guint32 frame_num)
abs_ts = session->funcs.get_frame_ts(session->prov, frame_num);
if (!abs_ts)
ws_g_warning("!!! couldn't get frame ts for %u !!!\n", frame_num);
g_warning("!!! couldn't get frame ts for %u !!!\n", frame_num);
return abs_ts;
}

View File

@ -39,7 +39,7 @@
#include <epan/range.h>
#include <wsutil/str_util.h>
#include <wsutil/ws_printf.h> /* ws_debug_printf and ws_g_warning */
#include <wsutil/ws_printf.h> /* ws_debug_printf */
static gint proto_malformed = -1;
static dissector_handle_t frame_handle = NULL;
@ -933,7 +933,7 @@ find_dissector_table(const char *name)
dissector_table = (dissector_table_t) g_hash_table_lookup(dissector_tables, new_name);
}
if (dissector_table) {
ws_g_warning("%s is now %s", name, new_name);
g_warning("%s is now %s", name, new_name);
}
}
return dissector_table;

View File

@ -32,7 +32,6 @@
#include <epan/decode_as.h>
#include "print.h"
#include <wsutil/file_util.h>
#include <wsutil/ws_printf.h> /* ws_g_warning */
#include <wsutil/report_message.h>
#include <epan/prefs-int.h>
@ -4456,7 +4455,7 @@ read_prefs_file(const char *pf_path, FILE *pf,
* If the pref has a trailing comma, eliminate it.
*/
cur_val->str[cur_val->len-1] = '\0';
ws_g_warning ("%s line %d: trailing comma in \"%s\" %s", pf_path, pline, cur_var->str, hint);
g_warning ("%s line %d: trailing comma in \"%s\" %s", pf_path, pline, cur_var->str, hint);
}
}
/* Call the routine to set the preference; it will parse
@ -4472,7 +4471,7 @@ read_prefs_file(const char *pf_path, FILE *pf,
break;
case PREFS_SET_SYNTAX_ERR:
ws_g_warning ("Syntax error in preference \"%s\" at line %d of\n%s %s",
g_warning ("Syntax error in preference \"%s\" at line %d of\n%s %s",
cur_var->str, pline, pf_path, hint);
break;
@ -4482,7 +4481,7 @@ read_prefs_file(const char *pf_path, FILE *pf,
* on non-Win32 platforms.
*/
if (strcmp(cur_var->str, "print.command") != 0)
ws_g_warning ("No such preference \"%s\" at line %d of\n%s %s",
g_warning ("No such preference \"%s\" at line %d of\n%s %s",
cur_var->str, pline, pf_path, hint);
prefs.unknown_prefs = TRUE;
break;
@ -4495,13 +4494,13 @@ read_prefs_file(const char *pf_path, FILE *pf,
The prefs in question need to be listed in the console window so that the
user can make an informed choice.
*/
ws_g_warning ("Obsolete preference \"%s\" at line %d of\n%s %s",
g_warning ("Obsolete preference \"%s\" at line %d of\n%s %s",
cur_var->str, pline, pf_path, hint);
prefs.unknown_prefs = TRUE;
break;
}
} else {
ws_g_warning ("Incomplete preference at line %d: of\n%s %s", pline, pf_path, hint);
g_warning ("Incomplete preference at line %d: of\n%s %s", pline, pf_path, hint);
}
}
state = IN_VAR;
@ -4514,7 +4513,7 @@ read_prefs_file(const char *pf_path, FILE *pf,
} else if (got_c == '#') {
state = IN_SKIP;
} else {
ws_g_warning ("Malformed preference at line %d of\n%s %s", fline, pf_path, hint);
g_warning ("Malformed preference at line %d of\n%s %s", fline, pf_path, hint);
}
break;
case IN_VAR:
@ -4559,12 +4558,12 @@ read_prefs_file(const char *pf_path, FILE *pf,
break;
case PREFS_SET_SYNTAX_ERR:
ws_g_warning ("Syntax error in preference %s at line %d of\n%s %s",
g_warning ("Syntax error in preference %s at line %d of\n%s %s",
cur_var->str, pline, pf_path, hint);
break;
case PREFS_SET_NO_SUCH_PREF:
ws_g_warning ("No such preference \"%s\" at line %d of\n%s %s",
g_warning ("No such preference \"%s\" at line %d of\n%s %s",
cur_var->str, pline, pf_path, hint);
prefs.unknown_prefs = TRUE;
break;
@ -4574,7 +4573,7 @@ read_prefs_file(const char *pf_path, FILE *pf,
break;
}
} else {
ws_g_warning("Incomplete preference at line %d of\n%s %s",
g_warning("Incomplete preference at line %d of\n%s %s",
pline, pf_path, hint);
}
}
@ -5230,16 +5229,16 @@ deprecated_port_pref(gchar *pref_name, const gchar *value)
for (i = 0; i < G_N_ELEMENTS(port_prefs); i++) {
module = prefs_find_module(port_prefs[i].module_name);
if (!module) {
ws_g_warning("Deprecated ports pref check - module '%s' not found", port_prefs[i].module_name);
g_warning("Deprecated ports pref check - module '%s' not found", port_prefs[i].module_name);
continue;
}
pref = prefs_find_preference(module, port_prefs[i].table_name);
if (!pref) {
ws_g_warning("Deprecated ports pref '%s.%s' not found", module->name, port_prefs[i].table_name);
g_warning("Deprecated ports pref '%s.%s' not found", module->name, port_prefs[i].table_name);
continue;
}
if (pref->type != PREF_DECODE_AS_UINT && pref->type != PREF_DECODE_AS_RANGE) {
ws_g_warning("Deprecated ports pref '%s.%s' has wrong type: %#x (%s)", module->name, port_prefs[i].table_name, pref->type, prefs_pref_type_name(pref));
g_warning("Deprecated ports pref '%s.%s' has wrong type: %#x (%s)", module->name, port_prefs[i].table_name, pref->type, prefs_pref_type_name(pref));
}
}
}
@ -5513,7 +5512,7 @@ set_pref(gchar *pref_name, const gchar *value, void *private_data _U_,
}
}
if (module) {
ws_g_warning ("Preference \"%s.%s\" has been converted to \"%s.%s\"\n"
g_warning ("Preference \"%s.%s\" has been converted to \"%s.%s\"\n"
"Save your preferences to make this change permanent.",
pref_name, dotp+1, module->name, dotp+1);
prefs.unknown_prefs = TRUE;
@ -6611,7 +6610,7 @@ write_prefs(char **pf_path_return)
char *err = NULL;
prefs.filter_expressions_old = FALSE;
if (!uat_save(uat_get_table_by_name("Display expressions"), &err)) {
ws_g_warning("Unable to save Display expressions: %s", err);
g_warning("Unable to save Display expressions: %s", err);
g_free(err);
}
}

View File

@ -44,7 +44,7 @@
#include "in_cksum.h"
#include "register-int.h"
#include <wsutil/ws_printf.h> /* ws_debug_printf/ws_g_warning */
#include <wsutil/ws_printf.h> /* ws_debug_printf */
#include <wsutil/crash_info.h>
#ifdef HAVE_JSONGLIB
@ -7663,7 +7663,7 @@ tmp_fld_check_assert(header_field_info *hfinfo)
so only report if different... */
if ((start_values[m].value == current->value) &&
(strcmp(start_values[m].strptr, current->strptr) != 0)) {
ws_g_warning("Field '%s' (%s) has a conflicting entry in its"
g_warning("Field '%s' (%s) has a conflicting entry in its"
" value_string: %u is at indices %u (%s) and %u (%s)\n",
hfinfo->name, hfinfo->abbrev,
current->value, m, start_values[m].strptr, n, current->strptr);
@ -10079,7 +10079,7 @@ proto_registrar_dump_values(void)
if (hfinfo->display & BASE_EXT_STRING) {
value_string_ext *vse_p = (value_string_ext *)hfinfo->strings;
if (!value_string_ext_validate(vse_p)) {
ws_g_warning("Invalid value_string_ext ptr for: %s", hfinfo->abbrev);
g_warning("Invalid value_string_ext ptr for: %s", hfinfo->abbrev);
continue;
}
try_val_to_str_ext(0, vse_p); /* "prime" the extended value_string */

View File

@ -18,7 +18,6 @@
#include <epan/prefs.h>
#include <epan/prefs-int.h>
#include <epan/show_exception.h>
#include <wsutil/ws_printf.h> /* ws_g_warning */
static int proto_short = -1;
static int proto_malformed = -1;
@ -137,7 +136,7 @@ show_exception(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree,
pinfo->current_proto,
exception_message == NULL ?
dissector_error_nomsg : exception_message);
ws_g_warning("Dissector bug, protocol %s, in packet %u: %s",
g_warning("Dissector bug, protocol %s, in packet %u: %s",
pinfo->current_proto, pinfo->num,
exception_message == NULL ?
dissector_error_nomsg : exception_message);

View File

@ -25,7 +25,6 @@
#include <epan/packet_info.h>
#include <epan/dfilter/dfilter.h>
#include <epan/tap.h>
#include <wsutil/ws_printf.h> /* ws_g_warning */
static gboolean tapping_is_active=FALSE;
@ -220,7 +219,7 @@ tap_queue_packet(int tap_id, packet_info *pinfo, const void *tap_specific_data)
* rather than having a fixed maximum number of entries?
*/
if(tap_packet_index >= TAP_PACKET_QUEUE_LEN){
ws_g_warning("Too many taps queued");
g_warning("Too many taps queued");
return;
}
@ -613,7 +612,7 @@ remove_tap_listener(void *tapdata)
}
if(!tl) {
ws_g_warning("remove_tap_listener(): no listener found with that tap data");
g_warning("remove_tap_listener(): no listener found with that tap data");
return;
}
}

View File

@ -19,7 +19,6 @@
#include <epan/proto.h>
#include <epan/packet_info.h>
#include <epan/tvbparse.h>
#include <wsutil/ws_printf.h> /* ws_g_warning */
#define TVBPARSE_DEBUG_ALL 0xffffffff
@ -78,7 +77,7 @@ static tvbparse_elem_t* new_tok(tvbparse_t* tt,
tvbparse_elem_t* tok;
#ifdef TVBPARSE_DEBUG
if (TVBPARSE_DEBUG & TVBPARSE_DEBUG_NEWTOK) ws_g_warning("new_tok: id=%i offset=%u len=%u",id,offset,len);
if (TVBPARSE_DEBUG & TVBPARSE_DEBUG_NEWTOK) g_warning("new_tok: id=%i offset=%u len=%u",id,offset,len);
#endif
tok = (tvbparse_elem_t *)wmem_new(wmem_packet_scope(), tvbparse_elem_t);
@ -104,20 +103,20 @@ static int ignore_fcn(tvbparse_t* tt, int offset) {
if (!tt->ignore) return 0;
#ifdef TVBPARSE_DEBUG
if (TVBPARSE_DEBUG & TVBPARSE_DEBUG_IGNORE) ws_g_warning("ignore: enter");
if (TVBPARSE_DEBUG & TVBPARSE_DEBUG_IGNORE) g_warning("ignore: enter");
#endif
while ((consumed = tt->ignore->condition(tt,offset,tt->ignore,&ignored)) > 0) {
len += consumed;
offset += consumed;
#ifdef TVBPARSE_DEBUG
if (TVBPARSE_DEBUG & TVBPARSE_DEBUG_IGNORE) ws_g_warning("ignore: consumed=%i",consumed);
if (TVBPARSE_DEBUG & TVBPARSE_DEBUG_IGNORE) g_warning("ignore: consumed=%i",consumed);
#endif
}
#ifdef TVBPARSE_DEBUG
if (TVBPARSE_DEBUG & TVBPARSE_DEBUG_IGNORE) ws_g_warning("ignore: len=%i",len);
if (TVBPARSE_DEBUG & TVBPARSE_DEBUG_IGNORE) g_warning("ignore: len=%i",len);
#endif
return len;
@ -129,7 +128,7 @@ static int cond_char (tvbparse_t* tt, const int offset, const tvbparse_wanted_t
guint i;
#ifdef TVBPARSE_DEBUG
if (TVBPARSE_DEBUG & TVBPARSE_DEBUG_CHAR) ws_g_warning("cond_char: control='%s'",wanted->control.str);
if (TVBPARSE_DEBUG & TVBPARSE_DEBUG_CHAR) g_warning("cond_char: control='%s'",wanted->control.str);
#endif
if ( offset + 1 > tt->end_offset )
@ -141,7 +140,7 @@ static int cond_char (tvbparse_t* tt, const int offset, const tvbparse_wanted_t
if ( c == t ) {
*tok = new_tok(tt,wanted->id,offset,1,wanted);
#ifdef TVBPARSE_DEBUG
if (TVBPARSE_DEBUG & TVBPARSE_DEBUG_CHAR) ws_g_warning("cond_char: GOT: '%c'",c);
if (TVBPARSE_DEBUG & TVBPARSE_DEBUG_CHAR) g_warning("cond_char: GOT: '%c'",c);
#endif
return 1;
}
@ -174,7 +173,7 @@ static int cond_chars_common(tvbparse_t* tt, int offset, const tvbparse_wanted_t
int left = tt->end_offset - offset;
#ifdef TVBPARSE_DEBUG
if (TVBPARSE_DEBUG & TVBPARSE_DEBUG_CHARS) ws_g_warning("cond_chars_common: control='%s'",wanted->control.str);
if (TVBPARSE_DEBUG & TVBPARSE_DEBUG_CHARS) g_warning("cond_chars_common: control='%s'",wanted->control.str);
#endif
if ( offset + (int)wanted->min > tt->end_offset )
@ -197,7 +196,7 @@ static int cond_chars_common(tvbparse_t* tt, int offset, const tvbparse_wanted_t
} else {
*tok = new_tok(tt,wanted->id,start,length,wanted);
#ifdef TVBPARSE_DEBUG
if (TVBPARSE_DEBUG & TVBPARSE_DEBUG_CHARS) ws_g_warning("cond_chars_common: GOT len=%i",length);
if (TVBPARSE_DEBUG & TVBPARSE_DEBUG_CHARS) g_warning("cond_chars_common: GOT len=%i",length);
#endif
return length;
}
@ -239,7 +238,7 @@ static int cond_not_char(tvbparse_t* tt, const int offset, const tvbparse_wanted
gboolean not_matched = FALSE;
#ifdef TVBPARSE_DEBUG
if (TVBPARSE_DEBUG & TVBPARSE_DEBUG_NOT_CHAR) ws_g_warning("cond_not_char: control='%s'",wanted->control.str);
if (TVBPARSE_DEBUG & TVBPARSE_DEBUG_NOT_CHAR) g_warning("cond_not_char: control='%s'",wanted->control.str);
#endif
if ( offset >= tt->end_offset ) {
@ -259,7 +258,7 @@ static int cond_not_char(tvbparse_t* tt, const int offset, const tvbparse_wanted
} else {
*tok = new_tok(tt,wanted->id,offset,1,wanted);
#ifdef TVBPARSE_DEBUG
if (TVBPARSE_DEBUG & TVBPARSE_DEBUG_NOT_CHAR) ws_g_warning("cond_not_char: GOT='%c'",t);
if (TVBPARSE_DEBUG & TVBPARSE_DEBUG_NOT_CHAR) g_warning("cond_not_char: GOT='%c'",t);
#endif
return 1;
}
@ -317,7 +316,7 @@ tvbparse_wanted_t* tvbparse_not_chars(const int id,
static int cond_string(tvbparse_t* tt, const int offset, const tvbparse_wanted_t * wanted, tvbparse_elem_t** tok) {
int len = wanted->len;
#ifdef TVBPARSE_DEBUG
if (TVBPARSE_DEBUG & TVBPARSE_DEBUG_STRING) ws_g_warning("cond_string: control='%s'",wanted->control.str);
if (TVBPARSE_DEBUG & TVBPARSE_DEBUG_STRING) g_warning("cond_string: control='%s'",wanted->control.str);
#endif
if ( offset + wanted->len > tt->end_offset )
@ -326,7 +325,7 @@ static int cond_string(tvbparse_t* tt, const int offset, const tvbparse_wanted_t
if ( tvb_strneql(tt->tvb, offset, wanted->control.str, len) == 0 ) {
*tok = new_tok(tt,wanted->id,offset,len,wanted);
#ifdef TVBPARSE_DEBUG
if (TVBPARSE_DEBUG & TVBPARSE_DEBUG_STRING) ws_g_warning("cond_string: GOT len=%i",len);
if (TVBPARSE_DEBUG & TVBPARSE_DEBUG_STRING) g_warning("cond_string: GOT len=%i",len);
#endif
return len;
} else {
@ -355,7 +354,7 @@ tvbparse_wanted_t* tvbparse_string(const int id,
static int cond_casestring(tvbparse_t* tt, const int offset, const tvbparse_wanted_t * wanted, tvbparse_elem_t** tok) {
int len = wanted->len;
#ifdef TVBPARSE_DEBUG
if (TVBPARSE_DEBUG & TVBPARSE_DEBUG_CASESTRING) ws_g_warning("cond_casestring: control='%s'",wanted->control.str);
if (TVBPARSE_DEBUG & TVBPARSE_DEBUG_CASESTRING) g_warning("cond_casestring: control='%s'",wanted->control.str);
#endif
if ( offset + len > tt->end_offset )
@ -364,7 +363,7 @@ static int cond_casestring(tvbparse_t* tt, const int offset, const tvbparse_want
if ( tvb_strncaseeql(tt->tvb, offset, wanted->control.str, len) == 0 ) {
*tok = new_tok(tt,wanted->id,offset,len,wanted);
#ifdef TVBPARSE_DEBUG
if (TVBPARSE_DEBUG & TVBPARSE_DEBUG_CASESTRING) ws_g_warning("cond_casestring: GOT len=%i",len);
if (TVBPARSE_DEBUG & TVBPARSE_DEBUG_CASESTRING) g_warning("cond_casestring: GOT len=%i",len);
#endif
return len;
} else {
@ -394,7 +393,7 @@ tvbparse_wanted_t* tvbparse_casestring(const int id,
static int cond_one_of(tvbparse_t* tt, const int offset, const tvbparse_wanted_t * wanted, tvbparse_elem_t** tok) {
guint i;
#ifdef TVBPARSE_DEBUG
if (TVBPARSE_DEBUG & TVBPARSE_DEBUG_ONEOF) ws_g_warning("cond_one_of: START");
if (TVBPARSE_DEBUG & TVBPARSE_DEBUG_ONEOF) g_warning("cond_one_of: START");
#endif
if ( offset > tt->end_offset )
@ -417,7 +416,7 @@ static int cond_one_of(tvbparse_t* tt, const int offset, const tvbparse_wanted_t
*tok = new_tok(tt, wanted->id, new_elem->offset, new_elem->len, wanted);
(*tok)->sub = new_elem;
#ifdef TVBPARSE_DEBUG
if (TVBPARSE_DEBUG & TVBPARSE_DEBUG_ONEOF) ws_g_warning("cond_one_of: GOT len=%i",curr_len);
if (TVBPARSE_DEBUG & TVBPARSE_DEBUG_ONEOF) g_warning("cond_one_of: GOT len=%i",curr_len);
#endif
tt->recursion_depth--;
return curr_len;
@ -475,7 +474,7 @@ static int cond_hash(tvbparse_t* tt, const int offset, const tvbparse_wanted_t*
tvbparse_elem_t* ret_tok;
#ifdef TVBPARSE_DEBUG
if (TVBPARSE_DEBUG & TVBPARSE_DEBUG_HASH) ws_g_warning("cond_hash: START");
if (TVBPARSE_DEBUG & TVBPARSE_DEBUG_HASH) g_warning("cond_hash: START");
#endif
if ( offset > tt->end_offset )
@ -493,7 +492,7 @@ static int cond_hash(tvbparse_t* tt, const int offset, const tvbparse_wanted_t*
key = tvb_get_string_enc(wmem_packet_scope(),key_elem->tvb,key_elem->offset,key_elem->len, ENC_ASCII);
#ifdef TVBPARSE_DEBUG
if (TVBPARSE_DEBUG & TVBPARSE_DEBUG_HASH) ws_g_warning("cond_hash: got key='%s'",key);
if (TVBPARSE_DEBUG & TVBPARSE_DEBUG_HASH) g_warning("cond_hash: got key='%s'",key);
#endif
if ((value_wanted = (tvbparse_wanted_t *)wmem_map_lookup(wanted->control.hash.table,key))) {
@ -519,7 +518,7 @@ static int cond_hash(tvbparse_t* tt, const int offset, const tvbparse_wanted_t*
*tok = ret_tok;
#ifdef TVBPARSE_DEBUG
if (TVBPARSE_DEBUG & TVBPARSE_DEBUG_HASH) ws_g_warning("cond_hash: GOT len=%i",tot_len);
if (TVBPARSE_DEBUG & TVBPARSE_DEBUG_HASH) g_warning("cond_hash: GOT len=%i",tot_len);
#endif
return tot_len;
@ -580,7 +579,7 @@ static int cond_seq(tvbparse_t* tt, int offset, const tvbparse_wanted_t * wanted
tvbparse_elem_t* ret_tok = NULL;
#ifdef TVBPARSE_DEBUG
if (TVBPARSE_DEBUG & TVBPARSE_DEBUG_SEQ) ws_g_warning("cond_seq: START");
if (TVBPARSE_DEBUG & TVBPARSE_DEBUG_SEQ) g_warning("cond_seq: START");
#endif
if ( offset > tt->end_offset )
@ -625,7 +624,7 @@ static int cond_seq(tvbparse_t* tt, int offset, const tvbparse_wanted_t * wanted
*tok = ret_tok;
#ifdef TVBPARSE_DEBUG
if (TVBPARSE_DEBUG & TVBPARSE_DEBUG_SEQ) ws_g_warning("cond_seq: GOT len=%i",offset - start);
if (TVBPARSE_DEBUG & TVBPARSE_DEBUG_SEQ) g_warning("cond_seq: GOT len=%i",offset - start);
#endif
return offset - start;
@ -664,7 +663,7 @@ static int cond_some(tvbparse_t* tt, int offset, const tvbparse_wanted_t * wante
int start = offset;
tvbparse_elem_t* ret_tok = NULL;
#ifdef TVBPARSE_DEBUG
if (TVBPARSE_DEBUG & TVBPARSE_DEBUG_SOME) ws_g_warning("cond_some: START");
if (TVBPARSE_DEBUG & TVBPARSE_DEBUG_SOME) g_warning("cond_some: START");
#endif
if ( offset > tt->end_offset )
@ -714,7 +713,7 @@ static int cond_some(tvbparse_t* tt, int offset, const tvbparse_wanted_t * wante
tt->recursion_depth--;
#ifdef TVBPARSE_DEBUG
if (TVBPARSE_DEBUG & TVBPARSE_DEBUG_SOME) ws_g_warning("cond_some: got num=%u",got_so_far);
if (TVBPARSE_DEBUG & TVBPARSE_DEBUG_SOME) g_warning("cond_some: got num=%u",got_so_far);
#endif
if(got_so_far < wanted->min) {
@ -723,7 +722,7 @@ static int cond_some(tvbparse_t* tt, int offset, const tvbparse_wanted_t * wante
*tok = ret_tok;
#ifdef TVBPARSE_DEBUG
if (TVBPARSE_DEBUG & TVBPARSE_DEBUG_SOME) ws_g_warning("cond_some: GOT len=%i",offset - start);
if (TVBPARSE_DEBUG & TVBPARSE_DEBUG_SOME) g_warning("cond_some: GOT len=%i",offset - start);
#endif
return offset - start;
}
@ -758,7 +757,7 @@ static int cond_until(tvbparse_t* tt, const int offset, const tvbparse_wanted_t
int len = 0;
int target_offset = offset;
#ifdef TVBPARSE_DEBUG
if (TVBPARSE_DEBUG & TVBPARSE_DEBUG_UNTIL) ws_g_warning("cond_until: START");
if (TVBPARSE_DEBUG & TVBPARSE_DEBUG_UNTIL) g_warning("cond_until: START");
#endif
if ( offset + wanted->control.until.subelem->len > tt->end_offset )
@ -787,19 +786,19 @@ static int cond_until(tvbparse_t* tt, const int offset, const tvbparse_wanted_t
case TP_UNTIL_INCLUDE:
new_elem->len = target_offset - offset - 1 + len;
#ifdef TVBPARSE_DEBUG
if (TVBPARSE_DEBUG & TVBPARSE_DEBUG_UNTIL) ws_g_warning("cond_until: GOT len=%i",target_offset - offset -1 + len);
if (TVBPARSE_DEBUG & TVBPARSE_DEBUG_UNTIL) g_warning("cond_until: GOT len=%i",target_offset - offset -1 + len);
#endif
return target_offset - offset -1 + len;
case TP_UNTIL_SPEND:
new_elem->len = target_offset - offset - 1;
#ifdef TVBPARSE_DEBUG
if (TVBPARSE_DEBUG & TVBPARSE_DEBUG_UNTIL) ws_g_warning("cond_until: GOT len=%i",target_offset - offset -1 + len);
if (TVBPARSE_DEBUG & TVBPARSE_DEBUG_UNTIL) g_warning("cond_until: GOT len=%i",target_offset - offset -1 + len);
#endif
return target_offset - offset - 1 + len;
case TP_UNTIL_LEAVE:
new_elem->len = target_offset - offset - 1;
#ifdef TVBPARSE_DEBUG
if (TVBPARSE_DEBUG & TVBPARSE_DEBUG_UNTIL) ws_g_warning("cond_until: GOT len=%i",target_offset - offset -1);
if (TVBPARSE_DEBUG & TVBPARSE_DEBUG_UNTIL) g_warning("cond_until: GOT len=%i",target_offset - offset -1);
#endif
return target_offset - offset -1;
default:
@ -1217,7 +1216,7 @@ tvbparse_t* tvbparse_init(tvbuff_t* tvb,
tvbparse_t* tt = (tvbparse_t *)wmem_new(wmem_packet_scope(), tvbparse_t);
#ifdef TVBPARSE_DEBUG
if (TVBPARSE_DEBUG & TVBPARSE_DEBUG_TT) ws_g_warning("tvbparse_init: offset=%i len=%i",offset,len);
if (TVBPARSE_DEBUG & TVBPARSE_DEBUG_TT) g_warning("tvbparse_init: offset=%i len=%i",offset,len);
#endif
@ -1236,7 +1235,7 @@ gboolean tvbparse_reset(tvbparse_t* tt,
int len) {
#ifdef TVBPARSE_DEBUG
if (TVBPARSE_DEBUG & TVBPARSE_DEBUG_TT) ws_g_warning("tvbparse_init: offset=%i len=%i",offset,len);
if (TVBPARSE_DEBUG & TVBPARSE_DEBUG_TT) g_warning("tvbparse_init: offset=%i len=%i",offset,len);
#endif
len = (len == -1) ? (int) tvb_captured_length(tt->tvb) : len;
@ -1260,7 +1259,7 @@ static void execute_callbacks(tvbparse_t* tt, tvbparse_elem_t* curr) {
while (curr) {
if(curr->wanted->before) {
#ifdef TVBPARSE_DEBUG
if (TVBPARSE_DEBUG & TVBPARSE_DEBUG_CB) ws_g_warning("execute_callbacks: BEFORE: id=%i offset=%i len=%i",curr->id,curr->offset,curr->len);
if (TVBPARSE_DEBUG & TVBPARSE_DEBUG_CB) g_warning("execute_callbacks: BEFORE: id=%i offset=%i len=%i",curr->id,curr->offset,curr->len);
#endif
curr->wanted->before(tt->data, curr->wanted->data, curr);
}
@ -1271,7 +1270,7 @@ static void execute_callbacks(tvbparse_t* tt, tvbparse_elem_t* curr) {
continue;
} else {
#ifdef TVBPARSE_DEBUG
if (TVBPARSE_DEBUG & TVBPARSE_DEBUG_CB) ws_g_warning("execute_callbacks: AFTER: id=%i offset=%i len=%i",curr->id,curr->offset,curr->len);
if (TVBPARSE_DEBUG & TVBPARSE_DEBUG_CB) g_warning("execute_callbacks: AFTER: id=%i offset=%i len=%i",curr->id,curr->offset,curr->len);
#endif
if(curr->wanted->after) curr->wanted->after(tt->data, curr->wanted->data, curr);
}
@ -1281,7 +1280,7 @@ static void execute_callbacks(tvbparse_t* tt, tvbparse_elem_t* curr) {
while( !curr && wmem_stack_count(stack) > 0 ) {
curr = (tvbparse_elem_t *)wmem_stack_pop(stack);
#ifdef TVBPARSE_DEBUG
if (TVBPARSE_DEBUG & TVBPARSE_DEBUG_CB) ws_g_warning("execute_callbacks: AFTER: id=%i offset=%i len=%i",curr->id,curr->offset,curr->len);
if (TVBPARSE_DEBUG & TVBPARSE_DEBUG_CB) g_warning("execute_callbacks: AFTER: id=%i offset=%i len=%i",curr->id,curr->offset,curr->len);
#endif
if( curr->wanted->after ) curr->wanted->after(tt->data, curr->wanted->data, curr);
curr = curr->next;
@ -1297,25 +1296,25 @@ gboolean tvbparse_peek(tvbparse_t* tt,
int offset = tt->offset;
#ifdef TVBPARSE_DEBUG
if (TVBPARSE_DEBUG & TVBPARSE_DEBUG_PEEK) ws_g_warning("tvbparse_peek: ENTER offset=%i",offset);
if (TVBPARSE_DEBUG & TVBPARSE_DEBUG_PEEK) g_warning("tvbparse_peek: ENTER offset=%i",offset);
#endif
offset += ignore_fcn(tt,offset);
#ifdef TVBPARSE_DEBUG
if (TVBPARSE_DEBUG & TVBPARSE_DEBUG_PEEK) ws_g_warning("tvbparse_peek: after ignore offset=%i",offset);
if (TVBPARSE_DEBUG & TVBPARSE_DEBUG_PEEK) g_warning("tvbparse_peek: after ignore offset=%i",offset);
#endif
consumed = wanted->condition(tt,offset,wanted,&tok);
if (consumed >= 0) {
#ifdef TVBPARSE_DEBUG
if (TVBPARSE_DEBUG & TVBPARSE_DEBUG_PEEK) ws_g_warning("tvbparse_peek: GOT len=%i",consumed);
if (TVBPARSE_DEBUG & TVBPARSE_DEBUG_PEEK) g_warning("tvbparse_peek: GOT len=%i",consumed);
#endif
return TRUE;
} else {
#ifdef TVBPARSE_DEBUG
if (TVBPARSE_DEBUG & TVBPARSE_DEBUG_PEEK) ws_g_warning("tvbparse_peek: NOT GOT");
if (TVBPARSE_DEBUG & TVBPARSE_DEBUG_PEEK) g_warning("tvbparse_peek: NOT GOT");
#endif
return FALSE;
}
@ -1329,25 +1328,25 @@ tvbparse_elem_t* tvbparse_get(tvbparse_t* tt,
int offset = tt->offset;
#ifdef TVBPARSE_DEBUG
if (TVBPARSE_DEBUG & TVBPARSE_DEBUG_GET) ws_g_warning("tvbparse_get: ENTER offset=%i",offset);
if (TVBPARSE_DEBUG & TVBPARSE_DEBUG_GET) g_warning("tvbparse_get: ENTER offset=%i",offset);
#endif
offset += ignore_fcn(tt,offset);
#ifdef TVBPARSE_DEBUG
if (TVBPARSE_DEBUG & TVBPARSE_DEBUG_GET) ws_g_warning("tvbparse_get: after ignore offset=%i",offset);
if (TVBPARSE_DEBUG & TVBPARSE_DEBUG_GET) g_warning("tvbparse_get: after ignore offset=%i",offset);
#endif
consumed = wanted->condition(tt,offset,wanted,&tok);
if (consumed >= 0) {
#ifdef TVBPARSE_DEBUG
if (TVBPARSE_DEBUG & TVBPARSE_DEBUG_GET) ws_g_warning("tvbparse_get: GOT len=%i",consumed);
if (TVBPARSE_DEBUG & TVBPARSE_DEBUG_GET) g_warning("tvbparse_get: GOT len=%i",consumed);
#endif
execute_callbacks(tt,tok);
tt->offset = offset + consumed;
#ifdef TVBPARSE_DEBUG
if (TVBPARSE_DEBUG & TVBPARSE_DEBUG_GET) ws_g_warning("tvbparse_get: DONE offset=%i", tt->offset);
if (TVBPARSE_DEBUG & TVBPARSE_DEBUG_GET) g_warning("tvbparse_get: DONE offset=%i", tt->offset);
#endif
return tok;
} else {
@ -1364,7 +1363,7 @@ tvbparse_elem_t* tvbparse_find(tvbparse_t* tt, const tvbparse_wanted_t* wanted)
int target_offset = offset -1;
#ifdef TVBPARSE_DEBUG
if (TVBPARSE_DEBUG & TVBPARSE_DEBUG_FIND) ws_g_warning("tvbparse_get: ENTER offset=%i", tt->offset);
if (TVBPARSE_DEBUG & TVBPARSE_DEBUG_FIND) g_warning("tvbparse_get: ENTER offset=%i", tt->offset);
#endif
do {
@ -1373,18 +1372,18 @@ tvbparse_elem_t* tvbparse_find(tvbparse_t* tt, const tvbparse_wanted_t* wanted)
if (len >= 0) {
#ifdef TVBPARSE_DEBUG
if (TVBPARSE_DEBUG & TVBPARSE_DEBUG_FIND) ws_g_warning("tvbparse_get: FOUND offset=%i len=%i", target_offset,len);
if (TVBPARSE_DEBUG & TVBPARSE_DEBUG_FIND) g_warning("tvbparse_get: FOUND offset=%i len=%i", target_offset,len);
#endif
execute_callbacks(tt,tok);
tt->offset = target_offset + len;
#ifdef TVBPARSE_DEBUG
if (TVBPARSE_DEBUG & TVBPARSE_DEBUG_FIND) ws_g_warning("tvbparse_get: DONE offset=%i", tt->offset);
if (TVBPARSE_DEBUG & TVBPARSE_DEBUG_FIND) g_warning("tvbparse_get: DONE offset=%i", tt->offset);
#endif
return tok;
} else {
#ifdef TVBPARSE_DEBUG
if (TVBPARSE_DEBUG & TVBPARSE_DEBUG_FIND) ws_g_warning("tvbparse_get: NOT FOUND");
if (TVBPARSE_DEBUG & TVBPARSE_DEBUG_FIND) g_warning("tvbparse_get: NOT FOUND");
#endif
return NULL;
}

View File

@ -17,7 +17,6 @@
#include "proto.h"
#include "to_str.h"
#include "value_string.h"
#include <wsutil/ws_printf.h> /* ws_g_warning */
/* REGULAR VALUE STRING */
@ -453,14 +452,14 @@ _try_val_to_str_ext_init(const guint32 val, value_string_ext *vse)
/* XXX: Should check for dups ?? */
if (type == VS_BIN_TREE) {
if (prev_value > vs_p[i].value) {
ws_g_warning("Extended value string '%s' forced to fall back to linear search:\n"
g_warning("Extended value string '%s' forced to fall back to linear search:\n"
" entry %u, value %u [%#x] < previous entry, value %u [%#x]",
vse->_vs_name, i, vs_p[i].value, vs_p[i].value, prev_value, prev_value);
type = VS_SEARCH;
break;
}
if (first_value > vs_p[i].value) {
ws_g_warning("Extended value string '%s' forced to fall back to linear search:\n"
g_warning("Extended value string '%s' forced to fall back to linear search:\n"
" entry %u, value %u [%#x] < first entry, value %u [%#x]",
vse->_vs_name, i, vs_p[i].value, vs_p[i].value, first_value, first_value);
type = VS_SEARCH;

View File

@ -84,7 +84,8 @@ CHECKAPI(
NAME
wmem
SWITCHES
-g termoutput -build
--group termoutput:1 --summary-group termoutput
--build
SOURCES
${WMEM_FILES}
)

View File

@ -23,8 +23,6 @@
#include "wmem_allocator_block_fast.h"
#include "wmem_allocator_strict.h"
#include <wsutil/ws_printf.h> /* ws_g_warning */
/* Set according to the WIRESHARK_DEBUG_WMEM_OVERRIDE environment variable in
* wmem_init. Should not be set again. */
static gboolean do_override = FALSE;
@ -198,7 +196,7 @@ wmem_init(void)
override_type = WMEM_ALLOCATOR_BLOCK_FAST;
}
else {
ws_g_warning("Unrecognized wmem override");
g_warning("Unrecognized wmem override");
do_override = FALSE;
}
}

View File

@ -154,7 +154,7 @@ CHECKAPI(
NAME
wslua
SWITCHES
-g termoutput -build
--group termoutput:6 --summary-group termoutput --build
SOURCES
${WSLUA_FILES}
)

View File

@ -17,7 +17,6 @@
#include <errno.h>
#include <wiretap/file_wrappers.h>
#include <wsutil/ws_printf.h> /* ws_g_warning */
#define MAX_LINE_LENGTH 65536
@ -278,12 +277,12 @@ WSLUA_METHOD File_read(lua_State* L) {
/* shiftFile() doesn't verify things like expired */
if (f->expired) {
ws_g_warning("Error in File read: Lua File has expired");
g_warning("Error in File read: Lua File has expired");
return 0;
}
if (!file_is_reader(f)) {
ws_g_warning("Error in File read: this File object instance is for writing only");
g_warning("Error in File read: this File object instance is for writing only");
return 0;
}
@ -400,7 +399,7 @@ WSLUA_METHOD File_lines(lua_State* L) {
return luaL_error(L, "Error getting File handle for lines");
if (!file_is_reader(f)) {
ws_g_warning("Error in File read: this File object instance is for writing only");
g_warning("Error in File read: this File object instance is for writing only");
return 0;
}
@ -422,7 +421,7 @@ WSLUA_METHOD File_write(lua_State* L) {
int err = 0;
if (!f->wdh) {
ws_g_warning("Error in File read: this File object instance is for reading only");
g_warning("Error in File read: this File object instance is for reading only");
return 0;
}

View File

@ -14,7 +14,6 @@
*/
#include "wslua_file_common.h"
#include <wsutil/ws_printf.h> /* ws_g_warning */
/* WSLUA_CONTINUE_MODULE File */
@ -51,19 +50,19 @@ static gboolean in_routine = FALSE;
/* This does the verification and setup common to all open/read/seek_read/close routines */
#define INIT_FILEHANDLER_ROUTINE(name,retval) \
if (!fh) { \
ws_g_warning("Error in file %s: no Lua FileHandler object", #name); \
g_warning("Error in file %s: no Lua FileHandler object", #name); \
return retval; \
} \
if (!fh->registered) { \
ws_g_warning("Error in file %s: Lua FileHandler is not registered", #name); \
g_warning("Error in file %s: Lua FileHandler is not registered", #name); \
return retval; \
} \
if (!fh->L) { \
ws_g_warning("Error in file %s: no FileHandler Lua state", #name); \
g_warning("Error in file %s: no FileHandler Lua state", #name); \
return retval; \
} \
if (fh->name##_ref == LUA_NOREF) { \
ws_g_warning("Error in file %s: no FileHandler %s routine reference", #name, #name); \
g_warning("Error in file %s: no FileHandler %s routine reference", #name, #name); \
return retval; \
} \
L = fh->L; \
@ -71,7 +70,7 @@ static gboolean in_routine = FALSE;
push_error_handler(L, #name " routine"); \
lua_rawgeti(L, LUA_REGISTRYINDEX, fh->name##_ref); \
if (!lua_isfunction(L, -1)) { \
ws_g_warning("Error in file %s: no FileHandler %s routine function in Lua", #name, #name); \
g_warning("Error in file %s: no FileHandler %s routine function in Lua", #name, #name); \
return retval; \
} \
/* now guard against deregistering during pcall() */ \
@ -89,16 +88,16 @@ static gboolean in_routine = FALSE;
#define CASE_ERROR(name) \
case LUA_ERRRUN: \
ws_g_warning("Run-time error while calling FileHandler %s routine", name); \
g_warning("Run-time error while calling FileHandler %s routine", name); \
break; \
case LUA_ERRMEM: \
ws_g_warning("Memory alloc error while calling FileHandler %s routine", name); \
g_warning("Memory alloc error while calling FileHandler %s routine", name); \
break; \
case LUA_ERRERR: \
ws_g_warning("Error in error handling while calling FileHandler %s routine", name); \
g_warning("Error in error handling while calling FileHandler %s routine", name); \
break; \
case LUA_ERRGCMM: \
ws_g_warning("Error in garbage collector while calling FileHandler %s routine", name); \
g_warning("Error in garbage collector while calling FileHandler %s routine", name); \
break; \
default: \
g_assert_not_reached(); \
@ -106,19 +105,19 @@ static gboolean in_routine = FALSE;
#define CASE_ERROR_ERRINFO(name) \
case LUA_ERRRUN: \
ws_g_warning("Run-time error while calling FileHandler %s routine", name); \
g_warning("Run-time error while calling FileHandler %s routine", name); \
*err_info = g_strdup_printf("Run-time error while calling FileHandler %s routine", name); \
break; \
case LUA_ERRMEM: \
ws_g_warning("Memory alloc error while calling FileHandler %s routine", name); \
g_warning("Memory alloc error while calling FileHandler %s routine", name); \
*err_info = g_strdup_printf("Memory alloc error while calling FileHandler %s routine", name); \
break; \
case LUA_ERRERR: \
ws_g_warning("Error in error handling while calling FileHandler %s routine", name); \
g_warning("Error in error handling while calling FileHandler %s routine", name); \
*err_info = g_strdup_printf("Error in error handling while calling FileHandler %s routine", name); \
break; \
case LUA_ERRGCMM: \
ws_g_warning("Error in garbage collector while calling FileHandler %s routine", name); \
g_warning("Error in garbage collector while calling FileHandler %s routine", name); \
*err_info = g_strdup_printf("Error in garbage collector while calling FileHandler %s routine", name); \
break; \
default: \
@ -187,7 +186,7 @@ wslua_filehandler_open(wtap *wth, int *err, gchar **err_info)
wth->subtype_read = wslua_filehandler_read;
}
else {
ws_g_warning("Lua file format module lacks a read routine");
g_warning("Lua file format module lacks a read routine");
return WTAP_OPEN_NOT_MINE;
}
@ -195,7 +194,7 @@ wslua_filehandler_open(wtap *wth, int *err, gchar **err_info)
wth->subtype_seek_read = wslua_filehandler_seek_read;
}
else {
ws_g_warning("Lua file format module lacks a seek-read routine");
g_warning("Lua file format module lacks a seek-read routine");
return WTAP_OPEN_NOT_MINE;
}
@ -225,7 +224,7 @@ wslua_filehandler_open(wtap *wth, int *err, gchar **err_info)
}
else {
/* not a valid return type */
ws_g_warning("FileHandler read_open routine returned %d", retval);
g_warning("FileHandler read_open routine returned %d", retval);
if (err) {
*err = WTAP_ERR_INTERNAL;
}
@ -505,7 +504,7 @@ wslua_filehandler_dump_open(wtap_dumper *wdh, int *err)
wdh->subtype_write = wslua_filehandler_dump;
}
else {
ws_g_warning("FileHandler was not set with a write function, even though write_open() returned true");
g_warning("FileHandler was not set with a write function, even though write_open() returned true");
return 0;
}

View File

@ -14,7 +14,6 @@
*/
#include "wslua_file_common.h"
#include <wsutil/ws_printf.h> /* ws_g_warning */
/* WSLUA_CONTINUE_MODULE File */
@ -145,12 +144,12 @@ static int FrameInfo_set_data (lua_State* L) {
FrameInfo fi = checkFrameInfo(L,1);
if (!fi->rec) {
ws_g_warning("Error in FrameInfo set data: NULL pointer");
g_warning("Error in FrameInfo set data: NULL pointer");
return 0;
}
if (!fi->buf) {
ws_g_warning("Error in FrameInfo set data: NULL frame_buffer pointer");
g_warning("Error in FrameInfo set data: NULL frame_buffer pointer");
return 0;
}

View File

@ -13,7 +13,6 @@
#include "config.h"
#include <epan/wmem/wmem.h>
#include <wsutil/ws_printf.h> /* ws_g_warning */
#include "wslua.h"
@ -49,10 +48,10 @@ static void lua_menu_callback(gpointer data) {
case 0:
break;
case LUA_ERRRUN:
ws_g_warning("Runtime error while calling menu callback");
g_warning("Runtime error while calling menu callback");
break;
case LUA_ERRMEM:
ws_g_warning("Memory alloc error while calling menu callback");
g_warning("Memory alloc error while calling menu callback");
break;
default:
g_assert_not_reached();
@ -146,10 +145,10 @@ static void lua_dialog_cb(gchar** user_input, void* data) {
case 0:
break;
case LUA_ERRRUN:
ws_g_warning("Runtime error while calling dialog callback");
g_warning("Runtime error while calling dialog callback");
break;
case LUA_ERRMEM:
ws_g_warning("Memory alloc error while calling dialog callback");
g_warning("Memory alloc error while calling dialog callback");
break;
default:
g_assert_not_reached();
@ -185,10 +184,10 @@ static void text_win_close_cb(void* data) {
case 0:
break;
case LUA_ERRRUN:
ws_g_warning("Runtime error during execution of TextWindow close callback");
g_warning("Runtime error during execution of TextWindow close callback");
break;
case LUA_ERRMEM:
ws_g_warning("Memory alloc error during execution of TextWindow close callback");
g_warning("Memory alloc error during execution of TextWindow close callback");
break;
default:
break;
@ -614,10 +613,10 @@ static gboolean wslua_button_callback(funnel_text_window_t* ws_tw, void* data) {
case 0:
break;
case LUA_ERRRUN:
ws_g_warning("Runtime error while calling button callback");
g_warning("Runtime error while calling button callback");
break;
case LUA_ERRMEM:
ws_g_warning("Memory alloc error while calling button callback");
g_warning("Memory alloc error while calling button callback");
break;
default:
g_assert_not_reached();

View File

@ -19,7 +19,6 @@
/* WSLUA_MODULE Listener Post-dissection packet analysis */
#include "wslua.h"
#include <wsutil/ws_printf.h> /* ws_g_warning */
WSLUA_CLASS_DEFINE(Listener,FAIL_ON_NULL("Listener"));
/*
@ -100,7 +99,7 @@ static gboolean lua_tap_packet(void *tapdata, packet_info *pinfo, epan_dissect_t
case LUA_ERRRUN:
break;
case LUA_ERRMEM:
ws_g_warning("Memory alloc error while calling listener tap callback packet");
g_warning("Memory alloc error while calling listener tap callback packet");
break;
default:
g_assert_not_reached();
@ -135,10 +134,10 @@ static void lua_tap_reset(void *tapdata) {
case 0:
break;
case LUA_ERRRUN:
ws_g_warning("Runtime error while calling a listener's init()");
g_warning("Runtime error while calling a listener's init()");
break;
case LUA_ERRMEM:
ws_g_warning("Memory alloc error while calling a listener's init()");
g_warning("Memory alloc error while calling a listener's init()");
break;
default:
g_assert_not_reached();
@ -160,10 +159,10 @@ static void lua_tap_draw(void *tapdata) {
break;
case LUA_ERRRUN:
error = lua_tostring(tap->L,-1);
ws_g_warning("Runtime error while calling a listener's draw(): %s",error);
g_warning("Runtime error while calling a listener's draw(): %s",error);
break;
case LUA_ERRMEM:
ws_g_warning("Memory alloc error while calling a listener's draw()");
g_warning("Memory alloc error while calling a listener's draw()");
break;
default:
g_assert_not_reached();

View File

@ -17,7 +17,6 @@
#include "wslua.h"
#include <math.h>
#include <epan/stat_tap_ui.h>
#include <wsutil/ws_printf.h> /* ws_g_warning */
WSLUA_FUNCTION wslua_get_version(lua_State* L) { /* Gets a string of the Wireshark version. */
@ -243,10 +242,10 @@ static void statcmd_init(const char *opt_arg, void* userdata) {
case 0:
break;
case LUA_ERRRUN:
ws_g_warning("Runtime error while calling statcmd callback");
g_warning("Runtime error while calling statcmd callback");
break;
case LUA_ERRMEM:
ws_g_warning("Memory alloc error while calling statcmd callback");
g_warning("Memory alloc error while calling statcmd callback");
break;
default:
g_assert_not_reached();

View File

@ -61,7 +61,9 @@ CHECKAPI(
NAME
mate
SWITCHES
-g abort -g termoutput -build
--group abort
--group termoutput:1 --summary-group termoutput
--build
SOURCES
${DISSECTOR_SRC}
${DISSECTOR_SUPPORT_SRC}

View File

@ -14,7 +14,6 @@
#include "mate.h"
#include "mate_util.h"
#include <wsutil/file_util.h>
#include <wsutil/ws_printf.h> /* ws_g_warning */
/***************************************************************************
@ -125,7 +124,7 @@ gchar* scs_subscribe(SCS_collection* c, const gchar* s) {
len = SCS_HUGE_SIZE;
} else {
len = SCS_HUGE_SIZE;
ws_g_warning("mate SCS: string truncated due to huge size");
g_warning("mate SCS: string truncated due to huge size");
}
orig = (gchar *)g_slice_alloc(len);
@ -175,7 +174,7 @@ void scs_unsubscribe(SCS_collection* c, gchar* s) {
(*ip)--;
}
} else {
ws_g_warning("unsubscribe: not subscribed");
g_warning("unsubscribe: not subscribed");
}
}

View File

@ -18,7 +18,6 @@
#include "mate.h"
#include <epan/expert.h>
#include <wsutil/ws_printf.h> /* ws_g_warning */
void proto_register_mate(void);
void proto_reg_handoff_mate(void);

View File

@ -772,7 +772,7 @@ static void init_globals(void)
if (hf_of_interest[i].hf != -1)
g_array_append_val(wanted_fields, hf_of_interest[i].hf);
else
ws_g_warning("TRANSUM: unknown field %s", hf_of_interest[i].proto_name);
g_warning("TRANSUM: unknown field %s", hf_of_interest[i].proto_name);
}
set_postdissector_wanted_hfids(transum_handle, wanted_fields);

View File

@ -890,8 +890,8 @@ sub check_pref_var_dupes($$)
sub print_usage
{
print "Usage: checkAPIs.pl [-M] [-h] [-g group1] [-g group2] ... \n";
print " [--build] [-s group1] [-s group2] ... \n";
print "Usage: checkAPIs.pl [-M] [-h] [-g group1[:count]] [-g group2] ... \n";
print " [--build] [-summary-group group1] [-summary-group group2] ... \n";
print " [--sourcedir=srcdir] \n";
print " [--nocheck-value-string-array] \n";
print " [--nocheck-addtext] [--nocheck-hf] [--debug]\n";
@ -903,7 +903,8 @@ sub print_usage
print " -h: help, print usage message\n";
print " -g <group>: Check input files for use of APIs in <group>\n";
print " (in addition to the default groups)\n";
print " -s <group>: Output summary (count) for each API in <group>\n";
print " Maximum uses can be specified with <group>:<count>\n";
print " -summary-group <group>: Output summary (count) for each API in <group>\n";
print " (-g <group> also req'd)\n";
print " ---nocheck-value-string-array: UNDOCUMENTED\n";
print " ---nocheck-addtext: UNDOCUMENTED\n";
@ -1078,6 +1079,11 @@ for my $apiGroup (keys %APIs) {
$APIs{$apiGroup}->{function_counts} = {};
@{$APIs{$apiGroup}->{function_counts}}{@functions} = (); # Add fcn names as keys to the anonymous hash
$APIs{$apiGroup}->{max_function_count} = -1;
if ($APIs{$apiGroup}->{count_errors}) {
$APIs{$apiGroup}->{max_function_count} = 0;
}
$APIs{$apiGroup}->{cur_function_count} = 0;
}
my @filelist;
@ -1219,12 +1225,36 @@ while ($_ = pop @filelist)
# Check and count APIs
for my $apiGroup (@apiGroups) {
for my $groupArg (@apiGroups) {
my $pfx = "Warning";
@foundAPIs = ();
my @groupParts = split(/:/, $groupArg);
my $apiGroup = $groupParts[0];
my $curFuncCount = 0;
if (scalar @groupParts > 1) {
$APIs{$apiGroup}->{max_function_count} = $groupParts[1];
}
findAPIinFile($APIs{$apiGroup}, \$fileContents, \@foundAPIs);
for my $api (keys %{$APIs{$apiGroup}->{function_counts}} ) {
$curFuncCount += $APIs{$apiGroup}{function_counts}{$api};
}
# If we have a max function count and we've exceeded it, treat it
# as an error.
if (!$APIs{$apiGroup}->{count_errors} && $APIs{$apiGroup}->{max_function_count} >= 0) {
if ($curFuncCount > $APIs{$apiGroup}->{max_function_count}) {
print STDERR $pfx . ": " . $apiGroup . " exceeds maximum function count: " . $APIs{$apiGroup}->{max_function_count} . "\n";
$APIs{$apiGroup}->{count_errors} = 1;
}
}
if ($curFuncCount <= $APIs{$apiGroup}->{max_function_count}) {
next;
}
if ($APIs{$apiGroup}->{count_errors}) {
# the use of "prohibited" APIs is an error, increment the error count
$errorCount += @foundAPIs;
@ -1244,10 +1274,16 @@ while ($_ = pop @filelist)
# Summary: Print Use Counts of each API in each requested summary group
for my $apiGroup (@apiSummaryGroups) {
printf "\n\nUse Counts\n";
for my $api (sort {"\L$a" cmp "\L$b"} (keys %{$APIs{$apiGroup}->{function_counts}} )) {
printf "%-20.20s %5d %-40.40s\n", $apiGroup . ':', $APIs{$apiGroup}{function_counts}{$api}, $api;
if (scalar @apiSummaryGroups > 0) {
my $fileline = join(", ", @ARGV);
printf "\nSummary for " . substr($fileline, 0, 65) . "…\n";
for my $apiGroup (@apiSummaryGroups) {
printf "\nUse counts for %s (maximum allowed total is %d)\n", $apiGroup, $APIs{$apiGroup}->{max_function_count};
for my $api (sort {"\L$a" cmp "\L$b"} (keys %{$APIs{$apiGroup}->{function_counts}} )) {
if ($APIs{$apiGroup}{function_counts}{$api} < 1) { next; }
printf "%5d %-40.40s\n", $APIs{$apiGroup}{function_counts}{$api}, $api;
}
}
}

View File

@ -171,9 +171,9 @@ CHECKAPI(
NAME
wiretap
SWITCHES
## 'abort' checking disabled for now pending resolution of existing use of g_assert & g_error
## -g abort -g termoutput
-g termoutput -build
--group abort:10 --summary-group abort
--group termoutput:1 --summary-group termoutput
--build
SOURCES
${WIRETAP_NONGENERATED_FILES}
# LEX files commented out due to use of malloc, free etc.

View File

@ -255,7 +255,7 @@ register_pcapng_block_type_handler(guint block_type, block_reader reader,
* something we don't handle in that block, submit a change
* to the main Wireshark source).
*/
ws_g_warning("Attempt to register plugin for block type 0x%08x not allowed",
g_warning("Attempt to register plugin for block type 0x%08x not allowed",
block_type);
return;
@ -279,7 +279,7 @@ register_pcapng_block_type_handler(guint block_type, block_reader reader,
* No; don't allow a plugin to be registered for it, as
* the block type needs to be registered before it's used.
*/
ws_g_warning("Attempt to register plugin for reserved block type 0x%08x not allowed",
g_warning("Attempt to register plugin for reserved block type 0x%08x not allowed",
block_type);
return;
}

View File

@ -317,7 +317,7 @@ CHECKAPI(
NAME
wsutil
SWITCHES
-g termoutput -build
--group termoutput:1 --summary-group termoutput --build
SOURCES
${WSUTIL_COMMON_FILES}
)

View File

@ -20,7 +20,6 @@
#else
#include <windows.h>
#endif
#include "ws_printf.h" /* ws_g_warning */
/* converts a broken down date representation, relative to UTC,
* to a timestamp; it uses timegm() if it's available.
@ -108,7 +107,7 @@ void log_resource_usage(gboolean reset_delta, const char *format, ...) {
g_string_append_vprintf(log_str, format, ap);
va_end(ap);
ws_g_warning("%s", log_str->str);
g_warning("%s", log_str->str);
g_string_free(log_str, TRUE);
}

View File

@ -71,11 +71,6 @@ debugging context has a protocol tree.
*/
#define ws_debug_printf printf
/* This is intended to fool checkAPIs.pl for few places that have legitimate
use for g_warning. This should be used sparingly.
*/
#define ws_g_warning g_warning
#ifdef __cplusplus
}
#endif /* __cplusplus */