-
Notifications
You must be signed in to change notification settings - Fork 8.2k
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
static analysis fixes #553
Conversation
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 want to make sure both @adiviness and @miniksa get their eyes on this, so I'll let them be the two signoffs. Otherwise looks good to me.
I want to make sure both @adiviness and @miniksa get their eyes on this, so I'll let them be the two signoffs. Otherwise looks good to me.
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 going to look a bit further at the server IO one when I'm actually at my desk at work to make sure my concern is warranted before signing off.
src/host/srvinit.cpp
Outdated
@@ -653,22 +653,22 @@ DWORD ConsoleIoThread() | |||
if (ReplyMsg != nullptr) | |||
{ | |||
LOG_IF_FAILED(ReplyMsg->ReleaseMessageBuffers()); | |||
} |
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 so sure about this one. I think there are API calls that don't return a ReplyMsg
. If any of those are called, then we would be stuck.
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.
In that case, with the old code, ReplyMsg->Complete
would be a null dereference.
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.
Should be ok now that I see ReadIo() can take nullptr as 1st parameter.
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.
You're right about the null dereference at &ReplyMsg->Complete
. I looked back at the original code this was adapted from, and what should happen is:
- ReadIo's signature should be taking the PCONSOLE_API_MSG ReplyMsg as parameter one and only attempting to dig out the completion part if it is not null at that level.
- We need to keep the } on line 656 because there's technically a situation where the IO could fail for not pipe-disconnected and try to go around the loop again to reattempt the call with there being no reply message at all.
@@ -505,5 +508,5 @@ void Utf8ToWideCharParser::_Reset() | |||
{ | |||
_currentState = _State::Ready; | |||
_bytesStored = 0; | |||
_convertedWideChars.release(); |
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 think this is also in #836 now
@@ -69,6 +67,8 @@ typedef unsigned int Column; | |||
// the first char of the 0th row in the text buffer row array. | |||
typedef unsigned int Endpoint; | |||
|
|||
constexpr IdType invalid_id = 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.
@adiviness What is the recommended naming scheme for constants? I have seen all uppercase, pascal, lowercase, etc... Which one is correct?
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 depends on the scope of the constant and what sort of constant it is. For macros we typically do all caps (ex. FOO_BAR). for constexprs we typically do pascal case (ex. FooBar).
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.
Relevant ISO C++ guideline:
TL;DR is that since ALL CAPS names are typically used for macros, it's dangerous to use them for anything but macros since it makes it easy for a macro to silently replace or redefine something that's not a macro.
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.
Thanks @binarycrusader - this is why I was asking. I have seen a lot of constexpr that were upper case. 👎 I noticed an issue was already logged. 👍
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.
Waiting for correction of srvinit.cpp
IO loop to compensate for null reply message and fix the deref problem via the function call/signature.
… srvinit.cpp by changing signature in DeviceComm.h
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.
Excellent, thank you.
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.
Thanks a bunch for doing this!
No description provided.