From: Arran Cudbard-Bell Date: Fri, 11 Dec 2020 14:52:45 +0000 (-0700) Subject: Strip error pointer from tmpl_preparse X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=b03a3318f08830b73c1fd8ec919336678ef3e58d;p=thirdparty%2Ffreeradius-server.git Strip error pointer from tmpl_preparse --- diff --git a/src/lib/server/cf_file.c b/src/lib/server/cf_file.c index 937aa41948c..5fef9c51df8 100644 --- a/src/lib/server/cf_file.c +++ b/src/lib/server/cf_file.c @@ -796,7 +796,6 @@ static int cf_get_token(CONF_SECTION *parent, char const **ptr_p, fr_token_t *to { char const *ptr = *ptr_p; ssize_t slen; - char const *error; char const *out; size_t outlen; @@ -807,14 +806,14 @@ static int cf_get_token(CONF_SECTION *parent, char const **ptr_p, fr_token_t *to * Don't allow casts or regexes. But do allow bare * %{...} expansions. */ - slen = tmpl_preparse(&out, &outlen, ptr, strlen(ptr), token, &error, NULL, false, true); + slen = tmpl_preparse(&out, &outlen, ptr, strlen(ptr), token, NULL, false, true); if (slen <= 0) { char *spaces, *text; fr_canonicalize_error(parent, &spaces, &text, slen, ptr); ERROR("%s[%d]: %s", filename, lineno, text); - ERROR("%s[%d]: %s^ - %s", filename, lineno, spaces, error); + ERROR("%s[%d]: %s^ - %s", filename, lineno, spaces, fr_strerror()); talloc_free(spaces); talloc_free(text); diff --git a/src/lib/server/cond_tokenize.c b/src/lib/server/cond_tokenize.c index 5005038fd4f..66841603032 100644 --- a/src/lib/server/cond_tokenize.c +++ b/src/lib/server/cond_tokenize.c @@ -237,16 +237,6 @@ static bool cond_type_check(fr_cond_t *c, fr_type_t lhs_type) return false; } - -/* - * Less code means less bugs - */ -#define return_P(_x) *error = _x;goto return_p -#define return_0(_x) *error = _x;goto return_0 -#define return_lhs(_x) *error = _x;goto return_lhs -#define return_rhs(_x) *error = _x;goto return_rhs -#define return_SLEN goto return_slen - static ssize_t cond_check_cast(fr_cond_t *c, char const *start, char const *lhs, char const *rhs) { diff --git a/src/lib/server/tmpl.h b/src/lib/server/tmpl.h index 37fd4ccab54..71e453c91b6 100644 --- a/src/lib/server/tmpl.h +++ b/src/lib/server/tmpl.h @@ -1010,9 +1010,9 @@ void tmpl_extents_debug(fr_dlist_head_t *head); /** @} */ ssize_t tmpl_preparse(char const **out, size_t *outlen, char const *in, size_t inlen, - fr_token_t *type, char const **error, + fr_token_t *type, fr_dict_attr_t const **castda, bool require_regex, - bool allow_xlat) CC_HINT(nonnull(1,2,3,5,6)); + bool allow_xlat) CC_HINT(nonnull(1,2,3,5)); bool tmpl_async_required(tmpl_t const *vpt); diff --git a/src/lib/server/tmpl_tokenize.c b/src/lib/server/tmpl_tokenize.c index e9743810886..692c17eb6c0 100644 --- a/src/lib/server/tmpl_tokenize.c +++ b/src/lib/server/tmpl_tokenize.c @@ -4227,7 +4227,7 @@ void tmpl_verify(char const *file, int line, tmpl_t const *vpt) } #endif -#define return_P(_x) *error = _x;goto return_p +#define return_P(_x) fr_strerror_const(_x);goto return_p /** Preparse a string in preparation for passing it to tmpl_afrom_substr() * @@ -4243,7 +4243,6 @@ void tmpl_verify(char const *file, int line, tmpl_t const *vpt) * @param in where we start looking for the string * @param inlen length of the input string * @param[out] type token type of the string. - * @param[out] error string describing the error * @param[out] castda NULL if casting is not allowed, otherwise the cast * @param require_regex whether or not to require regular expressions * @param allow_xlat whether or not "bare" xlat's are allowed @@ -4252,7 +4251,7 @@ void tmpl_verify(char const *file, int line, tmpl_t const *vpt) * - <=0, -offset in 'start' where the parse error was located */ ssize_t tmpl_preparse(char const **out, size_t *outlen, char const *in, size_t inlen, - fr_token_t *type, char const **error, + fr_token_t *type, fr_dict_attr_t const **castda, bool require_regex, bool allow_xlat) { char const *p = in, *end = in + inlen; @@ -4270,7 +4269,7 @@ ssize_t tmpl_preparse(char const **out, size_t *outlen, char const *in, size_t i char const *q; if (!castda) { - *error = "Unexpected cast"; + fr_strerror_const("Unexpected cast"); return_p: return -(p - in); }