Skip to content

whoami: Cleanup#2675

Merged
sylvestre merged 3 commits intouutils:masterfrom
blyxxyz:whoami-cleanup
Sep 18, 2021
Merged

whoami: Cleanup#2675
sylvestre merged 3 commits intouutils:masterfrom
blyxxyz:whoami-cleanup

Conversation

@blyxxyz
Copy link
Contributor

@blyxxyz blyxxyz commented Sep 13, 2021

  • Use modern conventions
  • Restrict the scope of unsafe
  • Do not use deprecated std::mem::unitialized()
  • Do not bake unicode into design

- Use modern conventions
- Restrict the scope of unsafe
- Do not use deprecated `std::mem::unitialized()`
- Do not bake unicode into design
let mut len = buffer.len() as minwindef::DWORD;
if winbase::GetUserNameW(buffer.as_mut_ptr(), &mut len) == 0 {
return Err(Error::last_os_error());
pub fn get_username() -> io::Result<OsString> {
Copy link
Contributor

Choose a reason for hiding this comment

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

any idea with code coverage is 0 here?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

All the tests were disabled on Windows. I'll see if I can fix it.

@blyxxyz
Copy link
Contributor Author

blyxxyz commented Sep 14, 2021

whoami: failed to get username: No such file or directory

This confused me for a bit. The reason it says that is that entries.rs creates an io::Error::new(io::ErrorKind::NotFound, format!("No such id: {}", k)), and error.rs discards the custom message. We should probably find a way to detect custom error messages.

(Not a problem for this PR.)

@sylvestre
Copy link
Contributor

Keep in mind that the CI can be configured weirdly

@blyxxyz
Copy link
Contributor Author

blyxxyz commented Sep 14, 2021

Yeah, there was already a workaround in place. I removed it to check if it was still necessary, and apparently it was, so I put it back.

Co-authored-by: Jan Scheer <jhscheer@users.noreply.github.com>
@sylvestre sylvestre merged commit 3e8b404 into uutils:master Sep 18, 2021
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.

3 participants