8000 Use uint instead of long for PDH constants by xtqqczze · Pull Request #13502 · PowerShell/PowerShell · GitHub
[go: up one dir, main page]

Skip to content

Conversation

@xtqqczze
Copy link
Contributor

PR Summary

Avoid some signed/unsigned conversions.

PR Context

PDH_STATUSerror codes can be handled with UInt32

https://docs.microsoft.com/en-us/windows/win32/perfctrs/pdh-error-codes

Follow-up: #13141

PR Checklist

@ghost ghost assigned daxian-dbw Aug 22, 2020
Copy link
Collaborator
@rjmholt rjmholt left a comment

Choose a reason for hiding this comment

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

According to the FormatMessage API docs, the PDH error code values are of type DWORD, which the marshalling docs say should be rendered as uint. So this changes makes sense to me

@SeeminglyScience
Copy link
Collaborator

According to the FormatMessage API docs, the PDH error code values are of type DWORD, which the marshalling docs say should be rendered as uint. So this changes makes sense to me

Yeah. The original author probably looked at PdhMsg.h and saw that the constants were suffixed with L. Really easy mistake to make, it's not super intuitive that long translates to Int32 and long long is what translates to Int64. Especially since that's only Windows (see 64-bit data models).

@daxian-dbw daxian-dbw merged commit 78d0d0e into PowerShell:master Aug 27, 2020
@daxian-dbw daxian-dbw added the CL-CodeCleanup Indicates that a PR should be marked as a Code Cleanup change in the Change Log label Aug 27, 2020
@daxian-dbw daxian-dbw added this to the 7.1.0-preview.7 milestone Aug 27, 2020
@xtqqczze xtqqczze deleted the use-uint-pdh branch August 28, 2020 18:43
@ghost
Copy link
ghost commented Sep 8, 2020

🎉v7.1.0-preview.7 has been released which incorporates this pull request.:tada:

Handy links:

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

CL-CodeCleanup Indicates that a PR should be marked as a Code Cleanup change in the Change Log

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants

0