summaryrefslogtreecommitdiff
path: root/src/core
diff options
context:
space:
mode:
authoronelin <oscar@nelin.dk>2025-03-16 21:28:34 +0000
committeronelin <oscar@nelin.dk>2025-03-16 21:28:34 +0000
commit6232b36ae110e9f7b306307c9bc44b0fdaf820e1 (patch)
tree03018820812c54bd94ac4b4e87d7d4ebba7e5bcb /src/core
parentd254403ae15b572735ab7fa00780d689d028353f (diff)
Fix some core warnings
Diffstat (limited to 'src/core')
-rw-r--r--src/core/src/loop.c33
1 files changed, 20 insertions, 13 deletions
diff --git a/src/core/src/loop.c b/src/core/src/loop.c
index 85e8cf6..07ce707 100644
--- a/src/core/src/loop.c
+++ b/src/core/src/loop.c
@@ -57,8 +57,8 @@ void delay( uint64_t us )
Sleep( ms );
#else
struct timespec ts = {
- .tv_sec = us / 1000000,
- .tv_nsec = (us * 1000) % 1000000000
+ .tv_sec = (i64)us / 1000000,
+ .tv_nsec = ((i64)us * 1000) % 1000000000
};
struct timespec rem = {0,0};
int err = 0;
@@ -73,6 +73,9 @@ void delay( uint64_t us )
case ENOTSUP:
WARN("clock_nanosleep didn't sleep full duration: unsupported clock.");
break;
+ default:
+ WARN("clock_nanosleep didn't sleep full duration!");
+ break;
}
ts = rem;
rem = (struct timespec){0,0};
@@ -95,12 +98,6 @@ i32 cmp_int(const void* a, const void* b) {
// return realsize;
//}
-void engine_update_window(Window* w, void* e) {
- //WARN("Unhandled function", (i32)e);
- return;
-}
-
-
/* Creates the window, initializes IO, Rendering, Fonts and engine-specific
* resources. */
Platform* engine_init(const char* windowtitle, i32 windowWidth, i32 windowHeight,
@@ -335,8 +332,6 @@ i32 engine_run(Platform* p, StateType initial_state, void* state_arg) {
/* Delta is relative to FPS cap */
//const f64 delta = (f64)dt / (f64)fps_cap;
- frame_end = frame_start;
-
/* Events */
glfwPollEvents();
i_flush_bindings(dt, callbacks_len, callbacks, mem->data);
@@ -394,7 +389,7 @@ i32 engine_run(Platform* p, StateType initial_state, void* state_arg) {
"\tframetime: %luμs"
"\trendertime: %luμs"
"\n"
- , ((f64)(ticks - last_fps_ticks)) / (dt_measurement / 1000000.0)
+ , ((f64)(ticks - last_fps_ticks)) / ((f64)dt_measurement / 1000000.0)
, ticks
, dt
, rendertime_dt
@@ -448,9 +443,21 @@ isize f_get_sz(FILE* f) {
}
const isize pos = ftell(f);
+ if (pos == -1) {
+ ERROR("Failed to determine file size (%d): %s", errno, strerror(errno));
+ }
+
+ const i32 err = fseek(f, 0, SEEK_END);
+ if (err != 0) {
+ if (err == ESPIPE) return 0;
+ ERROR("Failed to determine file size!");
+ }
- fseek(f, 0, SEEK_END);
- const i64 size = ftell(f);
+ const isize size = ftell(f);
+
+ if (size == -1) {
+ ERROR("Failed to determine file size (%d): %s", errno, strerror(errno));
+ }
// Reset the position to the position prior to calling f_get_sz
fseek(f, pos, SEEK_SET);