src: use printf() instead of pr_debug() whenever possible
Pablo Neira Ayuso
maintainerPATCH 1/1 src: use printf() instead of pr_debug() whenever possible
pr_debug() is disabled with --with-mini-gmp since it relies on the gmp_printf(), which is not available in the mini-gmp implementation. Use printf() instead of pr_debug() if no mpz_t types are used, so we get debugging information for proto-ctx as well.
This leaves the pr_debug() usage limited to src/segtree.c.
--- src/netlink_delinearize.c | 2 -- src/proto.c | 14 +++++++------- 2 files changed, 7 insertions(+), 9 deletions(-)
src/netlink_delinearize.c +0 -2
@@ -915,8 +915,6 @@ static void expr_postprocess(struct rule_pp_ctx *ctx, {struct expr *expr = *exprp, *i; -//pr_debug("%s len %u\n", expr->ops->name, expr->len); -switch (expr->ops->type) {case EXPR_MAP :expr_postprocess (ctx, stmt, &expr->map);
src/proto.c +7 -7
@@ -137,15 +137,15 @@ static void proto_ctx_debug(const struct proto_ctx *ctx, enum proto_bases base)if (!(debug_level &DEBUG_PROTO_CTX ))return ; -pr_debug ("update %s protocol context:\n" , proto_base_names[base]); +printf ("update %s protocol context:\n" , proto_base_names[base]);for (i =PROTO_BASE_LL_HDR ; i <=PROTO_BASE_MAX ; i++) { -pr_debug (" %-20s: %s%s\n" , - proto_base_names[i], - ctx->protocol[i].desc ? ctx->protocol[i].desc->name : -"none" , - i == base ?" <-" :"" ); +printf (" %-20s: %s%s\n" , + proto_base_names[i], + ctx->protocol[i].desc ? ctx->protocol[i].desc->name : +"none" , + i == base ?" <-" :"" ); } -pr_debug ("\n" ); +printf ("\n" );#endif }
Signature · 1 line
1.7.10.4
Quoted 6 lines · Pablo Neira Ayuso
pr_debug()is disabled with --with-mini-gmp since it relies on thegmp_printf(), which is not available in the mini-gmp implementation. Useprintf()instead ofpr_debug()if nompz_ttypes are used, so we get debugging information for proto-ctx as well.This leaves the
pr_debug()usage limited tosrc/segtree.c.
I don't think this patch is conceptually good. The intention of pr_debug() is to be able to disable debugging at compile time to avoid ifdefs everywhere.
We currently need them for external debugging functions like mnl, but f.i. in proto_ctx_debug() the compiler should very well be able to determine that the function is a NOP without debugging enabled.
I'd rather change pr_debug to a normal printf and adapt segtree to use a pr_gmp_debug or something like that.
Pablo Neira Ayuso
maintainerQuoted 2 lines · Patrick McHardy
I'd rather change
pr_debugto a normal printf and adapt segtree to use apr_gmp_debugor something like that.
Good idea, patch will follow up soon. Thanks Patrick.