Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

nut-scanner: nutscan_init() called before nut_debug_level is set; library scan messages are hidden #500

Closed
clepple opened this issue Nov 26, 2017 · 0 comments
Assignees
Milestone

Comments

@clepple
Copy link
Member

clepple commented Nov 26, 2017

nut_debug_level starts out as 0, but the -D flags are not parsed until after nutscan_init() is called. Therefore, it is not possible to see the debug messages when searching for libraries.

Tested with https://github.com/networkupstools/nut/tree/libusb-1.0%2B0.1 @ 80bc452.

Noticed while debugging #499.

@clepple clepple added the bug label Nov 26, 2017
jimklimov added a commit to jimklimov/nut that referenced this issue Nov 27, 2017
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 networkupstools#500

Signed-off-by: Jim Klimov <[email protected]>
@jimklimov jimklimov self-assigned this Nov 27, 2017
clepple added a commit that referenced this issue Dec 3, 2017
Closes: #300

Notable commits from master:

 * Documentation
 * statepath environment variables (#473 / #507)
 * nut-scanner (issue #500 / pull #502)
 * Fix one parallel build problem (#418)
 * Compute output load if not provided (#484)
@clepple clepple added this to the 2.7.5 milestone Dec 3, 2017
zykh added a commit to zykh/nut that referenced this issue Mar 16, 2018
In order to have early the value of the desired debug level (needed to correctly debug nutscan_init()), split the parsing of command line options into two loops:
- the first one, before the call to nutscan_init(), will only care about debug level,
- the second one, after the call to nutscan_init(), will consider the remaining (and possibly depending on a nutscan_avail_* var already initialized by nutscan_init()) arguments (and moan in case of errors).

Closes networkupstools#500
aquette pushed a commit that referenced this issue Jul 31, 2018
…tions (#541)

* Revert "Problem: nutscan_init() called before debug is enabled"

This reverts commit f613d45.

When parsing the command line (or showing help), many options rely on a nutscan_avail_* var already initialized by nutscan_init() -- moving that call after the parsing of opts renders those options unavailable.

* nutscanner: parse debug level opts separately before anything else

In order to have early the value of the desired debug level (needed to correctly debug nutscan_init()), split the parsing of command line options into two loops:
- the first one, before the call to nutscan_init(), will only care about debug level,
- the second one, after the call to nutscan_init(), will consider the remaining (and possibly depending on a nutscan_avail_* var already initialized by nutscan_init()) arguments (and moan in case of errors).

Closes #500
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants