Skip to content

Commit 4504cc5

Browse files
committed
Usage zero as language id for FormatMessageW()
1 parent d06ca0f commit 4504cc5

File tree

1 file changed

+2
-6
lines changed
  • library/std/src/sys/windows

1 file changed

+2
-6
lines changed

library/std/src/sys/windows/os.rs

+2-6
Original file line numberDiff line numberDiff line change
@@ -25,10 +25,6 @@ pub fn errno() -> i32 {
2525

2626
/// Gets a detailed string description for the given error number.
2727
pub fn error_string(mut errnum: i32) -> String {
28-
// This value is calculated from the macro
29-
// MAKELANGID(LANG_SYSTEM_DEFAULT, SUBLANG_SYS_DEFAULT)
30-
let langId = 0x0800 as c::DWORD;
31-
3228
let mut buf = [0 as c::WCHAR; 2048];
3329

3430
unsafe {
@@ -56,13 +52,13 @@ pub fn error_string(mut errnum: i32) -> String {
5652
flags | c::FORMAT_MESSAGE_FROM_SYSTEM | c::FORMAT_MESSAGE_IGNORE_INSERTS,
5753
module,
5854
errnum as c::DWORD,
59-
langId,
55+
0,
6056
buf.as_mut_ptr(),
6157
buf.len() as c::DWORD,
6258
ptr::null(),
6359
) as usize;
6460
if res == 0 {
65-
// Sometimes FormatMessageW can fail e.g., system doesn't like langId,
61+
// Sometimes FormatMessageW can fail e.g., system doesn't like 0 as langId,
6662
let fm_err = errno();
6763
return format!("OS Error {errnum} (FormatMessageW() returned error {fm_err})");
6864
}

0 commit comments

Comments
 (0)