Skip to content

Commit

Permalink
os: make minior improvement to C function semantics and related code (#…
Browse files Browse the repository at this point in the history
  • Loading branch information
ttytm authored May 25, 2024
1 parent a7cf1ad commit 25be362
Showing 1 changed file with 4 additions and 6 deletions.
10 changes: 4 additions & 6 deletions vlib/os/os_nix.c.v
Original file line number Diff line number Diff line change
Expand Up @@ -61,9 +61,9 @@ pub const s_iwoth = 0o0002 // Write by others

pub const s_ixoth = 0o0001

fn C.utime(&char, voidptr) int
fn C.utime(&char, &C.utimbuf) int

fn C.uname(name voidptr) int
fn C.uname(name &C.utsname) int

fn C.symlink(&char, &char) int

Expand Down Expand Up @@ -215,7 +215,7 @@ fn native_glob_pattern(pattern string, mut matches []string) ! {

pub fn utime(path string, actime int, modtime int) ! {
u := C.utimbuf{actime, modtime}
if C.utime(&char(path.str), voidptr(&u)) != 0 {
if C.utime(&char(path.str), &u) != 0 {
return error_with_code(posix_get_error_msg(C.errno), C.errno)
}
}
Expand All @@ -238,10 +238,8 @@ pub fn utime(path string, actime int, modtime int) ! {
// See also https://pubs.opengroup.org/onlinepubs/7908799/xsh/sysutsname.h.html
pub fn uname() Uname {
mut u := Uname{}
utsize := sizeof(C.utsname)
unsafe {
x := malloc_noscan(int(utsize))
d := &C.utsname(x)
d := &C.utsname(malloc_noscan(int(sizeof(C.utsname))))
if C.uname(d) == 0 {
u.sysname = cstring_to_vstring(d.sysname)
u.nodename = cstring_to_vstring(d.nodename)
Expand Down

0 comments on commit 25be362

Please sign in to comment.