Make the build work with -Wformat=2#2088
Conversation
The -Wformat=2 macro requires every format string either be a string
literal, or a parameter that was tagged with the format attribute. The
upshot is that it expects every printf function to be marked, or you get
warnings like this:
src/console_reporter.cc:104:23: error: format string is not a string literal [-Werror,-Wformat-nonliteral]
104 | out << FormatString(fmt, args);
| ^~~
Marking such things is generally worthwhile since it turns on
error-checking within the library, so fill in the missing ones.
Tested with:
bazelisk build --copt=-Werror --copt=-Wformat=2 :all
|
Should this diagnostic be enabled in CMake build then, otherwise things can regress back? |
|
Figured I'd defer to the project maintainers on that. I noticed this because we set this diagnostic in BoringSSL and (for now, but I'm considering changing this) the way we set our diagnostics hits dependencies. But I think this PR makes sense to merge either way, so I figure that can be a separate decision. |
That was the gist of my comment, yes. Aka, let's enable it or it will break again.
|
|
Added to CMake and Bazel builds. |
|
lovely. thank you. |
The -Wformat=2 macro requires every format string either be a string literal, or a parameter that was tagged with the format attribute. The upshot is that it expects every printf function to be marked, or you get warnings like this:
Marking such things is generally worthwhile since it turns on error-checking within the library, so fill in the missing ones.
Tested with: