mirror of
https://github.com/odin-lang/Odin.git
synced 2026-06-10 12:28:11 +00:00
More style improvements
This commit is contained in:
@@ -78,7 +78,7 @@ _Context :: struct {
|
||||
|
||||
@(private="package")
|
||||
_init :: proc(ctx: ^Context) -> (ok: bool) {
|
||||
defer if !ok do destroy(ctx)
|
||||
defer if !ok { destroy(ctx) }
|
||||
|
||||
ctx.impl.state = backtrace_create_state("odin-debug-trace", 1, nil, ctx)
|
||||
return ctx.impl.state != nil
|
||||
|
||||
@@ -274,8 +274,7 @@ _set_option :: proc(s: Any_Socket, option: Socket_Option, value: any, loc := #ca
|
||||
.Linger,
|
||||
.Send_Timeout,
|
||||
.Receive_Timeout:
|
||||
t, ok := value.(time.Duration)
|
||||
if !ok do panic("set_option() value must be a time.Duration here", loc)
|
||||
t := value.(time.Duration) or_else panic("set_option() value must be a time.Duration here", loc)
|
||||
|
||||
micros := i64(time.duration_microseconds(t))
|
||||
timeval_value.microseconds = int(micros % 1e6)
|
||||
|
||||
@@ -263,12 +263,15 @@ _set_option :: proc(s: Any_Socket, option: Socket_Option, value: any, loc := #ca
|
||||
ptr = &bool_value
|
||||
len = size_of(bool_value)
|
||||
case .Linger:
|
||||
t, ok := value.(time.Duration)
|
||||
if !ok do panic("set_option() value must be a time.Duration here", loc)
|
||||
t := value.(time.Duration) or_else panic("set_option() value must be a time.Duration here", loc)
|
||||
|
||||
num_secs := i64(time.duration_seconds(t))
|
||||
if time.Duration(num_secs * 1e9) != t do return .Linger_Only_Supports_Whole_Seconds
|
||||
if num_secs > i64(max(u16)) do return .Value_Out_Of_Range
|
||||
if time.Duration(num_secs * 1e9) != t {
|
||||
return .Linger_Only_Supports_Whole_Seconds
|
||||
}
|
||||
if num_secs > i64(max(u16)) {
|
||||
return .Value_Out_Of_Range
|
||||
}
|
||||
linger_value.l_onoff = 1
|
||||
linger_value.l_linger = c.ushort(num_secs)
|
||||
|
||||
@@ -277,8 +280,7 @@ _set_option :: proc(s: Any_Socket, option: Socket_Option, value: any, loc := #ca
|
||||
case
|
||||
.Receive_Timeout,
|
||||
.Send_Timeout:
|
||||
t, ok := value.(time.Duration)
|
||||
if !ok do panic("set_option() value must be a time.Duration here", loc)
|
||||
t := value.(time.Duration) or_else panic("set_option() value must be a time.Duration here", loc)
|
||||
|
||||
int_value = i32(time.duration_milliseconds(t))
|
||||
ptr = &int_value
|
||||
|
||||
@@ -705,7 +705,9 @@ set_current_directory :: proc(path: string) -> (err: Errno) {
|
||||
runtime.DEFAULT_TEMP_ALLOCATOR_TEMP_GUARD()
|
||||
cstr := strings.clone_to_cstring(path, context.temp_allocator)
|
||||
res := _unix_chdir(cstr)
|
||||
if res == -1 do return Errno(get_last_error())
|
||||
if res == -1 {
|
||||
return Errno(get_last_error())
|
||||
}
|
||||
return ERROR_NONE
|
||||
}
|
||||
|
||||
@@ -743,7 +745,9 @@ get_page_size :: proc() -> int {
|
||||
// NOTE(tetra): The page size never changes, so why do anything complicated
|
||||
// if we don't have to.
|
||||
@static page_size := -1
|
||||
if page_size != -1 do return page_size
|
||||
if page_size != -1 {
|
||||
return page_size
|
||||
}
|
||||
|
||||
page_size = int(_unix_getpagesize())
|
||||
return page_size
|
||||
|
||||
@@ -714,7 +714,9 @@ set_current_directory :: proc(path: string) -> (err: Errno) {
|
||||
runtime.DEFAULT_TEMP_ALLOCATOR_TEMP_GUARD()
|
||||
cstr := strings.clone_to_cstring(path, context.temp_allocator)
|
||||
res := _unix_chdir(cstr)
|
||||
if res == -1 do return Errno(get_last_error())
|
||||
if res == -1 {
|
||||
return Errno(get_last_error())
|
||||
}
|
||||
return ERROR_NONE
|
||||
}
|
||||
|
||||
@@ -755,7 +757,9 @@ get_page_size :: proc() -> int {
|
||||
// NOTE(tetra): The page size never changes, so why do anything complicated
|
||||
// if we don't have to.
|
||||
@static page_size := -1
|
||||
if page_size != -1 do return page_size
|
||||
if page_size != -1 {
|
||||
return page_size
|
||||
}
|
||||
|
||||
page_size = int(_unix_getpagesize())
|
||||
return page_size
|
||||
|
||||
@@ -192,7 +192,7 @@ StringCopyToOdinString :: proc(
|
||||
max := StringGetMaximumSizeForEncoding(length, StringEncoding(StringBuiltInEncodings.UTF8))
|
||||
|
||||
buf, err := make([]byte, max, allocator)
|
||||
if err != nil do return
|
||||
if err != nil { return }
|
||||
|
||||
raw_str := runtime.Raw_String {
|
||||
data = raw_data(buf),
|
||||
|
||||
4
vendor/ENet/win32.odin
vendored
4
vendor/ENet/win32.odin
vendored
@@ -39,7 +39,9 @@ foreign WinSock2 {
|
||||
return
|
||||
}
|
||||
}
|
||||
if s.fd_count >= FD_SETSIZE do return
|
||||
if s.fd_count >= FD_SETSIZE {
|
||||
return
|
||||
}
|
||||
s.fd_array[s.fd_count] = fd
|
||||
s.fd_count += 1
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user