Skip to content
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

Merged
merged 14 commits into from
May 23, 2019
Merged

static analysis fixes #553

merged 14 commits into from
May 23, 2019

Conversation

ebudai
Copy link
Contributor

@ebudai ebudai commented May 8, 2019

No description provided.

@msftclas
Copy link

msftclas commented May 8, 2019

CLA assistant check
All CLA requirements met.

src/host/srvinit.cpp Outdated Show resolved Hide resolved
src/renderer/vt/tracing.cpp Show resolved Hide resolved
src/server/ApiMessage.cpp Outdated Show resolved Hide resolved
@zadjii-msft zadjii-msft requested a review from miniksa May 8, 2019 16:36
Copy link
Member

@zadjii-msft zadjii-msft left a 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.

@zadjii-msft zadjii-msft dismissed their stale review May 9, 2019 14:16

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.

src/host/ft_uia/KeyPressTests.cs Show resolved Hide resolved
src/host/utf8ToWideCharParser.cpp Outdated Show resolved Hide resolved
src/interactivity/win32/UiaTextRange.cpp Outdated Show resolved Hide resolved
Copy link
Member

@miniksa miniksa left a 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.

@@ -653,22 +653,22 @@ DWORD ConsoleIoThread()
if (ReplyMsg != nullptr)
{
LOG_IF_FAILED(ReplyMsg->ReleaseMessageBuffers());
}
Copy link
Member

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.

Copy link
Contributor Author

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.

Copy link
Contributor Author

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.

Copy link
Member

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:

  1. 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.
  2. 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();
Copy link
Member

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

src/interactivity/win32/UiaTextRange.cpp Show resolved Hide resolved
@@ -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;
Copy link

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?

Copy link
Contributor

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).

Copy link
Member

Choose a reason for hiding this comment

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

Relevant ISO C++ guideline:

ES.9: Avoid ALL_CAPS names

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.

Copy link

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. 👍

Copy link
Member

@miniksa miniksa left a 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.

@ghost ghost added the Needs-Author-Feedback The original author of the issue/PR needs to come back and respond to something label May 22, 2019
@ghost ghost removed the Needs-Author-Feedback The original author of the issue/PR needs to come back and respond to something label May 22, 2019
Copy link
Member

@miniksa miniksa left a comment

Choose a reason for hiding this comment

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

Excellent, thank you.

Copy link
Contributor

@DHowett-MSFT DHowett-MSFT left a 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!

@DHowett-MSFT DHowett-MSFT merged commit 06a5583 into microsoft:master May 23, 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.

9 participants