Skip to content

Conversation

@AZero13
Copy link
Contributor

@AZero13 AZero13 commented Dec 10, 2025

I know Microsoft is not consistent on this, but GetUserNameExW returns 0 on error.


return withUnsafeTemporaryAllocation(of: WCHAR.self, capacity: Int(ulLength)) { wszBuffer in
guard GetUserNameExW(NameDisplay, wszBuffer.baseAddress!, &ulLength) == 0 else {
guard GetUserNameExW(NameDisplay, wszBuffer.baseAddress!, &ulLength) != 0 else {
Copy link
Contributor

Choose a reason for hiding this comment

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

It looks like we have a unit test that validates that the user name is not empty but it only runs on macOS. Should we also run it on Windows to validate this behavior?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Sure!

@AZero13 AZero13 force-pushed the guard-wrong branch 2 times, most recently from 9b99a45 to 274e0ca Compare December 16, 2025 23:40
I know Microsoft is not consistent on this, but yes.
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.

2 participants