forked from apache/pulsar
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[Issue 11632][C++] Turning on more compiler warnings, and enforcing w…
…arnings as errors (apache#11668) * [C++] Turning on more compiler warning flags, and enforcing warnings as errors. This change enables several key warning flags that prevent common mistakes in C++: -Wall -Wformat-security and -Wvla, as well as ensuring the code won't build if it contains warnings. This will help to keep the code base clean and stable long term. I was also planning to enable "-Wextra" as it contains several helpful warnings, but I thought the changes required to get -Wall enabled were getting a bit huge as-is, so I'm going to split that effort into two PRs. Most of the changes fall into four categories: * The vast majority are fixing class member initialization order warnings. These can lead to real bugs and are important to fix. * Next was unused variables or functions - these were mostly found in the tests * Functions with switches on enum values and no default/fallback case resulting in a code path with no return - just needed exception throw statements. * Finally, I also fixed several misuses of the "static" keyword: when applied to global variables or functions, this actually means that the identifier has "internal linkage", meaning it's not accessible outside the current translation unit. Putting this in a header is almost never what you want to do, but it's a common mistake since the meaning is different when applied to class members. The "inline" keyword is a better choice in these circumstances. Tests are still all passing. [C++] Removing some unnecessary variable type changes I meant to remove from the previous commit. I decided to disable the "signed comparison warning" since there are typically tons of these and they're tricky to fix because you have to go through and change all of your integer types to get them to line up right. Most C++ code bases I've worked on in the past also disable this warning. It's too much pain for too little gain. * Fixed more warnings and issues arising from the Release mode build. I had forgotten to build in release the first time, and it revealed more warnings that needed to be addressed. Finally, I formatted everything with clang-format. * [C++] Compiling under clang with -Wall generates a slew of additional warnings, a few of which were quite serious. This commit fixes these. I also reformatted the CMakeLists file to use the newer options syntax and better support clang and GCC side by side. This seems to work with recent GCC and clang versions. Will need to further test with older compilers as well. * Improved support for running tests outside the Docker environment, by allowing a locally installed gtest-parallel to be detected. * Fixed two more unit tests * Tweaking the compiler settings to work under the older compiler versions used in CentOS7 * Applying clang-format * Forgot to actually fix the real unused variable warnings in this file when CRC32 is disabled * Realized that I was running "check-format" with a version of clang-format that was too new, and it was formatting files differently. Probably should add a better check for that at some point, but this change is already getting out of control. * Apparently my attempts to allow gtest-parallel on a non-root path cause problems with the regular build. Reverting them. Also fixing potential mis-use of tar command in the test service start script. Co-authored-by: Matteo Merli <[email protected]>
- Loading branch information
1 parent
bd942e1
commit 4e60de6
Showing
55 changed files
with
177 additions
and
232 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.