-
Notifications
You must be signed in to change notification settings - Fork 272
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
Fix compiler warnings and condition check improvements #390
Conversation
- loglevels.cpp - warns about double return if dynamic logging is on - crashhandler_unix.cpp - warns about unused variable
1. Make the condition check more "C++ intuitive" For example, people may do something like below: ```cpp // log the value if pointer is not null LOG_IF(DEBUG, ptr) << "value: " << ptr->val; ``` This would not work since `ptr != true`, and would possibly confuse them 2. Checking if log level is enabled first. If it's disabled, there's no need to evaluate the expression (which can be expensive)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
1 is reverted
2 I believe it's necessary
@@ -145,17 +145,17 @@ namespace g3 { | |||
|
|||
|
|||
// LOG(level) is the API for the stream log | |||
#define LOG(level) if(!g3::logLevel(level)) {} else INTERNAL_LOG_MESSAGE(level).stream() | |||
#define LOG(level) if (!g3::logLevel(level)) {} else INTERNAL_LOG_MESSAGE(level).stream() |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Format change with my “space” change not yet removed
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is the only place you didn't put a space after an if
.
Are you sure that you want to keep it inconsistent with everywhere else?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
You are right. For this file. Leave this as is. Thanks for calling it out
Fix compiler warnings and condition check improvements (KjellKod#390)
New/modified code must be backed down with unit test - preferably TDD style development)
All new/modified functionality should be backed up with API documentation (API.markdown or README.markdown)
Cross-Platform Testing
Testing Advice
Run Test Alternatives:
ctest
ctest -V
for verbose outputmake test
Fix compiler warnings
Condition check improvements
Make the condition check more "C++ intuitive"(reverted)For example, people may do something like below:
This would not work since
ptr != true
, and would possibly confuse themIf it's disabled, there's no need to evaluate the expression (which can be expensive)