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

windows: basic support for GetUserProfileDirectoryW #3502

Merged
merged 4 commits into from
Apr 24, 2024

Conversation

RalfJung
Copy link
Member

Fixes #3499

)?;
// The Windows docs just say that this is written on failure. But std
// seems to rely on it always being written.
this.write_scalar(Scalar::from_u32(len.try_into().unwrap()), &size)?;
Copy link
Member Author

@RalfJung RalfJung Apr 23, 2024

Choose a reason for hiding this comment

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

@ChrisDenton something seems to be odd here, or I am misunderstanding something. The docs say about the size pointer

If the buffer specified by lpProfileDir is not large enough or lpProfileDir is NULL, the function fails and this parameter receives the necessary buffer size, including the terminating null character.

So in particular, if the buffer is large enough, it doesn't say that the pointer is changed at all.

But the way std calls this function, it assumes that on success, sz is updated to the actual size (including the null terminator).

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. We shouldn't be doing that if the behaviour isn't documented.

Given that's how it's worked in practice and Rust has apparently been relying on this for a long time, I do think updating the API docs is warranted. However, unless or until that actually happens we should act as if such a documentation change would be rejected.

Copy link
Member Author

@RalfJung RalfJung Apr 24, 2024

Choose a reason for hiding this comment

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

Thanks for confirming! I will then land this PR (if I stopped updating the size the tests would fail). I opened an issue to track this: rust-lang/rust#124325.

@RalfJung RalfJung force-pushed the GetUserProfileDirectoryW branch 3 times, most recently from 5cd7832 to 817ee4b Compare April 23, 2024 09:01
@bors
Copy link
Contributor

bors commented Apr 23, 2024

☔ The latest upstream changes (presumably #3504) made this pull request unmergeable. Please resolve the merge conflicts.

@RalfJung RalfJung force-pushed the GetUserProfileDirectoryW branch from 817ee4b to 10e8bb8 Compare April 24, 2024 06:49
@RalfJung
Copy link
Member Author

@bors r+

@bors
Copy link
Contributor

bors commented Apr 24, 2024

📌 Commit 10e8bb8 has been approved by RalfJung

It is now in the queue for this repository.

@bors
Copy link
Contributor

bors commented Apr 24, 2024

⌛ Testing commit 10e8bb8 with merge 4c399a3...

@bors
Copy link
Contributor

bors commented Apr 24, 2024

☀️ Test successful - checks-actions
Approved by: RalfJung
Pushing 4c399a3 to master...

@bors bors merged commit 4c399a3 into rust-lang:master Apr 24, 2024
8 checks passed
@RalfJung RalfJung deleted the GetUserProfileDirectoryW branch April 24, 2024 09:21
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.

Windows home_dir fallback when HOME is not set not supported
3 participants