-
-
Notifications
You must be signed in to change notification settings - Fork 1.8k
Feature/cppcheck fixes pt1 #3266
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
base: master
Are you sure you want to change the base?
Conversation
if (input < 0x80) { bytestoWrite = 1; } | ||
else if (input < 0x800) { bytestoWrite = 2; } | ||
else if (input < 0x10000) { bytestoWrite = 3; } | ||
else { assert(input <= 0x0010FFFF); bytestoWrite = 4; } |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I assume it complains when just having an else statement with the assert?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
No, the condition was always guaranteed to be true -- check the rest of the function above. The assert
is something I decided to add to make that obvious to the reader.
{ | ||
assert(channelCount == 2); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I don't particularly like this pattern, as it move the branch condition into the assert and mixes in the body two different concerns: 1) Error checking for the input 2) actual body for the given condition
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It's the same principle as above -- that condition is guaranteed to be true due to previous control flow. The assert makes that obvious to the reader.
This PR is a mixed bag of changes. I like some and don't like others. For the sake of merging some of this stuff ASAP, I'd love all the class initializer list changes in their own PR. I'd happily approve that. We've long since made an effort to move initialization out of the constructor body and into the initializer list if not into the class definition itself. That's an easy win. |
@@ -620,7 +619,7 @@ void Ftp::DataChannel::send(std::istream& stream) | |||
break; | |||
} | |||
|
|||
count = static_cast<std::size_t>(stream.gcount()); | |||
const auto count = static_cast<std::size_t>(stream.gcount()); | |||
|
|||
if (count > 0) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Do we gain anything be not just inlining this?
I guess we cast the "signed" streamsize
to unsigned size_t
, but maybe that's not correct to begin with?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'm not sure I get your concern -- the behavior is equivalent to before, the scope of count
just used to be unnecessarily large.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'm talking about this
if (count > 0) | |
if (stream.gcount() > 0) |
or this
if (count > 0) | |
if (static_cast<std::size_t>(stream.gcount()) > 0) |
What exactly don't you like here? I think all of these should be merged. |
@@ -343,7 +343,7 @@ bool getEWMHFrameExtents(::Display* disp, ::Window win, long& xFrameExtent, long | |||
|
|||
#pragma GCC diagnostic push | |||
#pragma GCC diagnostic ignored "-Wcast-align" | |||
long* extents = reinterpret_cast<long*>(data); | |||
const long* extents = reinterpret_cast<long*>(data); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
const long* extents = reinterpret_cast<long*>(data); | |
const auto* extents = reinterpret_cast<long*>(data); |
f59a364
to
6100b40
Compare
Rebased on |
6100b40
to
4920c0b
Compare
@@ -1693,6 +1693,7 @@ bool WindowImplX11::processEvent(XEvent& windowEvent) | |||
XSetICFocus(m_inputContext); | |||
|
|||
// Grab cursor | |||
// TODO: ??? |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Could you explain what these two new TODO comments mean?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yes, I don't know what the intended use of m_cursorGrabbed
was here... Was looking for some feedback on why it was there
4920c0b
to
002cd1d
Compare
Pull Request Test Coverage Report for Build 11187683706Details
💛 - Coveralls |
we explicitly instantiated a template for |
not applied:
applied:
to review:
There's a few more outstanding ones but I don't want to make the PR too big