diff --git a/lib/utils.c b/lib/utils.c index b591f72..b5b457a 100644 --- a/lib/utils.c +++ b/lib/utils.c @@ -28,8 +28,16 @@ struct nl_dump_params nl_debug_dp = { .dp_type = NL_DUMP_FULL, }; -static void __init nl_debug_dp_init(void) +static void __init nl_debug_init(void) { + char *nldbg, *end; + + if ((nldbg = getenv("NLDBG"))) { + long level = strtol(nldbg, &end, 0); + if (nldbg != end) + nl_debug = level; + } + nl_debug_dp.dp_fd = stderr; } diff --git a/src/utils.c b/src/utils.c index 308aacb..b3a11a1 100644 --- a/src/utils.c +++ b/src/utils.c @@ -18,7 +18,6 @@ static struct nl_cb *nltool_cb; int nltool_init(int argc, char *argv[]) { char *nlcb = getenv("NLCB"); - char *nldbg = getenv("NLDBG"); int cbset = NL_CB_VERBOSE; if (nlcb) { @@ -41,17 +40,6 @@ int nltool_init(int argc, char *argv[]) goto errout; } - if (nldbg) { - long dbg = strtol(nldbg, NULL, 0); - - if (dbg == LONG_MIN || dbg == LONG_MAX) { - fprintf(stderr, "Invalid value for NLDBG.\n"); - goto errout; - } - - nl_debug = dbg; - } - return 0; errout: