Skip to content

Use uint instead of long for PDH constants - #13502

Merged
Dongbo Wang (daxian-dbw) merged 1 commit into
PowerShell:masterfrom
xtqqczze:use-uint-pdh
Aug 27, 2020
Merged

Use uint instead of long for PDH constants#13502
Dongbo Wang (daxian-dbw) merged 1 commit into
PowerShell:masterfrom
xtqqczze:use-uint-pdh

Conversation

@xtqqczze

Copy link
Copy Markdown
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

@rjmholt Rob Holt (rjmholt) left a comment

Copy link
Copy Markdown
Collaborator

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
Copy Markdown
Contributor

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
Dongbo Wang (daxian-dbw) merged commit 78d0d0e into PowerShell:master Aug 27, 2020
@daxian-dbw Dongbo Wang (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
@xtqqczze
xtqqczze deleted the use-uint-pdh branch August 28, 2020 18:43
@ghost

Copy link
Copy Markdown

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

Handy links:

Thatgfsj (Thatgfsj) pushed a commit to Thatgfsj/PowerShell that referenced this pull request Aug 6, 2026
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