CLEANUP: opentracing: added FLT_OT_PARSE_INVALID_enum enum
It's always good to replace "hard-coded" values with something that looks less "hard-coded" (even though that doesn't change anything in the code). This is done here using FLT_OT_PARSE_INVALID_enum enum. This patch must be backported as far as 2.4.
This commit is contained in:
parent
ca09e01a13
commit
854384f400
@ -50,20 +50,20 @@
|
||||
* flt_ot_parse_data definition
|
||||
*/
|
||||
#define FLT_OT_PARSE_TRACER_DEFINES \
|
||||
FLT_OT_PARSE_TRACER_DEF( ID, 0, 1, 2, 2, "ot-tracer", " <name>") \
|
||||
FLT_OT_PARSE_TRACER_DEF( ACL, 0, 1, 3, 0, "acl", " <name> <criterion> [flags] [operator] <value> ...") \
|
||||
FLT_OT_PARSE_TRACER_DEF( LOG, 0, 1, 2, 0, "log", " { global | <addr> [len <len>] [format <fmt>] <facility> [<level> [<minlevel>]] }") \
|
||||
FLT_OT_PARSE_TRACER_DEF( CONFIG, 0, 0, 2, 2, "config", " <file>") \
|
||||
FLT_OT_PARSE_TRACER_DEF( PLUGIN, 0, 0, 2, 2, "plugin", " <file>") \
|
||||
FLT_OT_PARSE_TRACER_DEF( GROUPS, 0, 0, 2, 0, "groups", " <name> ...") \
|
||||
FLT_OT_PARSE_TRACER_DEF( SCOPES, 0, 0, 2, 0, "scopes", " <name> ...") \
|
||||
FLT_OT_PARSE_TRACER_DEF( RATE_LIMIT, 0, 0, 2, 2, "rate-limit", " <value>") \
|
||||
FLT_OT_PARSE_TRACER_DEF( OPTION, 0, 0, 2, 2, "option", " { disabled | dontlog-normal | hard-errors }") \
|
||||
FLT_OT_PARSE_TRACER_DEF(DEBUG_LEVEL, 0, 0, 2, 2, "debug-level", " <value>")
|
||||
FLT_OT_PARSE_TRACER_DEF( ID, 0, CHAR, 2, 2, "ot-tracer", " <name>") \
|
||||
FLT_OT_PARSE_TRACER_DEF( ACL, 0, CHAR, 3, 0, "acl", " <name> <criterion> [flags] [operator] <value> ...") \
|
||||
FLT_OT_PARSE_TRACER_DEF( LOG, 0, CHAR, 2, 0, "log", " { global | <addr> [len <len>] [format <fmt>] <facility> [<level> [<minlevel>]] }") \
|
||||
FLT_OT_PARSE_TRACER_DEF( CONFIG, 0, NONE, 2, 2, "config", " <file>") \
|
||||
FLT_OT_PARSE_TRACER_DEF( PLUGIN, 0, NONE, 2, 2, "plugin", " <file>") \
|
||||
FLT_OT_PARSE_TRACER_DEF( GROUPS, 0, NONE, 2, 0, "groups", " <name> ...") \
|
||||
FLT_OT_PARSE_TRACER_DEF( SCOPES, 0, NONE, 2, 0, "scopes", " <name> ...") \
|
||||
FLT_OT_PARSE_TRACER_DEF( RATE_LIMIT, 0, NONE, 2, 2, "rate-limit", " <value>") \
|
||||
FLT_OT_PARSE_TRACER_DEF( OPTION, 0, NONE, 2, 2, "option", " { disabled | dontlog-normal | hard-errors }") \
|
||||
FLT_OT_PARSE_TRACER_DEF(DEBUG_LEVEL, 0, NONE, 2, 2, "debug-level", " <value>")
|
||||
|
||||
#define FLT_OT_PARSE_GROUP_DEFINES \
|
||||
FLT_OT_PARSE_GROUP_DEF( ID, 0, 1, 2, 2, "ot-group", " <name>") \
|
||||
FLT_OT_PARSE_GROUP_DEF(SCOPES, 0, 0, 2, 0, "scopes", " <name> ...")
|
||||
FLT_OT_PARSE_GROUP_DEF( ID, 0, CHAR, 2, 2, "ot-group", " <name>") \
|
||||
FLT_OT_PARSE_GROUP_DEF(SCOPES, 0, NONE, 2, 0, "scopes", " <name> ...")
|
||||
|
||||
#ifdef USE_OT_VARS
|
||||
# define FLT_OT_PARSE_SCOPE_INJECT_HELP " <name-prefix> [use-vars] [use-headers]"
|
||||
@ -81,16 +81,24 @@
|
||||
* so I will not complicate it here with additional definitions.
|
||||
*/
|
||||
#define FLT_OT_PARSE_SCOPE_DEFINES \
|
||||
FLT_OT_PARSE_SCOPE_DEF( ID, 0, 1, 2, 2, "ot-scope", " <name>") \
|
||||
FLT_OT_PARSE_SCOPE_DEF( SPAN, 0, 0, 2, 5, "span", " <name> [<reference>] [root]") \
|
||||
FLT_OT_PARSE_SCOPE_DEF( TAG, 1, 0, 3, 0, "tag", " <name> <sample> ...") \
|
||||
FLT_OT_PARSE_SCOPE_DEF( LOG, 1, 0, 3, 0, "log", " <name> <sample> ...") \
|
||||
FLT_OT_PARSE_SCOPE_DEF(BAGGAGE, 1, 4, 3, 0, "baggage", " <name> <sample> ...") \
|
||||
FLT_OT_PARSE_SCOPE_DEF( INJECT, 1, 3, 2, 4, "inject", FLT_OT_PARSE_SCOPE_INJECT_HELP) \
|
||||
FLT_OT_PARSE_SCOPE_DEF(EXTRACT, 0, 3, 2, 3, "extract", FLT_OT_PARSE_SCOPE_EXTRACT_HELP) \
|
||||
FLT_OT_PARSE_SCOPE_DEF( FINISH, 0, 0, 2, 0, "finish", " <name> ...") \
|
||||
FLT_OT_PARSE_SCOPE_DEF( ACL, 0, 1, 3, 0, "acl", " <name> <criterion> [flags] [operator] <value> ...") \
|
||||
FLT_OT_PARSE_SCOPE_DEF( EVENT, 0, 0, 2, 0, "event", " <name> [{ if | unless } <condition>]")
|
||||
FLT_OT_PARSE_SCOPE_DEF( ID, 0, CHAR, 2, 2, "ot-scope", " <name>") \
|
||||
FLT_OT_PARSE_SCOPE_DEF( SPAN, 0, NONE, 2, 5, "span", " <name> [<reference>] [root]") \
|
||||
FLT_OT_PARSE_SCOPE_DEF( TAG, 1, NONE, 3, 0, "tag", " <name> <sample> ...") \
|
||||
FLT_OT_PARSE_SCOPE_DEF( LOG, 1, NONE, 3, 0, "log", " <name> <sample> ...") \
|
||||
FLT_OT_PARSE_SCOPE_DEF(BAGGAGE, 1, VAR, 3, 0, "baggage", " <name> <sample> ...") \
|
||||
FLT_OT_PARSE_SCOPE_DEF( INJECT, 1, CTX, 2, 4, "inject", FLT_OT_PARSE_SCOPE_INJECT_HELP) \
|
||||
FLT_OT_PARSE_SCOPE_DEF(EXTRACT, 0, CTX, 2, 3, "extract", FLT_OT_PARSE_SCOPE_EXTRACT_HELP) \
|
||||
FLT_OT_PARSE_SCOPE_DEF( FINISH, 0, NONE, 2, 0, "finish", " <name> ...") \
|
||||
FLT_OT_PARSE_SCOPE_DEF( ACL, 0, CHAR, 3, 0, "acl", " <name> <criterion> [flags] [operator] <value> ...") \
|
||||
FLT_OT_PARSE_SCOPE_DEF( EVENT, 0, NONE, 2, 0, "event", " <name> [{ if | unless } <condition>]")
|
||||
|
||||
enum FLT_OT_PARSE_INVCHAR_enum {
|
||||
FLT_OT_PARSE_INVALID_NONE,
|
||||
FLT_OT_PARSE_INVALID_CHAR,
|
||||
FLT_OT_PARSE_INVALID_DOM,
|
||||
FLT_OT_PARSE_INVALID_CTX,
|
||||
FLT_OT_PARSE_INVALID_VAR,
|
||||
};
|
||||
|
||||
enum FLT_OT_PARSE_TRACER_enum {
|
||||
#define FLT_OT_PARSE_TRACER_DEF(a,b,c,d,e,f,g) FLT_OT_PARSE_TRACER_##a,
|
||||
|
@ -139,16 +139,16 @@ static const char *flt_ot_parse_invalid_char(const char *name, int type)
|
||||
if (!FLT_OT_STR_ISVALID(name))
|
||||
FLT_OT_RETURN_EX(retptr, const char *, "%p");
|
||||
|
||||
if (type == 1) {
|
||||
if (type == FLT_OT_PARSE_INVALID_CHAR) {
|
||||
retptr = invalid_char(name);
|
||||
}
|
||||
else if (type == 2) {
|
||||
else if (type == FLT_OT_PARSE_INVALID_DOM) {
|
||||
retptr = invalid_domainchar(name);
|
||||
}
|
||||
else if (type == 3) {
|
||||
else if (type == FLT_OT_PARSE_INVALID_CTX) {
|
||||
retptr = invalid_prefix_char(name);
|
||||
}
|
||||
else if (type == 4) {
|
||||
else if (type == FLT_OT_PARSE_INVALID_VAR) {
|
||||
retptr = name;
|
||||
|
||||
/*
|
||||
@ -229,7 +229,7 @@ static int flt_ot_parse_cfg_check(const char *file, int linenum, char **args, co
|
||||
FLT_OT_PARSE_ERR(err, "'%s' : too many arguments (use '%s%s')", args[0], (*pdata)->name, (*pdata)->usage);
|
||||
|
||||
/* Checking that the first argument has only allowed characters. */
|
||||
if (!(retval & ERR_CODE) && ((*pdata)->check_name > 0)) {
|
||||
if (!(retval & ERR_CODE) && ((*pdata)->check_name != FLT_OT_PARSE_INVALID_NONE)) {
|
||||
const char *ic;
|
||||
|
||||
ic = flt_ot_parse_invalid_char(args[1], (*pdata)->check_name);
|
||||
@ -460,7 +460,7 @@ static bool flt_ot_parse_check_scope(void)
|
||||
*/
|
||||
static int flt_ot_parse_cfg_tracer(const char *file, int linenum, char **args, int kw_mod)
|
||||
{
|
||||
#define FLT_OT_PARSE_TRACER_DEF(a,b,c,d,e,f,g) { FLT_OT_PARSE_TRACER_##a, b, c, d, e, f, g },
|
||||
#define FLT_OT_PARSE_TRACER_DEF(a,b,c,d,e,f,g) { FLT_OT_PARSE_TRACER_##a, b, FLT_OT_PARSE_INVALID_##c, d, e, f, g },
|
||||
static const struct flt_ot_parse_data parse_data[] = { FLT_OT_PARSE_TRACER_DEFINES };
|
||||
#undef FLT_OT_PARSE_TRACER_DEF
|
||||
const struct flt_ot_parse_data *pdata = NULL;
|
||||
@ -623,7 +623,7 @@ static int flt_ot_post_parse_cfg_tracer(void)
|
||||
*/
|
||||
static int flt_ot_parse_cfg_group(const char *file, int linenum, char **args, int kw_mod)
|
||||
{
|
||||
#define FLT_OT_PARSE_GROUP_DEF(a,b,c,d,e,f,g) { FLT_OT_PARSE_GROUP_##a, b, c, d, e, f, g },
|
||||
#define FLT_OT_PARSE_GROUP_DEF(a,b,c,d,e,f,g) { FLT_OT_PARSE_GROUP_##a, b, FLT_OT_PARSE_INVALID_##c, d, e, f, g },
|
||||
static const struct flt_ot_parse_data parse_data[] = { FLT_OT_PARSE_GROUP_DEFINES };
|
||||
#undef FLT_OT_PARSE_GROUP_DEF
|
||||
const struct flt_ot_parse_data *pdata = NULL;
|
||||
@ -799,7 +799,7 @@ static struct acl_cond *flt_ot_parse_acl(const char *file, int linenum, struct p
|
||||
*/
|
||||
static int flt_ot_parse_cfg_scope(const char *file, int linenum, char **args, int kw_mod)
|
||||
{
|
||||
#define FLT_OT_PARSE_SCOPE_DEF(a,b,c,d,e,f,g) { FLT_OT_PARSE_SCOPE_##a, b, c, d, e, f, g },
|
||||
#define FLT_OT_PARSE_SCOPE_DEF(a,b,c,d,e,f,g) { FLT_OT_PARSE_SCOPE_##a, b, FLT_OT_PARSE_INVALID_##c, d, e, f, g },
|
||||
static const struct flt_ot_parse_data parse_data[] = { FLT_OT_PARSE_SCOPE_DEFINES };
|
||||
#undef FLT_OT_PARSE_SCOPE_DEF
|
||||
const struct flt_ot_parse_data *pdata = NULL;
|
||||
|
Loading…
x
Reference in New Issue
Block a user