Browse Source

Fix typo; remove unneeded casts

gingerBill 1 year ago
parent
commit
bdbbbf5c95
6 changed files with 118 additions and 118 deletions
  1. 31 31
      core/os/os_darwin.odin
  2. 21 21
      core/os/os_freebsd.odin
  3. 15 15
      core/os/os_haiku.odin
  4. 7 7
      core/os/os_linux.odin
  5. 23 23
      core/os/os_netbsd.odin
  6. 21 21
      core/os/os_openbsd.odin

+ 31 - 31
core/os/os_darwin.odin

@@ -733,7 +733,7 @@ write :: proc(fd: Handle, data: []byte) -> (int, Error) {
 
 	bytes_written := _unix_write(fd, raw_data(data), to_write)
 	if bytes_written < 0 {
-		return -1, Error(get_last_error())
+		return -1, get_last_error()
 	}
 	return bytes_written, nil
 }
@@ -747,7 +747,7 @@ read :: proc(fd: Handle, data: []u8) -> (int, Error) {
 
 	bytes_read := _unix_read(fd, raw_data(data), to_read)
 	if bytes_read < 0 {
-		return -1, Error(get_last_error())
+		return -1, get_last_error()
 	}
 	return bytes_read, nil
 }
@@ -761,7 +761,7 @@ read_at :: proc(fd: Handle, data: []byte, offset: i64) -> (int, Error) {
 
 	bytes_read := _unix_pread(fd, raw_data(data), to_read, offset)
 	if bytes_read < 0 {
-		return -1, Error(get_last_error())
+		return -1, get_last_error()
 	}
 	return bytes_read, nil
 }
@@ -775,7 +775,7 @@ write_at :: proc(fd: Handle, data: []byte, offset: i64) -> (int, Error) {
 
 	bytes_written := _unix_pwrite(fd, raw_data(data), to_write, offset)
 	if bytes_written < 0 {
-		return -1, Error(get_last_error())
+		return -1, get_last_error()
 	}
 	return bytes_written, nil
 }
@@ -888,7 +888,7 @@ remove :: proc(path: string) -> Error {
 	path_cstr := strings.clone_to_cstring(path, context.temp_allocator)
 	res := _unix_remove(path_cstr)
 	if res == -1 {
-		return Error(get_last_error())
+		return get_last_error()
 	}
 	return nil
 }
@@ -901,7 +901,7 @@ _stat :: proc(path: string) -> (OS_Stat, Error) {
 	s: OS_Stat
 	result := _unix_stat(cstr, &s)
 	if result == -1 {
-		return s, Error(get_last_error())
+		return s, get_last_error()
 	}
 	return s, nil
 }
@@ -914,7 +914,7 @@ _lstat :: proc(path: string) -> (OS_Stat, Error) {
 	s: OS_Stat
 	result := _unix_lstat(cstr, &s)
 	if result == -1 {
-		return s, Error(get_last_error())
+		return s, get_last_error()
 	}
 	return s, nil
 }
@@ -924,7 +924,7 @@ _fstat :: proc(fd: Handle) -> (OS_Stat, Error) {
 	s: OS_Stat
 	result := _unix_fstat(fd, &s)
 	if result == -1 {
-		return s, Error(get_last_error())
+		return s, get_last_error()
 	}
 	return s, nil
 }
@@ -933,7 +933,7 @@ _fstat :: proc(fd: Handle) -> (OS_Stat, Error) {
 _fdopendir :: proc(fd: Handle) -> (Dir, Error) {
 	dirp := _unix_fdopendir(fd)
 	if dirp == cast(Dir)nil {
-		return nil, Error(get_last_error())
+		return nil, get_last_error()
 	}
 	return dirp, nil
 }
@@ -942,7 +942,7 @@ _fdopendir :: proc(fd: Handle) -> (Dir, Error) {
 _closedir :: proc(dirp: Dir) -> Error {
 	rc := _unix_closedir(dirp)
 	if rc != 0 {
-		return Error(get_last_error())
+		return get_last_error()
 	}
 	return nil
 }
@@ -958,7 +958,7 @@ _readdir :: proc(dirp: Dir) -> (entry: Dirent, err: Error, end_of_stream: bool)
 	rc := _unix_readdir_r(dirp, &entry, &result)
 
 	if rc != 0 {
-		err = Error(get_last_error())
+		err = get_last_error()
 		return
 	}
 
@@ -982,7 +982,7 @@ _readlink :: proc(path: string) -> (string, Error) {
 		rc := _unix_readlink(path_cstr, &(buf[0]), bufsz)
 		if rc == -1 {
 			delete(buf)
-			return "", Error(get_last_error())
+			return "", get_last_error()
 		} else if rc == int(bufsz) {
 			// NOTE(laleksic, 2021-01-21): Any cleaner way to resize the slice?
 			bufsz *= 2
@@ -1011,7 +1011,7 @@ absolute_path_from_relative :: proc(rel: string) -> (path: string, err: Error) {
 
 	path_ptr := _unix_realpath(rel_cstr, nil)
 	if path_ptr == nil {
-		return "", Error(get_last_error())
+		return "", get_last_error()
 	}
 	defer _unix_free(path_ptr)
 
@@ -1052,7 +1052,7 @@ set_env :: proc(key, value: string) -> Error {
 	value_cstring := strings.clone_to_cstring(value, context.temp_allocator)
 	res := _unix_setenv(key_cstring, value_cstring, 1)
 	if res < 0 {
-		return Error(get_last_error())
+		return get_last_error()
 	}
 	return nil
 }
@@ -1062,7 +1062,7 @@ unset_env :: proc(key: string) -> Error {
 	s := strings.clone_to_cstring(key, context.temp_allocator)
 	res := _unix_unsetenv(s)
 	if res < 0 {
-		return Error(get_last_error())
+		return get_last_error()
 	}
 	return nil
 }
@@ -1075,7 +1075,7 @@ get_current_directory :: proc() -> string {
 		if cwd != nil {
 			return string(cwd)
 		}
-		if Error(get_last_error()) != ERANGE {
+		if get_last_error() != ERANGE {
 			delete(buf)
 			return ""
 		}
@@ -1089,7 +1089,7 @@ set_current_directory :: proc(path: string) -> (err: Error) {
 	cstr := strings.clone_to_cstring(path, context.temp_allocator)
 	res := _unix_chdir(cstr)
 	if res == -1 {
-		return Error(get_last_error())
+		return get_last_error()
 	}
 	return nil
 }
@@ -1099,7 +1099,7 @@ make_directory :: proc(path: string, mode: u16 = 0o775) -> Error {
 	path_cstr := strings.clone_to_cstring(path, context.temp_allocator)
 	res := _unix_mkdir(path_cstr, mode)
 	if res == -1 {
-		return Error(get_last_error())
+		return get_last_error()
 	}
 	return nil
 }
@@ -1176,7 +1176,7 @@ _alloc_command_line_arguments :: proc() -> []string {
 socket :: proc(domain: int, type: int, protocol: int) -> (Socket, Error) {
 	result := _unix_socket(domain, type, protocol)
 	if result < 0 {
-		return 0, Error(get_last_error())
+		return 0, get_last_error()
 	}
 	return Socket(result), nil
 }
@@ -1184,7 +1184,7 @@ socket :: proc(domain: int, type: int, protocol: int) -> (Socket, Error) {
 connect :: proc(sd: Socket, addr: ^SOCKADDR, len: socklen_t) -> (Error) {
 	result := _unix_connect(int(sd), addr, len)
 	if result < 0 {
-		return Error(get_last_error())
+		return get_last_error()
 	}
 	return nil
 }
@@ -1192,7 +1192,7 @@ connect :: proc(sd: Socket, addr: ^SOCKADDR, len: socklen_t) -> (Error) {
 bind :: proc(sd: Socket, addr: ^SOCKADDR, len: socklen_t) -> (Error) {
 	result := _unix_bind(int(sd), addr, len)
 	if result < 0 {
-		return Error(get_last_error())
+		return get_last_error()
 	}
 	return nil
 }
@@ -1200,7 +1200,7 @@ bind :: proc(sd: Socket, addr: ^SOCKADDR, len: socklen_t) -> (Error) {
 accept :: proc(sd: Socket, addr: ^SOCKADDR, len: rawptr) -> (Socket, Error) {
 	result := _unix_accept(int(sd), rawptr(addr), len)
 	if result < 0 {
-		return 0, Error(get_last_error())
+		return 0, get_last_error()
 	}
 	return Socket(result), nil
 }
@@ -1208,7 +1208,7 @@ accept :: proc(sd: Socket, addr: ^SOCKADDR, len: rawptr) -> (Socket, Error) {
 listen :: proc(sd: Socket, backlog: int) -> (Error) {
 	result := _unix_listen(int(sd), backlog)
 	if result < 0 {
-		return Error(get_last_error())
+		return get_last_error()
 	}
 	return nil
 }
@@ -1216,7 +1216,7 @@ listen :: proc(sd: Socket, backlog: int) -> (Error) {
 setsockopt :: proc(sd: Socket, level: int, optname: int, optval: rawptr, optlen: socklen_t) -> (Error) {
 	result := _unix_setsockopt(int(sd), level, optname, optval, optlen)
 	if result < 0 {
-		return Error(get_last_error())
+		return get_last_error()
 	}
 	return nil
 }
@@ -1224,7 +1224,7 @@ setsockopt :: proc(sd: Socket, level: int, optname: int, optval: rawptr, optlen:
 getsockopt :: proc(sd: Socket, level: int, optname: int, optval: rawptr, optlen: socklen_t) -> Error {
 	result := _unix_getsockopt(int(sd), level, optname, optval, optlen)
 	if result < 0 {
-		return Error(get_last_error())
+		return get_last_error()
 	}
 	return nil
 }
@@ -1232,7 +1232,7 @@ getsockopt :: proc(sd: Socket, level: int, optname: int, optval: rawptr, optlen:
 recvfrom :: proc(sd: Socket, data: []byte, flags: int, addr: ^SOCKADDR, addr_size: ^socklen_t) -> (u32, Error) {
 	result := _unix_recvfrom(int(sd), raw_data(data), len(data), flags, addr, addr_size)
 	if result < 0 {
-		return 0, Error(get_last_error())
+		return 0, get_last_error()
 	}
 	return u32(result), nil
 }
@@ -1240,7 +1240,7 @@ recvfrom :: proc(sd: Socket, data: []byte, flags: int, addr: ^SOCKADDR, addr_siz
 recv :: proc(sd: Socket, data: []byte, flags: int) -> (u32, Error) {
 	result := _unix_recv(int(sd), raw_data(data), len(data), flags)
 	if result < 0 {
-		return 0, Error(get_last_error())
+		return 0, get_last_error()
 	}
 	return u32(result), nil
 }
@@ -1248,7 +1248,7 @@ recv :: proc(sd: Socket, data: []byte, flags: int) -> (u32, Error) {
 sendto :: proc(sd: Socket, data: []u8, flags: int, addr: ^SOCKADDR, addrlen: socklen_t) -> (u32, Error) {
 	result := _unix_sendto(int(sd), raw_data(data), len(data), flags, addr, addrlen)
 	if result < 0 {
-		return 0, Error(get_last_error())
+		return 0, get_last_error()
 	}
 	return u32(result), nil
 }
@@ -1256,7 +1256,7 @@ sendto :: proc(sd: Socket, data: []u8, flags: int, addr: ^SOCKADDR, addrlen: soc
 send :: proc(sd: Socket, data: []byte, flags: int) -> (u32, Error) {
 	result := _unix_send(int(sd), raw_data(data), len(data), 0)
 	if result < 0 {
-		return 0, Error(get_last_error())
+		return 0, get_last_error()
 	}
 	return u32(result), nil
 }
@@ -1264,7 +1264,7 @@ send :: proc(sd: Socket, data: []byte, flags: int) -> (u32, Error) {
 shutdown :: proc(sd: Socket, how: int) -> (Error) {
 	result := _unix_shutdown(int(sd), how)
 	if result < 0 {
-		return Error(get_last_error())
+		return get_last_error()
 	}
 	return nil
 }
@@ -1272,7 +1272,7 @@ shutdown :: proc(sd: Socket, how: int) -> (Error) {
 fcntl :: proc(fd: int, cmd: int, arg: int) -> (int, Error) {
 	result := _unix__fcntl(Handle(fd), c.int(cmd), uintptr(arg))
 	if result < 0 {
-		return 0, Error(get_last_error())
+		return 0, get_last_error()
 	}
 	return int(result), nil
 }

+ 21 - 21
core/os/os_freebsd.odin

@@ -429,7 +429,7 @@ open :: proc(path: string, flags: int = O_RDONLY, mode: int = 0) -> (Handle, Err
 	cstr := strings.clone_to_cstring(path, context.temp_allocator)
 	handle := _unix_open(cstr, c.int(flags), c.int(mode))
 	if handle == -1 {
-		return INVALID_HANDLE, Error(get_last_error())
+		return INVALID_HANDLE, get_last_error()
 	}
 	return handle, nil
 }
@@ -437,7 +437,7 @@ open :: proc(path: string, flags: int = O_RDONLY, mode: int = 0) -> (Handle, Err
 close :: proc(fd: Handle) -> Error {
 	result := _unix_close(fd)
 	if result == -1 {
-		return Error(get_last_error())
+		return get_last_error()
 	}
 	return nil
 }
@@ -454,7 +454,7 @@ read :: proc(fd: Handle, data: []byte) -> (int, Error) {
 	to_read    := min(c.size_t(len(data)), MAX_RW)
 	bytes_read := _unix_read(fd, &data[0], to_read)
 	if bytes_read == -1 {
-		return -1, Error(get_last_error())
+		return -1, get_last_error()
 	}
 	return int(bytes_read), nil
 }
@@ -467,7 +467,7 @@ write :: proc(fd: Handle, data: []byte) -> (int, Error) {
 	to_write      := min(c.size_t(len(data)), MAX_RW)
 	bytes_written := _unix_write(fd, &data[0], to_write)
 	if bytes_written == -1 {
-		return -1, Error(get_last_error())
+		return -1, get_last_error()
 	}
 	return int(bytes_written), nil
 }
@@ -475,7 +475,7 @@ write :: proc(fd: Handle, data: []byte) -> (int, Error) {
 seek :: proc(fd: Handle, offset: i64, whence: int) -> (i64, Error) {
 	res := _unix_seek(fd, offset, c.int(whence))
 	if res == -1 {
-		return -1, Error(get_last_error())
+		return -1, get_last_error()
 	}
 	return res, nil
 }
@@ -493,7 +493,7 @@ rename :: proc(old_path, new_path: string) -> Error {
 	new_path_cstr := strings.clone_to_cstring(new_path, context.temp_allocator)
 	res := _unix_rename(old_path_cstr, new_path_cstr)
 	if res == -1 {
-		return Error(get_last_error())
+		return get_last_error()
 	}
 	return nil
 }
@@ -503,7 +503,7 @@ remove :: proc(path: string) -> Error {
 	path_cstr := strings.clone_to_cstring(path, context.temp_allocator)
 	res := _unix_unlink(path_cstr)
 	if res == -1 {
-		return Error(get_last_error())
+		return get_last_error()
 	}
 	return nil
 }
@@ -513,7 +513,7 @@ make_directory :: proc(path: string, mode: mode_t = 0o775) -> Error {
 	path_cstr := strings.clone_to_cstring(path, context.temp_allocator)
 	res := _unix_mkdir(path_cstr, mode)
 	if res == -1 {
-		return Error(get_last_error())
+		return get_last_error()
 	}
 	return nil
 }
@@ -523,7 +523,7 @@ remove_directory :: proc(path: string) -> Error {
 	path_cstr := strings.clone_to_cstring(path, context.temp_allocator)
 	res := _unix_rmdir(path_cstr)
 	if res == -1 {
-		return Error(get_last_error())
+		return get_last_error()
 	}
 	return nil
 }
@@ -610,7 +610,7 @@ _stat :: proc(path: string) -> (OS_Stat, Error) {
 	s: OS_Stat = ---
 	result := _unix_lstat(cstr, &s)
 	if result == -1 {
-		return s, Error(get_last_error())
+		return s, get_last_error()
 	}
 	return s, nil
 }
@@ -624,7 +624,7 @@ _lstat :: proc(path: string) -> (OS_Stat, Error) {
 	s: OS_Stat = ---
 	res := _unix_lstat(cstr, &s)
 	if res == -1 {
-		return s, Error(get_last_error())
+		return s, get_last_error()
 	}
 	return s, nil
 }
@@ -634,7 +634,7 @@ _fstat :: proc(fd: Handle) -> (OS_Stat, Error) {
 	s: OS_Stat = ---
 	result := _unix_fstat(fd, &s)
 	if result == -1 {
-		return s, Error(get_last_error())
+		return s, get_last_error()
 	}
 	return s, nil
 }
@@ -643,7 +643,7 @@ _fstat :: proc(fd: Handle) -> (OS_Stat, Error) {
 _fdopendir :: proc(fd: Handle) -> (Dir, Error) {
 	dirp := _unix_fdopendir(fd)
 	if dirp == cast(Dir)nil {
-		return nil, Error(get_last_error())
+		return nil, get_last_error()
 	}
 	return dirp, nil
 }
@@ -652,7 +652,7 @@ _fdopendir :: proc(fd: Handle) -> (Dir, Error) {
 _closedir :: proc(dirp: Dir) -> Error {
 	rc := _unix_closedir(dirp)
 	if rc != 0 {
-		return Error(get_last_error())
+		return get_last_error()
 	}
 	return nil
 }
@@ -668,7 +668,7 @@ _readdir :: proc(dirp: Dir) -> (entry: Dirent, err: Error, end_of_stream: bool)
 	rc := _unix_readdir_r(dirp, &entry, &result)
 
 	if rc != 0 {
-		err = Error(get_last_error())
+		err = get_last_error()
 		return
 	}
 
@@ -692,7 +692,7 @@ _readlink :: proc(path: string) -> (string, Error) {
 		rc := _unix_readlink(path_cstr, &(buf[0]), bufsz)
 		if rc == -1 {
 			delete(buf)
-			return "", Error(get_last_error())
+			return "", get_last_error()
 		} else if rc == int(bufsz) {
 			bufsz += MAX_PATH
 			delete(buf)
@@ -720,7 +720,7 @@ absolute_path_from_handle :: proc(fd: Handle) -> (string, Error) {
 
 	res := _unix_fcntl(fd, F_KINFO, cast(uintptr)&kinfo)
 	if res == -1 {
-		return "", Error(get_last_error())
+		return "", get_last_error()
 	}
 
 	path := strings.clone_from_cstring_bounded(cast(cstring)&kinfo.path[0], len(kinfo.path))
@@ -738,7 +738,7 @@ absolute_path_from_relative :: proc(rel: string) -> (path: string, err: Error) {
 
 	path_ptr := _unix_realpath(rel_cstr, nil)
 	if path_ptr == nil {
-		return "", Error(get_last_error())
+		return "", get_last_error()
 	}
 	defer _unix_free(path_ptr)
 
@@ -754,7 +754,7 @@ access :: proc(path: string, mask: int) -> (bool, Error) {
 	cstr := strings.clone_to_cstring(path, context.temp_allocator)
 	result := _unix_access(cstr, c.int(mask))
 	if result == -1 {
-		return false, Error(get_last_error())
+		return false, get_last_error()
 	}
 	return true, nil
 }
@@ -786,7 +786,7 @@ get_current_directory :: proc() -> string {
 		if cwd != nil {
 			return string(cwd)
 		}
-		if Error(get_last_error()) != ERANGE {
+		if get_last_error() != ERANGE {
 			delete(buf)
 			return ""
 		}
@@ -800,7 +800,7 @@ set_current_directory :: proc(path: string) -> (err: Error) {
 	cstr := strings.clone_to_cstring(path, context.temp_allocator)
 	res := _unix_chdir(cstr)
 	if res == -1 {
-		return Error(get_last_error())
+		return get_last_error()
 	}
 	return nil
 }

+ 15 - 15
core/os/os_haiku.odin

@@ -189,7 +189,7 @@ get_last_error :: proc "contextless" () -> Error {
 fork :: proc() -> (Pid, Error) {
 	pid := _unix_fork()
 	if pid == -1 {
-		return Pid(-1), Error(get_last_error())
+		return Pid(-1), get_last_error()
 	}
 	return Pid(pid), nil
 }
@@ -199,7 +199,7 @@ open :: proc(path: string, flags: int = O_RDONLY, mode: int = 0) -> (Handle, Err
 	cstr := strings.clone_to_cstring(path, context.temp_allocator)
 	handle := _unix_open(cstr, c.int(flags), c.int(mode))
 	if handle == -1 {
-		return INVALID_HANDLE, Error(get_last_error())
+		return INVALID_HANDLE, get_last_error()
 	}
 	return handle, nil
 }
@@ -207,7 +207,7 @@ open :: proc(path: string, flags: int = O_RDONLY, mode: int = 0) -> (Handle, Err
 close :: proc(fd: Handle) -> Error {
 	result := _unix_close(fd)
 	if result == -1 {
-		return Error(get_last_error())
+		return get_last_error()
 	}
 	return nil
 }
@@ -223,7 +223,7 @@ read :: proc(fd: Handle, data: []byte) -> (int, Error) {
 	to_read    := min(c.size_t(len(data)), MAX_RW)
 	bytes_read := _unix_read(fd, &data[0], to_read)
 	if bytes_read == -1 {
-		return -1, Error(get_last_error())
+		return -1, get_last_error()
 	}
 	return int(bytes_read), nil
 }
@@ -236,7 +236,7 @@ write :: proc(fd: Handle, data: []byte) -> (int, Error) {
 	to_write      := min(c.size_t(len(data)), MAX_RW)
 	bytes_written := _unix_write(fd, &data[0], to_write)
 	if bytes_written == -1 {
-		return -1, Error(get_last_error())
+		return -1, get_last_error()
 	}
 	return int(bytes_written), nil
 }
@@ -244,7 +244,7 @@ write :: proc(fd: Handle, data: []byte) -> (int, Error) {
 seek :: proc(fd: Handle, offset: i64, whence: int) -> (i64, Error) {
 	res := _unix_seek(fd, offset, c.int(whence))
 	if res == -1 {
-		return -1, Error(get_last_error())
+		return -1, get_last_error()
 	}
 	return res, nil
 }
@@ -277,7 +277,7 @@ _stat :: proc(path: string) -> (OS_Stat, Error) {
 	s: OS_Stat = ---
 	res := _unix_stat(cstr, &s)
 	if res == -1 {
-		return s, Error(get_last_error())
+		return s, get_last_error()
 	}
 	return s, nil
 }
@@ -291,7 +291,7 @@ _lstat :: proc(path: string) -> (OS_Stat, Error) {
 	s: OS_Stat = ---
 	res := _unix_lstat(cstr, &s)
 	if res == -1 {
-		return s, Error(get_last_error())
+		return s, get_last_error()
 	}
 	return s, nil
 }
@@ -302,7 +302,7 @@ _fstat :: proc(fd: Handle) -> (OS_Stat, Error) {
 	s: OS_Stat = ---
 	res := _unix_fstat(fd, &s)
 	if res == -1 {
-		return s, Error(get_last_error())
+		return s, get_last_error()
 	}
 	return s, nil
 }
@@ -311,7 +311,7 @@ _fstat :: proc(fd: Handle) -> (OS_Stat, Error) {
 _fdopendir :: proc(fd: Handle) -> (Dir, Error) {
 	dirp := _unix_fdopendir(fd)
 	if dirp == cast(Dir)nil {
-		return nil, Error(get_last_error())
+		return nil, get_last_error()
 	}
 	return dirp, nil
 }
@@ -320,7 +320,7 @@ _fdopendir :: proc(fd: Handle) -> (Dir, Error) {
 _closedir :: proc(dirp: Dir) -> Error {
 	rc := _unix_closedir(dirp)
 	if rc != 0 {
-		return Error(get_last_error())
+		return get_last_error()
 	}
 	return nil
 }
@@ -336,7 +336,7 @@ _readdir :: proc(dirp: Dir) -> (entry: Dirent, err: Error, end_of_stream: bool)
 	rc := _unix_readdir_r(dirp, &entry, &result)
 
 	if rc != 0 {
-		err = Error(get_last_error())
+		err = get_last_error()
 		return
 	}
 
@@ -359,7 +359,7 @@ _readlink :: proc(path: string) -> (string, Error) {
 		rc := _unix_readlink(path_cstr, &(buf[0]), bufsz)
 		if rc == -1 {
 			delete(buf)
-			return "", Error(get_last_error())
+			return "", get_last_error()
 		} else if rc == int(bufsz) {
 			bufsz += MAX_PATH
 			delete(buf)
@@ -385,7 +385,7 @@ absolute_path_from_relative :: proc(rel: string) -> (path: string, err: Error) {
 
 	path_ptr := _unix_realpath(rel_cstr, nil)
 	if path_ptr == nil {
-		return "", Error(get_last_error())
+		return "", get_last_error()
 	}
 	defer _unix_free(path_ptr)
 
@@ -400,7 +400,7 @@ access :: proc(path: string, mask: int) -> (bool, Error) {
 	cstr := strings.clone_to_cstring(path, context.temp_allocator)
 	res := _unix_access(cstr, c.int(mask))
 	if res == -1 {
-		return false, Error(get_last_error())
+		return false, get_last_error()
 	}
 	return true, nil
 }

+ 7 - 7
core/os/os_linux.odin

@@ -563,7 +563,7 @@ execvp :: proc(path: string, args: []string) -> Error {
 	}
 
 	_unix_execvp(path_cstr, raw_data(args_cstrs))
-	return Error(get_last_error())
+	return get_last_error()
 }
 
 
@@ -809,7 +809,7 @@ _fstat :: proc(fd: Handle) -> (OS_Stat, Error) {
 _fdopendir :: proc(fd: Handle) -> (Dir, Error) {
 	dirp := _unix_fdopendir(fd)
 	if dirp == cast(Dir)nil {
-		return nil, Error(get_last_error())
+		return nil, get_last_error()
 	}
 	return dirp, nil
 }
@@ -818,7 +818,7 @@ _fdopendir :: proc(fd: Handle) -> (Dir, Error) {
 _closedir :: proc(dirp: Dir) -> Error {
 	rc := _unix_closedir(dirp)
 	if rc != 0 {
-		return Error(get_last_error())
+		return get_last_error()
 	}
 	return nil
 }
@@ -834,7 +834,7 @@ _readdir :: proc(dirp: Dir) -> (entry: Dirent, err: Error, end_of_stream: bool)
 	rc := _unix_readdir_r(dirp, &entry, &result)
 
 	if rc != 0 {
-		err = Error(get_last_error())
+		err = get_last_error()
 		return
 	}
 	err = nil
@@ -892,7 +892,7 @@ absolute_path_from_relative :: proc(rel: string) -> (path: string, err: Error) {
 
 	path_ptr := _unix_realpath(rel_cstr, nil)
 	if path_ptr == nil {
-		return "", Error(get_last_error())
+		return "", get_last_error()
 	}
 	defer _unix_free(path_ptr)
 
@@ -934,7 +934,7 @@ set_env :: proc(key, value: string) -> Error {
 	// NOTE(GoNZooo): `setenv` instead of `putenv` because it copies both key and value more commonly
 	res := _unix_setenv(key_cstring, value_cstring, 1)
 	if res < 0 {
-		return Error(get_last_error())
+		return get_last_error()
 	}
 	return nil
 }
@@ -944,7 +944,7 @@ unset_env :: proc(key: string) -> Error {
 	s := strings.clone_to_cstring(key, context.temp_allocator)
 	res := _unix_putenv(s)
 	if res < 0 {
-		return Error(get_last_error())
+		return get_last_error()
 	}
 	return nil
 }

+ 23 - 23
core/os/os_netbsd.odin

@@ -421,7 +421,7 @@ W_OK :: 2 // Test for write permission
 R_OK :: 4 // Test for read permission
 
 foreign libc {
-	@(link_name="__error")          __error_location    :: proc() -> ^c.int ---
+	@(link_name="__errno")          __errno_location    :: proc() -> ^c.int ---
 
 	@(link_name="open")             _unix_open          :: proc(path: cstring, flags: c.int, mode: c.int) -> Handle ---
 	@(link_name="close")            _unix_close         :: proc(fd: Handle) -> c.int ---
@@ -480,7 +480,7 @@ is_path_separator :: proc(r: rune) -> bool {
 
 @(require_results, no_instrumentation)
 get_last_error :: proc "contextless" () -> Error {
-	return Platform_Error(__error_location()^)
+	return Platform_Error(__errno_location()^)
 }
 
 @(require_results)
@@ -489,7 +489,7 @@ open :: proc(path: string, flags: int = O_RDONLY, mode: int = 0) -> (Handle, Err
 	cstr := strings.clone_to_cstring(path, context.temp_allocator)
 	handle := _unix_open(cstr, c.int(flags), c.int(mode))
 	if handle == -1 {
-		return INVALID_HANDLE, Error(get_last_error())
+		return INVALID_HANDLE, get_last_error()
 	}
 	return handle, nil
 }
@@ -497,7 +497,7 @@ open :: proc(path: string, flags: int = O_RDONLY, mode: int = 0) -> (Handle, Err
 close :: proc(fd: Handle) -> Error {
 	result := _unix_close(fd)
 	if result == -1 {
-		return Error(get_last_error())
+		return get_last_error()
 	}
 	return nil
 }
@@ -510,7 +510,7 @@ read :: proc(fd: Handle, data: []byte) -> (int, Error) {
 	to_read    := min(c.size_t(len(data)), MAX_RW)
 	bytes_read := _unix_read(fd, &data[0], to_read)
 	if bytes_read == -1 {
-		return -1, Error(get_last_error())
+		return -1, get_last_error()
 	}
 	return int(bytes_read), nil
 }
@@ -523,7 +523,7 @@ write :: proc(fd: Handle, data: []byte) -> (int, Error) {
 	to_write      := min(c.size_t(len(data)), MAX_RW)
 	bytes_written := _unix_write(fd, &data[0], to_write)
 	if bytes_written == -1 {
-		return -1, Error(get_last_error())
+		return -1, get_last_error()
 	}
 	return int(bytes_written), nil
 }
@@ -531,7 +531,7 @@ write :: proc(fd: Handle, data: []byte) -> (int, Error) {
 seek :: proc(fd: Handle, offset: i64, whence: int) -> (i64, Error) {
 	res := _unix_seek(fd, offset, c.int(whence))
 	if res == -1 {
-		return -1, Error(get_last_error())
+		return -1, get_last_error()
 	}
 	return res, nil
 }
@@ -549,7 +549,7 @@ rename :: proc(old_path, new_path: string) -> Error {
 	new_path_cstr := strings.clone_to_cstring(new_path, context.temp_allocator)
 	res := _unix_rename(old_path_cstr, new_path_cstr)
 	if res == -1 {
-		return Error(get_last_error())
+		return get_last_error()
 	}
 	return nil
 }
@@ -559,7 +559,7 @@ remove :: proc(path: string) -> Error {
 	path_cstr := strings.clone_to_cstring(path, context.temp_allocator)
 	res := _unix_unlink(path_cstr)
 	if res == -1 {
-		return Error(get_last_error())
+		return get_last_error()
 	}
 	return nil
 }
@@ -569,7 +569,7 @@ make_directory :: proc(path: string, mode: mode_t = 0o775) -> Error {
 	path_cstr := strings.clone_to_cstring(path, context.temp_allocator)
 	res := _unix_mkdir(path_cstr, mode)
 	if res == -1 {
-		return Error(get_last_error())
+		return get_last_error()
 	}
 	return nil
 }
@@ -579,7 +579,7 @@ remove_directory :: proc(path: string) -> Error {
 	path_cstr := strings.clone_to_cstring(path, context.temp_allocator)
 	res := _unix_rmdir(path_cstr)
 	if res == -1 {
-		return Error(get_last_error())
+		return get_last_error()
 	}
 	return nil
 }
@@ -641,7 +641,7 @@ exists :: proc(path: string) -> bool {
 fcntl :: proc(fd: int, cmd: int, arg: int) -> (int, Error) {
 	result := _unix_fcntl(Handle(fd), c.int(cmd), uintptr(arg))
 	if result < 0 {
-		return 0, Error(get_last_error())
+		return 0, get_last_error()
 	}
 	return int(result), nil
 }
@@ -671,7 +671,7 @@ _stat :: proc(path: string) -> (OS_Stat, Error) {
 	s: OS_Stat = ---
 	result := _unix_lstat(cstr, &s)
 	if result == -1 {
-		return s, Error(get_last_error())
+		return s, get_last_error()
 	}
 	return s, nil
 }
@@ -685,7 +685,7 @@ _lstat :: proc(path: string) -> (OS_Stat, Error) {
 	s: OS_Stat = ---
 	res := _unix_lstat(cstr, &s)
 	if res == -1 {
-		return s, Error(get_last_error())
+		return s, get_last_error()
 	}
 	return s, nil
 }
@@ -695,7 +695,7 @@ _fstat :: proc(fd: Handle) -> (OS_Stat, Error) {
 	s: OS_Stat = ---
 	result := _unix_fstat(fd, &s)
 	if result == -1 {
-		return s, Error(get_last_error())
+		return s, get_last_error()
 	}
 	return s, nil
 }
@@ -704,7 +704,7 @@ _fstat :: proc(fd: Handle) -> (OS_Stat, Error) {
 _fdopendir :: proc(fd: Handle) -> (Dir, Error) {
 	dirp := _unix_fdopendir(fd)
 	if dirp == cast(Dir)nil {
-		return nil, Error(get_last_error())
+		return nil, get_last_error()
 	}
 	return dirp, nil
 }
@@ -713,7 +713,7 @@ _fdopendir :: proc(fd: Handle) -> (Dir, Error) {
 _closedir :: proc(dirp: Dir) -> Error {
 	rc := _unix_closedir(dirp)
 	if rc != 0 {
-		return Error(get_last_error())
+		return get_last_error()
 	}
 	return nil
 }
@@ -729,7 +729,7 @@ _readdir :: proc(dirp: Dir) -> (entry: Dirent, err: Error, end_of_stream: bool)
 	rc := _unix_readdir_r(dirp, &entry, &result)
 
 	if rc != 0 {
-		err = Error(get_last_error())
+		err = get_last_error()
 		return
 	}
 	err = nil
@@ -754,7 +754,7 @@ _readlink :: proc(path: string) -> (string, Error) {
 		rc := _unix_readlink(path_cstr, &(buf[0]), bufsz)
 		if rc == -1 {
 			delete(buf)
-			return "", Error(get_last_error())
+			return "", get_last_error()
 		} else if rc == int(bufsz) {
 			bufsz += MAX_PATH
 			delete(buf)
@@ -784,7 +784,7 @@ absolute_path_from_relative :: proc(rel: string) -> (path: string, err: Error) {
 
 	path_ptr := _unix_realpath(rel_cstr, nil)
 	if path_ptr == nil {
-		return "", Error(get_last_error())
+		return "", get_last_error()
 	}
 	defer _unix_free(path_ptr)
 
@@ -799,7 +799,7 @@ access :: proc(path: string, mask: int) -> (bool, Error) {
 	cstr := strings.clone_to_cstring(path, context.temp_allocator)
 	result := _unix_access(cstr, c.int(mask))
 	if result == -1 {
-		return false, Error(get_last_error())
+		return false, get_last_error()
 	}
 	return true, nil
 }
@@ -831,7 +831,7 @@ get_current_directory :: proc() -> string {
 		if cwd != nil {
 			return string(cwd)
 		}
-		if Error(get_last_error()) != ERANGE {
+		if get_last_error() != ERANGE {
 			delete(buf)
 			return ""
 		}
@@ -845,7 +845,7 @@ set_current_directory :: proc(path: string) -> (err: Error) {
 	cstr := strings.clone_to_cstring(path, context.temp_allocator)
 	res := _unix_chdir(cstr)
 	if res == -1 {
-		return Error(get_last_error())
+		return get_last_error()
 	}
 	return nil
 }

+ 21 - 21
core/os/os_openbsd.odin

@@ -402,7 +402,7 @@ get_last_error :: proc "contextless" () -> Error {
 fork :: proc() -> (Pid, Error) {
 	pid := _unix_fork()
 	if pid == -1 {
-		return Pid(-1), Error(get_last_error())
+		return Pid(-1), get_last_error()
 	}
 	return Pid(pid), nil
 }
@@ -413,7 +413,7 @@ open :: proc(path: string, flags: int = O_RDONLY, mode: int = 0) -> (Handle, Err
 	cstr := strings.clone_to_cstring(path, context.temp_allocator)
 	handle := _unix_open(cstr, c.int(flags), c.int(mode))
 	if handle == -1 {
-		return INVALID_HANDLE, Error(get_last_error())
+		return INVALID_HANDLE, get_last_error()
 	}
 	return handle, nil
 }
@@ -421,7 +421,7 @@ open :: proc(path: string, flags: int = O_RDONLY, mode: int = 0) -> (Handle, Err
 close :: proc(fd: Handle) -> Error {
 	result := _unix_close(fd)
 	if result == -1 {
-		return Error(get_last_error())
+		return get_last_error()
 	}
 	return nil
 }
@@ -438,7 +438,7 @@ read :: proc(fd: Handle, data: []byte) -> (int, Error) {
 	to_read    := min(c.size_t(len(data)), MAX_RW)
 	bytes_read := _unix_read(fd, &data[0], to_read)
 	if bytes_read == -1 {
-		return -1, Error(get_last_error())
+		return -1, get_last_error()
 	}
 	return int(bytes_read), nil
 }
@@ -451,7 +451,7 @@ write :: proc(fd: Handle, data: []byte) -> (int, Error) {
 	to_write      := min(c.size_t(len(data)), MAX_RW)
 	bytes_written := _unix_write(fd, &data[0], to_write)
 	if bytes_written == -1 {
-		return -1, Error(get_last_error())
+		return -1, get_last_error()
 	}
 	return int(bytes_written), nil
 }
@@ -459,7 +459,7 @@ write :: proc(fd: Handle, data: []byte) -> (int, Error) {
 seek :: proc(fd: Handle, offset: i64, whence: int) -> (i64, Error) {
 	res := _unix_seek(fd, offset, c.int(whence))
 	if res == -1 {
-		return -1, Error(get_last_error())
+		return -1, get_last_error()
 	}
 	return res, nil
 }
@@ -477,7 +477,7 @@ rename :: proc(old_path, new_path: string) -> Error {
 	new_path_cstr := strings.clone_to_cstring(new_path, context.temp_allocator)
 	res := _unix_rename(old_path_cstr, new_path_cstr)
 	if res == -1 {
-		return Error(get_last_error())
+		return get_last_error()
 	}
 	return nil
 }
@@ -487,7 +487,7 @@ remove :: proc(path: string) -> Error {
 	path_cstr := strings.clone_to_cstring(path, context.temp_allocator)
 	res := _unix_unlink(path_cstr)
 	if res == -1 {
-		return Error(get_last_error())
+		return get_last_error()
 	}
 	return nil
 }
@@ -497,7 +497,7 @@ make_directory :: proc(path: string, mode: mode_t = 0o775) -> Error {
 	path_cstr := strings.clone_to_cstring(path, context.temp_allocator)
 	res := _unix_mkdir(path_cstr, mode)
 	if res == -1 {
-		return Error(get_last_error())
+		return get_last_error()
 	}
 	return nil
 }
@@ -507,7 +507,7 @@ remove_directory :: proc(path: string) -> Error {
 	path_cstr := strings.clone_to_cstring(path, context.temp_allocator)
 	res := _unix_rmdir(path_cstr)
 	if res == -1 {
-		return Error(get_last_error())
+		return get_last_error()
 	}
 	return nil
 }
@@ -590,7 +590,7 @@ _stat :: proc(path: string) -> (OS_Stat, Error) {
 	s: OS_Stat = ---
 	res := _unix_stat(cstr, &s)
 	if res == -1 {
-		return s, Error(get_last_error())
+		return s, get_last_error()
 	}
 	return s, nil
 }
@@ -604,7 +604,7 @@ _lstat :: proc(path: string) -> (OS_Stat, Error) {
 	s: OS_Stat = ---
 	res := _unix_lstat(cstr, &s)
 	if res == -1 {
-		return s, Error(get_last_error())
+		return s, get_last_error()
 	}
 	return s, nil
 }
@@ -615,7 +615,7 @@ _fstat :: proc(fd: Handle) -> (OS_Stat, Error) {
 	s: OS_Stat = ---
 	res := _unix_fstat(fd, &s)
 	if res == -1 {
-		return s, Error(get_last_error())
+		return s, get_last_error()
 	}
 	return s, nil
 }
@@ -624,7 +624,7 @@ _fstat :: proc(fd: Handle) -> (OS_Stat, Error) {
 _fdopendir :: proc(fd: Handle) -> (Dir, Error) {
 	dirp := _unix_fdopendir(fd)
 	if dirp == cast(Dir)nil {
-		return nil, Error(get_last_error())
+		return nil, get_last_error()
 	}
 	return dirp, nil
 }
@@ -633,7 +633,7 @@ _fdopendir :: proc(fd: Handle) -> (Dir, Error) {
 _closedir :: proc(dirp: Dir) -> Error {
 	rc := _unix_closedir(dirp)
 	if rc != 0 {
-		return Error(get_last_error())
+		return get_last_error()
 	}
 	return nil
 }
@@ -649,7 +649,7 @@ _readdir :: proc(dirp: Dir) -> (entry: Dirent, err: Error, end_of_stream: bool)
 	rc := _unix_readdir_r(dirp, &entry, &result)
 
 	if rc != 0 {
-		err = Error(get_last_error())
+		err = get_last_error()
 		return
 	}
 	err = nil
@@ -673,7 +673,7 @@ _readlink :: proc(path: string) -> (string, Error) {
 		rc := _unix_readlink(path_cstr, &(buf[0]), bufsz)
 		if rc == -1 {
 			delete(buf)
-			return "", Error(get_last_error())
+			return "", get_last_error()
 		} else if rc == int(bufsz) {
 			bufsz += MAX_PATH
 			delete(buf)
@@ -700,7 +700,7 @@ absolute_path_from_relative :: proc(rel: string) -> (path: string, err: Error) {
 
 	path_ptr := _unix_realpath(rel_cstr, nil)
 	if path_ptr == nil {
-		return "", Error(get_last_error())
+		return "", get_last_error()
 	}
 	defer _unix_free(path_ptr)
 
@@ -714,7 +714,7 @@ access :: proc(path: string, mask: int) -> (bool, Error) {
 	cstr := strings.clone_to_cstring(path, context.temp_allocator)
 	res := _unix_access(cstr, c.int(mask))
 	if res == -1 {
-		return false, Error(get_last_error())
+		return false, get_last_error()
 	}
 	return true, nil
 }
@@ -741,7 +741,7 @@ get_current_directory :: proc() -> string {
 		if cwd != nil {
 			return string(cwd)
 		}
-		if Error(get_last_error()) != ERANGE {
+		if get_last_error() != ERANGE {
 			delete(buf)
 			return ""
 		}
@@ -755,7 +755,7 @@ set_current_directory :: proc(path: string) -> (err: Error) {
 	cstr := strings.clone_to_cstring(path, context.temp_allocator)
 	res := _unix_chdir(cstr)
 	if res == -1 {
-		return Error(get_last_error())
+		return get_last_error()
 	}
 	return nil
 }