diff options
author | João Valverde <j@v6e.pt> | 2022-11-19 19:21:19 +0000 |
---|---|---|
committer | João Valverde <j@v6e.pt> | 2022-11-28 15:46:44 +0000 |
commit | a0d77e93298ab2e62600ec835099691b37fce69b (patch) | |
tree | c364f785b543b432a906d9d0779362114026ec2e /tshark.c | |
parent | b4196ab772bd80f0bd95981fa4e70e884bfb8937 (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 'tshark.c')
-rw-r--r-- | tshark.c | 13 |
1 files changed, 7 insertions, 6 deletions
@@ -614,8 +614,8 @@ static gboolean _compile_dfilter(const char *text, dfilter_t **dfp, const char *caller) { gboolean ok; - dfilter_loc_t err_loc; char *err_msg = NULL; + df_error_t *df_err; char *err_off; char *expanded; @@ -626,16 +626,17 @@ _compile_dfilter(const char *text, dfilter_t **dfp, const char *caller) return FALSE; } - ok = dfilter_compile_real(expanded, dfp, &err_msg, &err_loc, caller, FALSE, FALSE); + ok = dfilter_compile_real(expanded, dfp, &df_err, caller, FALSE, FALSE); if (!ok ) { - cmdarg_err("%s", err_msg); - g_free(err_msg); - if (err_loc.col_start >= 0) { - err_off = ws_strdup_underline(NULL, err_loc.col_start, err_loc.col_len); + cmdarg_err("%s", df_err->msg); + + if (df_err->loc.col_start >= 0) { + err_off = ws_strdup_underline(NULL, df_err->loc.col_start, df_err->loc.col_len); cmdarg_err_cont(" %s", expanded); cmdarg_err_cont(" %s", err_off); g_free(err_off); } + dfilter_error_free(df_err); } g_free(expanded); |