From 7ed3389fa8404fd3bedfa3fca6d05608cd2cecd2 Mon Sep 17 00:00:00 2001 From: Delyan Angelov Date: Wed, 17 Aug 2022 18:40:15 +0300 Subject: [PATCH] ci: fix -cstrict checks after 7585e86 --- vlib/os/os.c.v | 40 ++++++++++++++++++++-------------------- 1 file changed, 20 insertions(+), 20 deletions(-) diff --git a/vlib/os/os.c.v b/vlib/os/os.c.v index 80ed28151b..8d28691958 100644 --- a/vlib/os/os.c.v +++ b/vlib/os/os.c.v @@ -611,7 +611,7 @@ pub fn read_file_array(path string) []T { pub fn executable() string { mut result := [max_path_buffer_size]u8{} $if windows { - pu16_result := unsafe { &u16(&result) } + pu16_result := unsafe { &u16(&result[0]) } len := C.GetModuleFileName(0, pu16_result, 512) // determine if the file is a windows symlink attrs := C.GetFileAttributesW(pu16_result) @@ -625,10 +625,10 @@ pub fn executable() string { } final_path := [max_path_buffer_size]u8{} // https://docs.microsoft.com/en-us/windows/win32/api/fileapi/nf-fileapi-getfinalpathnamebyhandlew - final_len := C.GetFinalPathNameByHandleW(file, unsafe { &u16(&final_path) }, + final_len := C.GetFinalPathNameByHandleW(file, unsafe { &u16(&final_path[0]) }, max_path_buffer_size, 0) if final_len < max_path_buffer_size { - sret := unsafe { string_from_wide2(&u16(&final_path), final_len) } + sret := unsafe { string_from_wide2(&u16(&final_path[0]), final_len) } defer { unsafe { sret.free() } } @@ -646,46 +646,46 @@ pub fn executable() string { } $if macos { pid := C.getpid() - ret := proc_pidpath(pid, &result, max_path_len) + ret := proc_pidpath(pid, &result[0], max_path_len) if ret <= 0 { eprintln('os.executable() failed at calling proc_pidpath with pid: $pid . proc_pidpath returned $ret ') return executable_fallback() } - res := unsafe { tos_clone(&result) } + res := unsafe { tos_clone(&result[0]) } return res } $if freebsd { bufsize := usize(max_path_buffer_size) mib := [1 /* CTL_KERN */, 14 /* KERN_PROC */, 12 /* KERN_PROC_PATHNAME */, -1] - unsafe { C.sysctl(mib.data, mib.len, &result, &bufsize, 0, 0) } - res := unsafe { tos_clone(&result) } + unsafe { C.sysctl(mib.data, mib.len, &result[0], &bufsize, 0, 0) } + res := unsafe { tos_clone(&result[0]) } return res } $if netbsd { - count := C.readlink(c'/proc/curproc/exe', &char(&result), max_path_len) + count := C.readlink(c'/proc/curproc/exe', &char(&result[0]), max_path_len) if count < 0 { eprintln('os.executable() failed at reading /proc/curproc/exe to get exe path') return executable_fallback() } - res := unsafe { tos_clone(&result) } + res := unsafe { tos_clone(&result[0]) } return res } $if dragonfly { - count := C.readlink(c'/proc/curproc/file', &char(&result), max_path_len) + count := C.readlink(c'/proc/curproc/file', &char(&result[0]), max_path_len) if count < 0 { eprintln('os.executable() failed at reading /proc/curproc/file to get exe path') return executable_fallback() } - res := unsafe { tos_clone(&result) } + res := unsafe { tos_clone(&result[0]) } return res } $if linux { - count := C.readlink(c'/proc/self/exe', &char(&result), max_path_len) + count := C.readlink(c'/proc/self/exe', &char(&result[0]), max_path_len) if count < 0 { eprintln('os.executable() failed at reading /proc/self/exe to get exe path') return executable_fallback() } - res := unsafe { tos_clone(&result) } + res := unsafe { tos_clone(&result[0]) } return res } // "Sadly there is no way to get the full path of the executed file in OpenBSD." @@ -752,16 +752,16 @@ pub fn getwd() string { unsafe { buf := [max_path_buffer_size]u8{} $if windows { - if C._wgetcwd(&u16(&buf), max_path_len) == 0 { + if C._wgetcwd(&u16(&buf[0]), max_path_len) == 0 { return '' } - res := string_from_wide(&u16(&buf)) + res := string_from_wide(&u16(&buf[0])) return res } $else { - if C.getcwd(&char(&buf), max_path_len) == 0 { + if C.getcwd(&char(&buf[0]), max_path_len) == 0 { return '' } - res := tos_clone(&buf) + res := tos_clone(&buf[0]) return res } } @@ -777,7 +777,7 @@ pub fn real_path(fpath string) string { mut fullpath := [max_path_buffer_size]u8{} mut res := '' $if windows { - pu16_fullpath := unsafe { &u16(&fullpath) } + pu16_fullpath := unsafe { &u16(&fullpath[0]) } // gets handle with GENERIC_READ, FILE_SHARE_READ, 0, OPEN_EXISTING, FILE_ATTRIBUTE_NORMAL, 0 // use C.CreateFile(fpath.to_wide(), 0x80000000, 1, 0, 3, 0x80, 0) instead of get_file_handle // try to open the file to get symbolic link path @@ -815,7 +815,7 @@ pub fn real_path(fpath string) string { res = unsafe { string_from_wide(pu16_fullpath) } } } $else { - ret := &char(C.realpath(&char(fpath.str), &char(&fullpath))) + ret := &char(C.realpath(&char(fpath.str), &char(&fullpath[0]))) if ret == 0 { unsafe { res.free() } return fpath.clone() @@ -825,7 +825,7 @@ pub fn real_path(fpath string) string { // resulting string from that buffer, to a shorter one, and then free the // 4KB fullpath buffer. unsafe { res.free() } - res = unsafe { tos_clone(&fullpath) } + res = unsafe { tos_clone(&fullpath[0]) } } unsafe { normalize_drive_letter(res) } return res