From f613d45f78c96c290a1d63d4a2c3f28385d90d42 Mon Sep 17 00:00:00 2001 From: Jim Klimov Date: Mon, 27 Nov 2017 09:14:34 +0100 Subject: [PATCH] Problem: nutscan_init() called before debug is enabled Solution: Move the call to this stateless function to the point after we parse arguments and just before we'd start the actual scans. Later this can be extended to also consider which scans were requested and so which libs to load. Thanks to @clepple for research in https://github.com/networkupstools/nut/issues/500 Signed-off-by: Jim Klimov --- tools/nut-scanner/nut-scanner.c | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/tools/nut-scanner/nut-scanner.c b/tools/nut-scanner/nut-scanner.c index 0e65fdf957..9fea9276c4 100644 --- a/tools/nut-scanner/nut-scanner.c +++ b/tools/nut-scanner/nut-scanner.c @@ -246,8 +246,6 @@ int main(int argc, char *argv[]) xml_sec.usec_timeout = -1; /* Override with the "timeout" common setting later */ xml_sec.peername = NULL; - nutscan_init(); - display_func = nutscan_display_ups_conf; /* Note: the getopts print an error message about unknown arguments @@ -468,6 +466,12 @@ int main(int argc, char *argv[]) /* BEWARE: allow_all does not include allow_eaton_serial! */ } + /* TODO: nutscan_init() should consider (via args? shared global vars?) + * which scan types we desire at this run, and not try to load irrelevant + * libraries. + */ + nutscan_init(); + /* TODO/discuss : Should the #else...#endif code below for lack of pthreads * during build also serve as a fallback for pthread failure at runtime? */