Fix missing colmap namespace in file macro.#4159
Conversation
Summary of ChangesHello, I'm Gemini Code Assist1! I'm currently reviewing this pull request and will post my feedback shortly. In the meantime, here's a summary to help you and other reviewers quickly get up to speed! This pull request resolves a regression by reintroducing explicit namespace qualifications for several file utility functions within their respective Highlights
Changelog
Activity
Using Gemini Code AssistThe full guide for Gemini Code Assist can be found on our documentation page, here are some quick tips. Invoking Gemini You can request assistance from Gemini at any point by creating a comment using either
Customization To customize Gemini Code Assist for GitHub experience, repository maintainers can create a configuration file and/or provide a custom code review style guide (such as PEP-8 for Python) by creating and adding files to a Limitations & Feedback Gemini Code Assist may make mistakes. Please leave feedback on any instances where its feedback is incorrect or counter productive. You can react with 👍 and 👎 on @gemini-code-assist comments. If you're interested in giving your feedback about your experience with Gemini Code Assist for Github and other Google products, sign up here. You can also get AI-powered code generation, chat, as well as code reviews directly in the IDE at no cost with the Gemini Code Assist IDE Extension. Footnotes
|
There was a problem hiding this comment.
Code Review
This pull request correctly adds the colmap:: namespace qualifier to function calls within macros in file.h, fixing a regression that could cause compilation errors. My review also identified a potential issue in the modified macros where arguments can be evaluated multiple times, which could lead to subtle bugs. The comments detailing these issues have been retained as they do not conflict with any provided rules.
| #define THROW_CHECK_FILE_EXISTS(path) \ | ||
| THROW_CHECK(colmap::ExistsFile(path)) \ | ||
| << "File " << (path) << " does not exist." |
There was a problem hiding this comment.
The macro argument path is evaluated twice: once in colmap::ExistsFile(path) and again in the stream output << (path). This can lead to incorrect behavior or performance degradation if an expression with side effects or an expensive function call is passed as path. This is a common pitfall with function-like macros, and a safer implementation would evaluate the argument only once.
| #define THROW_CHECK_DIR_EXISTS(path) \ | ||
| THROW_CHECK(colmap::ExistsDir(path)) \ | ||
| << "Directory " << (path) << " does not exist." |
There was a problem hiding this comment.
The macro argument path is evaluated twice: once in colmap::ExistsDir(path) and again in the stream output << (path). This can lead to incorrect behavior or performance degradation if an expression with side effects or an expensive function call is passed as path. This is a common pitfall with function-like macros, and a safer implementation would evaluate the argument only once.
| #define THROW_CHECK_HAS_FILE_EXTENSION(path, ext) \ | ||
| THROW_CHECK(HasFileExtension(path, ext)) \ | ||
| THROW_CHECK(colmap::HasFileExtension(path, ext)) \ | ||
| << "Path " << (path) << " does not match file extension " << (ext) \ | ||
| << "." |
There was a problem hiding this comment.
The macro arguments path and ext are evaluated twice. For example, path is used in colmap::HasFileExtension(path, ext) and again in << (path). This can lead to incorrect behavior or performance degradation if expressions with side effects or expensive function calls are passed as arguments. This is a common pitfall with function-like macros, and a safer implementation would evaluate arguments only once.
|
The Gemini comments are valid. I guess we could do |
Already addressed in #3770, but somehow regressed in #4058