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 /ui/gtk/funnel_stat.c | |
parent | c60fb3038e4a449c5488a32574d838a6599cb33f (diff) | |
download | wireshark-cfcbb286712ae392689e7cd1a640b57b611dd277.tar.gz |
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 'ui/gtk/funnel_stat.c')
-rw-r--r-- | ui/gtk/funnel_stat.c | 13 |
1 files changed, 6 insertions, 7 deletions
diff --git a/ui/gtk/funnel_stat.c b/ui/gtk/funnel_stat.c index 13bf97a3e6..c61de1bd1f 100644 --- a/ui/gtk/funnel_stat.c +++ b/ui/gtk/funnel_stat.c @@ -486,11 +486,11 @@ static void funnel_retap_packets(void) { cf_retap_packets(&cfile); } -static gboolean funnel_open_file(const char* fname, const char* filter, const char** err_str) { +static gboolean funnel_open_file(const char* fname, const char* filter, char** err_str) { int err = 0; dfilter_t *rfcode = NULL; - *err_str = "no error"; + *err_str = NULL; switch (cfile.state) { case FILE_CLOSED: @@ -498,20 +498,19 @@ static gboolean funnel_open_file(const char* fname, const char* filter, const ch case FILE_READ_ABORTED: break; case FILE_READ_IN_PROGRESS: - *err_str = "file read in progress"; + *err_str = g_strdup("file read in progress"); return FALSE; } if (filter) { - if (!dfilter_compile(filter, &rfcode)) { - *err_str = dfilter_error_msg ? dfilter_error_msg : "cannot compile filter"; + if (!dfilter_compile(filter, &rfcode, err_str)) { return FALSE; } } /* This closes the current file if it succeeds. */ if (cf_open(&cfile, fname, WTAP_TYPE_AUTO, FALSE, &err) != CF_OK) { - *err_str = g_strerror(err); + *err_str = g_strdup(g_strerror(err)); if (rfcode != NULL) dfilter_free(rfcode); return FALSE; } @@ -523,7 +522,7 @@ static gboolean funnel_open_file(const char* fname, const char* filter, const ch case CF_READ_ERROR: break; default: - *err_str = "problem while reading file"; + *err_str = g_strdup("problem while reading file"); return FALSE; } |