Skip to content

Commit 698409a

Browse files
committed
Adjust signature of cygwin_conv_path
...and remove set_len
1 parent 6ec5f9d commit 698409a

File tree

1 file changed

+7
-9
lines changed

1 file changed

+7
-9
lines changed

src/symbolize/gimli/libs_windows.rs

+7-9
Original file line numberDiff line numberDiff line change
@@ -52,12 +52,12 @@ unsafe fn get_posix_path(long_path: &[u16]) -> Option<OsString> {
5252
// Src: https://github.com/cygwin/cygwin/blob/718a15ba50e0d01c79800bd658c2477f9a603540/winsup/cygwin/path.cc#L3902
5353
// Safety:
5454
// * `what` should be `CCP_WIN_W_TO_POSIX` here
55-
// * `from` is `*const u16`, null-terminated, UTF-16 path
56-
// * `to` is `*mut u8` buffer, the buffer size is `size`.
55+
// * `from` is null-terminated UTF-16 path
56+
// * `to` is buffer, the buffer size is `size`.
5757
fn cygwin_conv_path(
5858
what: libc::c_uint,
59-
from: *const libc::c_void,
60-
to: *mut libc::c_void,
59+
from: *const u16,
60+
to: *mut u8,
6161
size: libc::size_t,
6262
) -> libc::ssize_t;
6363
}
@@ -69,7 +69,7 @@ unsafe fn get_posix_path(long_path: &[u16]) -> Option<OsString> {
6969
let name_len = unsafe {
7070
cygwin_conv_path(
7171
CCP_WIN_W_TO_POSIX,
72-
long_path.as_ptr().cast(),
72+
long_path.as_ptr(),
7373
core::ptr::null_mut(),
7474
0,
7575
)
@@ -85,17 +85,15 @@ unsafe fn get_posix_path(long_path: &[u16]) -> Option<OsString> {
8585
let res = unsafe {
8686
cygwin_conv_path(
8787
CCP_WIN_W_TO_POSIX,
88-
long_path.as_ptr().cast(),
89-
name_buffer.as_mut_ptr().cast(),
88+
long_path.as_ptr(),
89+
name_buffer.as_mut_ptr(),
9090
name_buffer.len(),
9191
)
9292
};
9393
// It's not likely to return error here.
9494
if res != 0 {
9595
return None;
9696
}
97-
// Ignore null terminator.
98-
unsafe { name_buffer.set_len(name_len - 1) };
9997
let name = OsString::from_vec(name_buffer);
10098
Some(name)
10199
}

0 commit comments

Comments
 (0)