Browse Source

fix some bugs with -disable-assert

Laytan Laats 1 year ago
parent
commit
28fac62a02

+ 2 - 1
base/runtime/wasm_allocator.odin

@@ -297,7 +297,8 @@ lock :: proc(a: ^WASM_Allocator) {
 					return
 				}
 
-				assert(intrinsics.wasm_memory_atomic_wait32((^u32)(&a.mu), u32(new_state), -1) != 0)
+				ret := intrinsics.wasm_memory_atomic_wait32((^u32)(&a.mu), u32(new_state), -1)
+				assert(ret != 0)
 				intrinsics.cpu_relax()
 			}
 		}

+ 2 - 1
core/encoding/cbor/marshal.odin

@@ -351,7 +351,8 @@ _marshal_into_encoder :: proc(e: Encoder, v: any, ti: ^runtime.Type_Info) -> (er
 				builder := strings.builder_from_slice(res[:])
 				e.writer = strings.to_stream(&builder)
 
-				assert(_encode_u64(e, u64(len(str)), .Text) == nil)
+				err := _encode_u64(e, u64(len(str)), .Text)
+				assert(err == nil)
 				res[9] = u8(len(builder.buf))
 				assert(res[9] < 10)
 				return

+ 2 - 1
core/encoding/cbor/unmarshal.odin

@@ -96,7 +96,8 @@ _unmarshal_value :: proc(d: Decoder, v: any, hdr: Header, allocator := context.a
 			ti = reflect.type_info_base(variant)
 			if !reflect.is_pointer_internally(variant) {
 				tag := any{rawptr(uintptr(v.data) + u.tag_offset), u.tag_type.id}
-				assert(_assign_int(tag, 1))
+				assigned := _assign_int(tag, 1)
+				assert(assigned)
 			}
 		}
 	}

+ 2 - 2
core/testing/runner.odin

@@ -654,8 +654,8 @@ runner :: proc(internal_tests: []Internal_Test) -> bool {
 			#no_bounds_check pkg := report.packages_by_name[it.pkg]
 			pkg.frame_ready = false
 
-			fmt.assertf(thread.pool_stop_task(&pool, test_index),
-				"A signal (%v) was raised to stop test #%i %s.%s, but it was unable to be found.",
+			found := thread.pool_stop_task(&pool, test_index)
+			fmt.assertf(found, "A signal (%v) was raised to stop test #%i %s.%s, but it was unable to be found.",
 				reason, test_index, it.pkg, it.name)
 
 			// The order this is handled in is a little particular.

+ 5 - 3
core/thread/thread_unix.odin

@@ -81,9 +81,12 @@ _create :: proc(procedure: Thread_Proc, priority: Thread_Priority) -> ^Thread {
 	defer unix.pthread_attr_destroy(&attrs)
 
 	// NOTE(tetra, 2019-11-01): These only fail if their argument is invalid.
-	assert(unix.pthread_attr_setdetachstate(&attrs, unix.PTHREAD_CREATE_JOINABLE) == 0)
+	res: i32
+	res = unix.pthread_attr_setdetachstate(&attrs, unix.PTHREAD_CREATE_JOINABLE)
+	assert(res == 0)
 	when ODIN_OS != .Haiku && ODIN_OS != .NetBSD {
-		assert(unix.pthread_attr_setinheritsched(&attrs, unix.PTHREAD_EXPLICIT_SCHED) == 0)
+		res = unix.pthread_attr_setinheritsched(&attrs, unix.PTHREAD_EXPLICIT_SCHED)
+		assert(res == 0)
 	}
 
 	thread := new(Thread)
@@ -94,7 +97,6 @@ _create :: proc(procedure: Thread_Proc, priority: Thread_Priority) -> ^Thread {
 
 	// Set thread priority.
 	policy: i32
-	res: i32
 	when ODIN_OS != .Haiku && ODIN_OS != .NetBSD {
 		res = unix.pthread_attr_getschedpolicy(&attrs, &policy)
 		assert(res == 0)

+ 2 - 1
vendor/wgpu/wgpu_js.odin

@@ -22,5 +22,6 @@ wgpu_alloc :: proc "contextless" (size: i32) -> [^]byte {
 @(private="file", export)
 wgpu_free :: proc "contextless" (ptr: rawptr) {
 	context = g_context
-	assert(free(ptr) == nil, "wgpu_free failed")
+	err := free(ptr)
+	assert(err == nil, "wgpu_free failed")
 }