forked from osmocom/wireshark
dfilter: Remove parenthesis deprecation warning
This usage devalues a mechanism for warning users that deserves more attention than this minor suggestion. The warning is inconvenient for intermediate and advanced users.
This commit is contained in:
parent
f401cdeaae
commit
431cb43b81
|
@ -378,6 +378,5 @@ function_params(P) ::= function_params(L) COMMA entity(E).
|
|||
expr(X) ::= LPAREN expr(Y) RPAREN.
|
||||
{
|
||||
X = Y;
|
||||
stnode_set_inside_parens(X, TRUE);
|
||||
}
|
||||
|
||||
|
|
|
@ -1187,7 +1187,7 @@ check_relation_in(dfwork_t *dfw, stnode_t *st_node _U_,
|
|||
static void
|
||||
check_test(dfwork_t *dfw, stnode_t *st_node)
|
||||
{
|
||||
test_op_t st_op, st_arg_op;
|
||||
test_op_t st_op;
|
||||
stnode_t *st_arg1, *st_arg2;
|
||||
|
||||
LOG_NODE(st_node);
|
||||
|
@ -1214,22 +1214,6 @@ check_test(dfwork_t *dfw, stnode_t *st_node)
|
|||
|
||||
case TEST_OP_AND:
|
||||
case TEST_OP_OR:
|
||||
if (stnode_type_id(st_arg1) == STTYPE_TEST) {
|
||||
sttype_test_get(st_arg1, &st_arg_op, NULL, NULL);
|
||||
if (st_arg_op == TEST_OP_AND || st_arg_op == TEST_OP_OR) {
|
||||
if (st_op != st_arg_op && !stnode_inside_parens(st_arg1))
|
||||
add_deprecated_token(dfw, "suggest parentheses around '&&' within '||'");
|
||||
}
|
||||
}
|
||||
|
||||
if (stnode_type_id(st_arg2) == STTYPE_TEST) {
|
||||
sttype_test_get(st_arg2, &st_arg_op, NULL, NULL);
|
||||
if (st_arg_op == TEST_OP_AND || st_arg_op == TEST_OP_OR) {
|
||||
if (st_op != st_arg_op && !stnode_inside_parens(st_arg2))
|
||||
add_deprecated_token(dfw, "suggest parentheses around '&&' within '||'");
|
||||
}
|
||||
}
|
||||
|
||||
semcheck(dfw, st_arg1);
|
||||
semcheck(dfw, st_arg2);
|
||||
break;
|
||||
|
|
|
@ -88,7 +88,6 @@ stnode_clear(stnode_t *node)
|
|||
}
|
||||
|
||||
node->type = NULL;
|
||||
node->flags = 0;
|
||||
node->data = NULL;
|
||||
g_free(node->repr_display);
|
||||
node->repr_display = NULL;
|
||||
|
@ -106,7 +105,6 @@ stnode_init(stnode_t *node, sttype_id_t type_id, gpointer data, char *token)
|
|||
ws_assert_magic(node, STNODE_MAGIC);
|
||||
ws_assert(!node->type);
|
||||
ws_assert(!node->data);
|
||||
node->flags = 0;
|
||||
node->repr_display = NULL;
|
||||
node->repr_debug = NULL;
|
||||
node->repr_token = token;
|
||||
|
@ -133,11 +131,9 @@ stnode_init(stnode_t *node, sttype_id_t type_id, gpointer data, char *token)
|
|||
void
|
||||
stnode_replace(stnode_t *node, sttype_id_t type_id, gpointer data)
|
||||
{
|
||||
uint16_t flags = node->flags; /* Save flags. */
|
||||
char *repr_token = g_strdup(node->repr_token);
|
||||
stnode_clear(node);
|
||||
stnode_init(node, type_id, data, NULL);
|
||||
node->flags = flags;
|
||||
node->repr_token = repr_token;
|
||||
}
|
||||
|
||||
|
@ -197,7 +193,6 @@ stnode_dup(const stnode_t *node)
|
|||
ws_assert_magic(node, STNODE_MAGIC);
|
||||
new = g_new(stnode_t, 1);
|
||||
new->magic = STNODE_MAGIC;
|
||||
new->flags = node->flags;
|
||||
new->repr_display = NULL;
|
||||
new->repr_debug = NULL;
|
||||
new->repr_token = g_strdup(node->repr_token);
|
||||
|
@ -258,23 +253,6 @@ stnode_steal_data(stnode_t *node)
|
|||
return data;
|
||||
}
|
||||
|
||||
gboolean
|
||||
stnode_inside_parens(stnode_t *node)
|
||||
{
|
||||
return node->flags & STNODE_F_INSIDE_PARENS;
|
||||
}
|
||||
|
||||
void
|
||||
stnode_set_inside_parens(stnode_t *node, gboolean inside)
|
||||
{
|
||||
if (inside) {
|
||||
node->flags |= STNODE_F_INSIDE_PARENS;
|
||||
}
|
||||
else {
|
||||
node->flags &= ~STNODE_F_INSIDE_PARENS;
|
||||
}
|
||||
}
|
||||
|
||||
static char *
|
||||
_node_tostr(stnode_t *node, gboolean pretty)
|
||||
{
|
||||
|
@ -338,7 +316,6 @@ sprint_node(stnode_t *node)
|
|||
wmem_strbuf_append_printf(buf, "magic=0x%"PRIx32", ", node->magic);
|
||||
wmem_strbuf_append_printf(buf, "type=%s, ", stnode_type_name(node));
|
||||
wmem_strbuf_append_printf(buf, "data=<%s>, ", stnode_todebug(node));
|
||||
wmem_strbuf_append_printf(buf, "flags=0x%04"PRIx16" }", node->flags);
|
||||
return wmem_strbuf_finalize(buf);
|
||||
}
|
||||
|
||||
|
|
|
@ -75,13 +75,10 @@ typedef struct {
|
|||
STTypeToStrFunc func_tostr;
|
||||
} sttype_t;
|
||||
|
||||
#define STNODE_F_INSIDE_PARENS (1 << 0)
|
||||
|
||||
/** Node (type instance) information */
|
||||
typedef struct {
|
||||
uint32_t magic;
|
||||
sttype_t *type;
|
||||
uint16_t flags;
|
||||
gpointer data;
|
||||
char *repr_token;
|
||||
char *repr_display;
|
||||
|
@ -158,12 +155,6 @@ stnode_tostr(stnode_t *node, gboolean pretty);
|
|||
|
||||
#define stnode_todebug(node) stnode_tostr(node, FALSE)
|
||||
|
||||
gboolean
|
||||
stnode_inside_parens(stnode_t *node);
|
||||
|
||||
void
|
||||
stnode_set_inside_parens(stnode_t *node, gboolean inside);
|
||||
|
||||
void
|
||||
log_node_full(enum ws_log_level level,
|
||||
const char *file, int line, const char *func,
|
||||
|
|
|
@ -81,10 +81,6 @@ class case_syntax(unittest.TestCase):
|
|||
checkDFilterCount(dfilter, 0)
|
||||
|
||||
def test_deprecated_1(self, checkDFilterSucceed):
|
||||
dfilter = "http && udp || tcp"
|
||||
checkDFilterSucceed(dfilter, "suggest parentheses around")
|
||||
|
||||
def test_deprecated_2(self, checkDFilterSucceed):
|
||||
dfilter = "bootp"
|
||||
checkDFilterSucceed(dfilter, "Deprecated tokens: \"bootp\"")
|
||||
|
||||
|
|
Loading…
Reference in New Issue