Skip to content

Apply warnings/suggestions reported by clang-tidy v9 #67

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 7 commits into from
Dec 3, 2019

Conversation

marcomagdy
Copy link
Contributor

Clang-tidy version 9 reported a few warnings, and since we treat errors
as warnings we better address them.

I've disabled the trailing-return-type suggestion because I believe it's
ridiculous.

Signed-off-by: Marco Magdy [email protected]

By submitting this pull request, I confirm that my contribution is made under the terms of the Apache 2.0 license.

Clang-tidy version 9 reported a few warnings, and since we treat errors
as warnings we better address them.

I've disabled the trailing-return-type suggestion because I believe it's
ridiculous.

Signed-off-by: Marco Magdy <[email protected]>
Comment on lines +74 to +89
constexpr int space = 0x20; // space (0x20, ' ')
constexpr int form_feed = 0x0c; // form feed (0x0c, '\f')
constexpr int line_feed = 0x0a; // line feed (0x0a, '\n')
constexpr int carriage_return = 0x0d; // carriage return (0x0d, '\r')
constexpr int horizontal_tab = 0x09; // horizontal tab (0x09, '\t')
constexpr int vertical_tab = 0x0b; // vertical tab (0x0b, '\v')
switch (ch) {
case space:
case form_feed:
case line_feed:
case carriage_return:
case horizontal_tab:
case vertical_tab:
return true;
default:
return false;
Copy link
Contributor Author

Choose a reason for hiding this comment

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

isspace has a cloud of UB around it.

The behavior is undefined if the value of ch is not representable as unsigned char and is not equal to EOF.

I'm not sure what "not representable as unsigned char" really means here. So I went ahead and did the simple thing I need to avoid the shenanigans.

src/runtime.cpp Outdated
@@ -276,7 +290,8 @@ runtime::next_outcome runtime::get_next()

if (resp.has_header(DEADLINE_MS_HEADER)) {
auto const& deadline_string = resp.get_header(DEADLINE_MS_HEADER);
unsigned long ms = strtoul(deadline_string.c_str(), nullptr, 10);
constexpr int decimal_radix = 10;

Choose a reason for hiding this comment

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

This one feels stupid. I don't love the magic numbers check (disabled it in all of the CRT libs), but this one just feels extra unnecessary.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Sigh. Yes. You're absolutely right. I hate it.
P.S I rewrote this comment 3 times starting with: "I'm feeling worried about future people working on the project" to "I'm close to nuking it if it complains one more time" to "You're right, screw this"

Choose a reason for hiding this comment

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

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Decided to keep the magic number warning

I was about to remove the constexpr variable and replace the argument
with the hardcoded value with an inline comment and I realized that this
is exactly what the warning/error is about. Documentation/readability.

I was about to remove the constexpr variable and replace the argument
with the hardcoded value with an inline comment and I realized that this
is exactly what the warning/error is about. Documentation/readability.
@marcomagdy marcomagdy merged commit 4e820f9 into master Dec 3, 2019
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.

2 participants