diff options
author | Guy Harris <guy@alum.mit.edu> | 2015-01-18 02:22:19 -0800 |
---|---|---|
committer | Guy Harris <guy@alum.mit.edu> | 2015-01-18 10:22:59 +0000 |
commit | cfcbb286712ae392689e7cd1a640b57b611dd277 (patch) | |
tree | c41ab4705bb0b790da02bc8b29768b5879543474 /file.c | |
parent | c60fb3038e4a449c5488a32574d838a6599cb33f (diff) |
Clean up ftype-conversion and dfilter error message string handling.
Have dfilter_compile() take an additional gchar ** argument, pointing to
a gchar * item that, on error, gets set to point to a g_malloc()ed error
string. That removes one bit of global state from the display filter
parser, and doesn't impose a fixed limit on the error message strings.
Have fvalue_from_string() and fvalue_from_unparsed() take a gchar **
argument, pointer to a gchar * item, rather than an error-reporting
function, and set the gchar * item to point to a g_malloc()ed error
string on an error.
Allow either gchar ** argument to be null; if the argument is null, no
error message is allocated or provided.
Change-Id: Ibd36b8aaa9bf4234aa6efa1e7fb95f7037493b4c
Reviewed-on: https://code.wireshark.org/review/6608
Reviewed-by: Guy Harris <guy@alum.mit.edu>
Diffstat (limited to 'file.c')
-rw-r--r-- | file.c | 16 |
1 files changed, 9 insertions, 7 deletions
@@ -546,7 +546,7 @@ cf_read(capture_file *cf, gboolean reloading) * We assume this will not fail since cf->dfilter is only set in * cf_filter IFF the filter was valid. */ - compiled = dfilter_compile(cf->dfilter, &dfcode); + compiled = dfilter_compile(cf->dfilter, &dfcode, NULL); g_assert(!cf->dfilter || (compiled && dfcode)); /* Get the union of the flags for all tap listeners. */ @@ -793,7 +793,7 @@ cf_continue_tail(capture_file *cf, volatile int to_read, int *err) * We assume this will not fail since cf->dfilter is only set in * cf_filter IFF the filter was valid. */ - compiled = dfilter_compile(cf->dfilter, &dfcode); + compiled = dfilter_compile(cf->dfilter, &dfcode, NULL); g_assert(!cf->dfilter || (compiled && dfcode)); /* Get the union of the flags for all tap listeners. */ @@ -920,7 +920,7 @@ cf_finish_tail(capture_file *cf, int *err) * We assume this will not fail since cf->dfilter is only set in * cf_filter IFF the filter was valid. */ - compiled = dfilter_compile(cf->dfilter, &dfcode); + compiled = dfilter_compile(cf->dfilter, &dfcode, NULL); g_assert(!cf->dfilter || (compiled && dfcode)); /* Get the union of the flags for all tap listeners. */ @@ -1652,6 +1652,7 @@ cf_filter_packets(capture_file *cf, gchar *dftext, gboolean force) const char *filter_new = dftext ? dftext : ""; const char *filter_old = cf->dfilter ? cf->dfilter : ""; dfilter_t *dfcode; + gchar *err_msg; GTimeVal start_time; /* if new filter equals old one, do nothing unless told to do so */ @@ -1671,12 +1672,13 @@ cf_filter_packets(capture_file *cf, gchar *dftext, gboolean force) * and try to compile it. */ dftext = g_strdup(dftext); - if (!dfilter_compile(dftext, &dfcode)) { + if (!dfilter_compile(dftext, &dfcode, &err_msg)) { /* The attempt failed; report an error. */ simple_message_box(ESD_TYPE_ERROR, NULL, "See the help for a description of the display filter syntax.", "\"%s\" isn't a valid display filter: %s", - dftext, dfilter_error_msg); + dftext, err_msg); + g_free(err_msg); g_free(dftext); return CF_ERROR; } @@ -1819,7 +1821,7 @@ rescan_packets(capture_file *cf, const char *action, const char *action_item, gb * We assume this will not fail since cf->dfilter is only set in * cf_filter IFF the filter was valid. */ - compiled = dfilter_compile(cf->dfilter, &dfcode); + compiled = dfilter_compile(cf->dfilter, &dfcode, NULL); g_assert(!cf->dfilter || (compiled && dfcode)); /* Get the union of the flags for all tap listeners. */ @@ -3447,7 +3449,7 @@ cf_find_packet_dfilter_string(capture_file *cf, const char *filter, dfilter_t *sfcode; gboolean result; - if (!dfilter_compile(filter, &sfcode)) { + if (!dfilter_compile(filter, &sfcode, NULL)) { /* * XXX - this shouldn't happen, as the filter string is machine * generated |