Skip to content

Avoid conditional compilation on whether tracing is enabled #914

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

Merged
merged 2 commits into from
Dec 15, 2021

Conversation

vector-of-bool
Copy link
Contributor

Macros that discard their arguments under certain configurations can lead to missed refactors and unknowingly breaking code. This changeset changes conditional tracing to use C-language-level conditions rather than preprocessor conditions.

Copy link
Contributor

@eramongodb eramongodb left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I assume these changes suggest the runtime impact of disabled tracing utilities is not significant enough to justify their conditional compile-time compilation and corresponding maintenance burden. It seems like the compilers are also gracious enough not to warn about the always true/false conditions predecated on MONGOC_TRACE_ENABLED. LGTM.

Copy link
Contributor

@chardan chardan left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

+1, LGTM!

@@ -85,10 +103,8 @@ mongoc_log (mongoc_log_level_t log_level,
bson_once (&once, &_mongoc_ensure_mutex_once);

stop_logging = !gLogFunc;
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Should this check be combined into _mongoc_log_trace_is_enabled()?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Unsure. I left the logic as close to the original as possible.

@vector-of-bool vector-of-bool merged commit 59aeacb into mongodb:master Dec 15, 2021
@vector-of-bool vector-of-bool deleted the log-macro-cleanup branch December 15, 2021 00:38
*/
#define MONGOC_TRACE @MONGOC_TRACE@
#cmakedefine01 MONGOC_TRACE
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This unexpectedly broke PHPC's build system (autotools). I've reported CDRIVER-4247 to request a more portable approach.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Resolved in #917.

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

Successfully merging this pull request may close these issues.

5 participants