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

Enable various C++ build-time warnings and treat them as errors #340

Merged

Conversation

pentschev
Copy link
Member

@pentschev pentschev commented Nov 29, 2024

Enable various C++ build-time warnings to improve code quality and treat them as errors moving forward. Additionally fix all of those entries that are now considered warnings.

Copy link

copy-pr-bot bot commented Nov 29, 2024

Auto-sync is disabled for draft pull requests in this repository. Workflows must be run manually.

Contributors can view more details about this message here.

@pentschev
Copy link
Member Author

/ok to test

@@ -56,7 +56,7 @@ set(UCXX_BUILD_TESTS ${BUILD_TESTS})
set(UCXX_BUILD_BENCHMARKS ${BUILD_BENCHMARKS})
set(UCXX_BUILD_EXAMPLES ${BUILD_EXAMPLES})

set(UCXX_CXX_FLAGS "")
set(UCXX_CXX_FLAGS "-Wall" "-Wattributes" "-Werror")
Copy link
Contributor

Choose a reason for hiding this comment

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

Other things that might be worthwhile adding -Wextra, -Wsign-conversion.

Copy link
Member Author

Choose a reason for hiding this comment

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

Thanks Lawrence for the suggestions. I've extended those in ba26e7e . Additionally I added -Wno-missing-field-initializers this is because we otherwise hit those warnings when initializing many of the UCP structures where we don't (and probably shouldn't, at least not in all cases) fill those values. Alternatively we could use #pragmas to filter them out, but I'm not sure if it's worth it. If you have other better ideas please let me know as well.

@pentschev pentschev changed the title Enable -Wall -Wattributes -Werror in C++ build Enable various C++ build-time warnings and treat them as errors Nov 29, 2024
@pentschev pentschev marked this pull request as ready for review November 29, 2024 13:26
@pentschev pentschev requested review from a team as code owners November 29, 2024 13:26
Copy link
Contributor

@vyasr vyasr left a comment

Choose a reason for hiding this comment

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

LGTM.

@@ -56,7 +56,7 @@ set(UCXX_BUILD_TESTS ${BUILD_TESTS})
set(UCXX_BUILD_BENCHMARKS ${BUILD_BENCHMARKS})
set(UCXX_BUILD_EXAMPLES ${BUILD_EXAMPLES})

set(UCXX_CXX_FLAGS "")
set(UCXX_CXX_FLAGS "-Wall" "-Wattributes" "-Werror" "-Wextra" "-Wsign-conversion" "-Wno-missing-field-initializers")
Copy link
Contributor

Choose a reason for hiding this comment

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

You shouldn't need all the quotes here.

Copy link
Member Author

Choose a reason for hiding this comment

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

Thanks for the hint, removed in f974f2c .

@@ -145,11 +145,11 @@ RequestAm::RequestAm(std::shared_ptr<Component> endpointOrWorker,
callbackData)
{
std::visit(data::dispatch{
[this](data::AmSend amSend) {
[this](data::AmSend) {
Copy link
Contributor

Choose a reason for hiding this comment

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

It seems like there are multiple cases where you dispatch to an empty functor, maybe that should be added as a method for simplification?

Copy link
Member Author

Choose a reason for hiding this comment

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

Maybe I'm misunderstanding your suggestion, but the empty functors are not (necessarily) exactly the same, their signature changes with the argument type which is used to match the dispatcher, so I don't think this is possible.

Copy link
Contributor

Choose a reason for hiding this comment

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

You're right, never mind. What was confusing me is that you're using a visitor pattern where none of the arms actually use the input object (both here and in other parts of this PR), so it looks like you don't need the input object at all, but in fact you do need it for the dispatch itself to be done so you can't drop the function parameter.

Copy link
Member Author

Choose a reason for hiding this comment

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

You nailed it, that's exactly why we need it regardless of whether we use it or not, the type carries at a minimum the meaning of the kind of transfer the request will perform.

{
THROW_FUTURE_NOT_IMPLEMENTED();
}
RequestNotifierWaitState Worker::waitRequestNotifier(uint64_t) { THROW_FUTURE_NOT_IMPLEMENTED(); }
Copy link
Member Author

Choose a reason for hiding this comment

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

Workaround for cpplint/cpplint#131 .

@pentschev
Copy link
Member Author

Thanks @wence- and @vyasr !

@pentschev
Copy link
Member Author

/merge

@rapids-bot rapids-bot bot merged commit 8621e47 into rapidsai:branch-0.42 Dec 19, 2024
68 checks passed
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.

3 participants