aboutsummaryrefslogtreecommitdiffstats
path: root/rawshark.c
diff options
context:
space:
mode:
authorJoão Valverde <j@v6e.pt>2022-11-19 19:21:19 +0000
committerJoão Valverde <j@v6e.pt>2022-11-28 15:46:44 +0000
commita0d77e93298ab2e62600ec835099691b37fce69b (patch)
treec364f785b543b432a906d9d0779362114026ec2e /rawshark.c
parentb4196ab772bd80f0bd95981fa4e70e884bfb8937 (diff)
dfilter: Return an error object instead of string
Return an struct containing error information. This simplifies the interface to more easily provide richer diagnostics in the future. Add an error code besides a human-readable error string to allow checking programmatically for errors in a robust manner. Currently there is only a generic error code, it is expected to increase in the future. Move error location information to the struct. Change callers and implementation to use the new interface.
Diffstat (limited to 'rawshark.c')
-rw-r--r--rawshark.c7
1 files changed, 4 insertions, 3 deletions
diff --git a/rawshark.c b/rawshark.c
index 99ca32c556..ed4fa4b9a4 100644
--- a/rawshark.c
+++ b/rawshark.c
@@ -398,6 +398,7 @@ main(int argc, char *argv[])
{
char *err_msg;
int opt, i;
+ df_error_t *df_err;
#ifndef _WIN32
struct rlimit limit;
@@ -759,9 +760,9 @@ main(int argc, char *argv[])
if (n_rfilters != 0) {
for (i = 0; i < n_rfilters; i++) {
- if (!dfilter_compile(rfilters[i], &rfcodes[n_rfcodes], &err_msg)) {
- cmdarg_err("%s", err_msg);
- g_free(err_msg);
+ if (!dfilter_compile(rfilters[i], &rfcodes[n_rfcodes], &df_err)) {
+ cmdarg_err("%s", df_err->msg);
+ dfilter_error_free(df_err);
ret = INVALID_DFILTER;
goto clean_exit;
}