diff options
Diffstat (limited to 'src')
-rw-r--r-- | src/evaluate.c | 8 | ||||
-rw-r--r-- | src/main.c | 10 | ||||
-rw-r--r-- | src/mnl.c | 8 | ||||
-rw-r--r-- | src/netlink.c | 14 | ||||
-rw-r--r-- | src/parser_bison.y | 2 | ||||
-rw-r--r-- | src/proto.c | 2 | ||||
-rw-r--r-- | src/segtree.c | 3 |
7 files changed, 1 insertions, 46 deletions
diff --git a/src/evaluate.c b/src/evaluate.c index 3989d5e3..e3c8e1dc 100644 --- a/src/evaluate.c +++ b/src/evaluate.c @@ -1708,7 +1708,6 @@ static int expr_evaluate_meta(struct eval_ctx *ctx, struct expr **exprp) static int expr_evaluate(struct eval_ctx *ctx, struct expr **expr) { -#ifdef DEBUG if (debug_level & DEBUG_EVALUATION) { struct error_record *erec; erec = erec_create(EREC_INFORMATIONAL, &(*expr)->location, @@ -1717,7 +1716,6 @@ static int expr_evaluate(struct eval_ctx *ctx, struct expr **expr) expr_print(*expr, &octx_debug_dummy); printf("\n\n"); } -#endif switch ((*expr)->ops->type) { case EXPR_SYMBOL: @@ -2691,7 +2689,6 @@ static int stmt_evaluate_objref(struct eval_ctx *ctx, struct stmt *stmt) int stmt_evaluate(struct eval_ctx *ctx, struct stmt *stmt) { -#ifdef DEBUG if (debug_level & DEBUG_EVALUATION) { struct error_record *erec; erec = erec_create(EREC_INFORMATIONAL, &stmt->location, @@ -2699,7 +2696,6 @@ int stmt_evaluate(struct eval_ctx *ctx, struct stmt *stmt) erec_print(stdout, erec); stmt_print(stmt, &octx_debug_dummy); printf("\n\n"); } -#endif switch (stmt->ops->type) { case STMT_COUNTER: @@ -3341,7 +3337,6 @@ static int cmd_evaluate_export(struct eval_ctx *ctx, struct cmd *cmd) return cache_update(ctx->nf_sock, ctx->cache, cmd->op, ctx->msgs); } -#ifdef DEBUG static const char *cmd_op_name[] = { [CMD_INVALID] = "invalid", [CMD_ADD] = "add", @@ -3364,11 +3359,9 @@ static const char *cmd_op_to_name(enum cmd_ops op) return cmd_op_name[op]; } -#endif int cmd_evaluate(struct eval_ctx *ctx, struct cmd *cmd) { -#ifdef DEBUG if (debug_level & DEBUG_EVALUATION) { struct error_record *erec; @@ -3376,7 +3369,6 @@ int cmd_evaluate(struct eval_ctx *ctx, struct cmd *cmd) "Evaluate %s", cmd_op_to_name(cmd->op)); erec_print(stdout, erec); printf("\n\n"); } -#endif ctx->cmd = cmd; switch (cmd->op) { @@ -29,9 +29,7 @@ #include <cli.h> static struct nft_ctx nft; -#ifdef DEBUG unsigned int debug_level; -#endif enum opt_vals { OPT_HELP = 'h', @@ -90,13 +88,11 @@ static const struct option options[] = { .val = OPT_INCLUDEPATH, .has_arg = 1, }, -#ifdef DEBUG { .name = "debug", .val = OPT_DEBUG, .has_arg = 1, }, -#endif { .name = "handle", .val = OPT_HANDLE_OUTPUT, @@ -131,14 +127,11 @@ static void show_help(const char *name) " -a, --handle Output rule handle.\n" " -e, --echo Echo what has been added, inserted or replaced.\n" " -I, --includepath <directory> Add <directory> to the paths searched for include files. Default is: %s\n" -#ifdef DEBUG " --debug <level [,level...]> Specify debugging level (scanner, parser, eval, netlink, mnl, proto-ctx, segtree, all)\n" -#endif "\n", name, DEFAULT_INCLUDE_PATH); } -#ifdef DEBUG static const struct { const char *name; enum debug_level level; @@ -176,7 +169,6 @@ static const struct { .level = ~0, }, }; -#endif static const struct input_descriptor indesc_cmdline = { .type = INDESC_BUFFER, @@ -359,7 +351,6 @@ int main(int argc, char * const *argv) case OPT_IP2NAME: nft.output.ip2name++; break; -#ifdef DEBUG case OPT_DEBUG: for (;;) { unsigned int i; @@ -387,7 +378,6 @@ int main(int argc, char * const *argv) optarg = end + 1; } break; -#endif case OPT_HANDLE_OUTPUT: nft.output.handle++; break; @@ -72,10 +72,8 @@ nft_mnl_talk(struct mnl_socket *nf_sock, const void *data, { uint32_t portid = mnl_socket_get_portid(nf_sock); -#ifdef DEBUG if (debug_level & DEBUG_MNL) mnl_nlmsg_fprintf(stdout, data, len, sizeof(struct nfgenmsg)); -#endif if (mnl_socket_sendto(nf_sock, data, len) < 0) return -1; @@ -223,14 +221,11 @@ static ssize_t mnl_nft_socket_sendmsg(const struct mnl_socket *nl, .msg_iov = iov, .msg_iovlen = iov_len, }; -#ifdef DEBUG uint32_t i; -#endif mnl_set_sndbuffer(nl, batch); nftnl_batch_iovec(batch, iov, iov_len); -#ifdef DEBUG for (i = 0; i < iov_len; i++) { if (debug_level & DEBUG_MNL) { mnl_nlmsg_fprintf(stdout, @@ -238,7 +233,6 @@ static ssize_t mnl_nft_socket_sendmsg(const struct mnl_socket *nl, sizeof(struct nfgenmsg)); } } -#endif return sendmsg(mnl_socket_get_fd(nl), &msg, 0); } @@ -1072,12 +1066,10 @@ int mnl_nft_event_listener(struct mnl_socket *nf_sock, } } -#ifdef DEBUG if (debug_level & DEBUG_MNL) { mnl_nlmsg_fprintf(stdout, buf, sizeof(buf), sizeof(struct nfgenmsg)); } -#endif /* DEBUG */ ret = mnl_cb_run(buf, ret, 0, 0, cb, cb_data); if (ret <= 0) break; diff --git a/src/netlink.c b/src/netlink.c index f6eb08fd..7730b724 100644 --- a/src/netlink.c +++ b/src/netlink.c @@ -504,7 +504,6 @@ int netlink_del_rule_batch(struct netlink_ctx *ctx, const struct handle *h, void netlink_dump_rule(const struct nftnl_rule *nlr) { -#ifdef DEBUG char buf[4096]; if (!(debug_level & DEBUG_NETLINK)) @@ -512,12 +511,10 @@ void netlink_dump_rule(const struct nftnl_rule *nlr) nftnl_rule_snprintf(buf, sizeof(buf), nlr, 0, 0); fprintf(stdout, "%s\n", buf); -#endif } void netlink_dump_expr(const struct nftnl_expr *nle) { -#ifdef DEBUG char buf[4096]; if (!(debug_level & DEBUG_NETLINK)) @@ -525,7 +522,6 @@ void netlink_dump_expr(const struct nftnl_expr *nle) nftnl_expr_snprintf(buf, sizeof(buf), nle, 0, 0); fprintf(stdout, "%s\n", buf); -#endif } static int list_rule_cb(struct nftnl_rule *nlr, void *arg) @@ -579,7 +575,6 @@ static int netlink_flush_rules(struct netlink_ctx *ctx, const struct handle *h, void netlink_dump_chain(const struct nftnl_chain *nlc) { -#ifdef DEBUG char buf[4096]; if (!(debug_level & DEBUG_NETLINK)) @@ -587,7 +582,6 @@ void netlink_dump_chain(const struct nftnl_chain *nlc) nftnl_chain_snprintf(buf, sizeof(buf), nlc, 0, 0); fprintf(stdout, "%s\n", buf); -#endif } static int netlink_add_chain_compat(struct netlink_ctx *ctx, @@ -1036,7 +1030,6 @@ static const struct datatype *dtype_map_from_kernel(enum nft_data_types type) void netlink_dump_set(const struct nftnl_set *nls) { -#ifdef DEBUG char buf[4096]; if (!(debug_level & DEBUG_NETLINK)) @@ -1044,7 +1037,6 @@ void netlink_dump_set(const struct nftnl_set *nls) nftnl_set_snprintf(buf, sizeof(buf), nls, 0, 0); fprintf(stdout, "%s\n", buf); -#endif } static int set_parse_udata_cb(const struct nftnl_udata *attr, void *data) @@ -1661,7 +1653,6 @@ out: void netlink_dump_obj(struct nftnl_obj *nln) { -#ifdef DEBUG char buf[4096]; if (!(debug_level & DEBUG_NETLINK)) @@ -1669,7 +1660,6 @@ void netlink_dump_obj(struct nftnl_obj *nln) nftnl_obj_snprintf(buf, sizeof(buf), nln, 0, 0); fprintf(stdout, "%s\n", buf); -#endif } int netlink_add_obj(struct netlink_ctx *ctx, const struct handle *h, @@ -2854,7 +2844,6 @@ static int netlink_events_trace_cb(const struct nlmsghdr *nlh, int type, return MNL_CB_OK; } -#ifdef DEBUG /* only those which could be useful listening to events */ static const char *const nftnl_msg_types[NFT_MSG_MAX] = { [NFT_MSG_NEWTABLE] = "NFT_MSG_NEWTABLE", @@ -2880,16 +2869,13 @@ static const char *nftnl_msgtype2str(uint16_t type) return nftnl_msg_types[type]; } -#endif /* DEBUG */ static void netlink_events_debug(uint16_t type) { -#ifdef DEBUG if (!(debug_level & DEBUG_NETLINK)) return; printf("netlink event: %s\n", nftnl_msgtype2str(type)); -#endif /* DEBUG */ } static int netlink_events_newgen_cb(const struct nlmsghdr *nlh, int type, diff --git a/src/parser_bison.y b/src/parser_bison.y index a187d098..c2fd67de 100644 --- a/src/parser_bison.y +++ b/src/parser_bison.y @@ -118,12 +118,10 @@ static void location_update(struct location *loc, struct location *rhs, int n) %initial-action { location_init(scanner, state, &yylloc); -#ifdef DEBUG if (debug_level & DEBUG_SCANNER) nft_set_debug(1, scanner); if (debug_level & DEBUG_PARSER) yydebug = 1; -#endif } %union { diff --git a/src/proto.c b/src/proto.c index 7ac0ee03..045f2d81 100644 --- a/src/proto.c +++ b/src/proto.c @@ -140,7 +140,6 @@ const struct hook_proto_desc hook_proto_desc[] = { static void proto_ctx_debug(const struct proto_ctx *ctx, enum proto_bases base) { -#ifdef DEBUG unsigned int i; if (!(debug_level & DEBUG_PROTO_CTX)) @@ -159,7 +158,6 @@ static void proto_ctx_debug(const struct proto_ctx *ctx, enum proto_bases base) pr_debug("\n"); } pr_debug("\n"); -#endif } /** diff --git a/src/segtree.c b/src/segtree.c index 34a00161..8623e862 100644 --- a/src/segtree.c +++ b/src/segtree.c @@ -163,10 +163,9 @@ static void __ei_insert(struct seg_tree *tree, struct elementary_interval *new) static bool segtree_debug(void) { -#ifdef DEBUG if (debug_level & DEBUG_SEGTREE) return true; -#endif + return false; } |