Skip to content

Commit acf9d16

Browse files
authored
os: fix some C compiler warnings for windows (#10506)
1 parent d56ae2d commit acf9d16

File tree

2 files changed

+6
-7
lines changed

2 files changed

+6
-7
lines changed

vlib/builtin/cfns.c.v

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -246,7 +246,7 @@ fn C.RegSetValueExW(hKey voidptr, lpValueName &u16, Reserved u32, dwType u32, lp
246246

247247
fn C.RegCloseKey(hKey voidptr)
248248

249-
fn C.RemoveDirectory(lpPathName &char) int
249+
fn C.RemoveDirectory(lpPathName &u16) int
250250

251251
// fn C.GetStdHandle() voidptr
252252
fn C.GetStdHandle(u32) voidptr

vlib/os/os_c.v

Lines changed: 5 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,7 @@ fn C.CopyFile(&u16, &u16, bool) int
2929

3030
// fn C.lstat(charptr, voidptr) u64
3131

32-
fn C._wstat64(&char, voidptr) u64
32+
fn C._wstat64(&u16, voidptr) u64
3333

3434
fn C.chown(&char, int, int) int
3535

@@ -168,7 +168,7 @@ pub fn file_size(path string) u64 {
168168
$if x64 {
169169
$if windows {
170170
mut swin := C.__stat64{}
171-
if C._wstat64(&char(path.to_wide()), voidptr(&swin)) != 0 {
171+
if C._wstat64(path.to_wide(), voidptr(&swin)) != 0 {
172172
eprintln_unknown_file_size()
173173
return 0
174174
}
@@ -471,7 +471,7 @@ pub fn rm(path string) ? {
471471
// rmdir removes a specified directory.
472472
pub fn rmdir(path string) ? {
473473
$if windows {
474-
rc := C.RemoveDirectory(&char(path.to_wide()))
474+
rc := C.RemoveDirectory(path.to_wide())
475475
if rc == 0 {
476476
// https://docs.microsoft.com/en-us/windows/win32/api/fileapi/nf-fileapi-removedirectorya - 0 is failure
477477
return error('Failed to remove "$path": ' + posix_get_error_msg(C.errno))
@@ -777,12 +777,11 @@ pub fn getwd() string {
777777
// NB: this particular rabbit hole is *deep* ...
778778
[manualfree]
779779
pub fn real_path(fpath string) string {
780-
mut fullpath := &byte(0)
781780
mut res := ''
782781
$if windows {
783782
// GetFullPathName doesn't work with symbolic links,
784783
// so if it is not a file, get full path
785-
fullpath = unsafe { &u16(vcalloc_noscan(max_path_len * 2)) }
784+
mut fullpath := unsafe { &u16(vcalloc_noscan(max_path_len * 2)) }
786785
// TODO: check errors if path len is not enough
787786
ret := C.GetFullPathName(fpath.to_wide(), max_path_len, fullpath, 0)
788787
if ret == 0 {
@@ -791,7 +790,7 @@ pub fn real_path(fpath string) string {
791790
}
792791
res = unsafe { string_from_wide(fullpath) }
793792
} $else {
794-
fullpath = vcalloc_noscan(max_path_len)
793+
mut fullpath := vcalloc_noscan(max_path_len)
795794
ret := &char(C.realpath(&char(fpath.str), &char(fullpath)))
796795
if ret == 0 {
797796
unsafe { free(fullpath) }

0 commit comments

Comments
 (0)