fix compiler warnings and release mode u32 overflow
This commit is contained in:
parent
9550d34e65
commit
704b14b2a0
3 changed files with 12 additions and 7 deletions
|
|
@ -1,6 +1,7 @@
|
|||
#pragma once
|
||||
|
||||
#include <stdio.h>
|
||||
#include <string.h>
|
||||
#include <sys/stat.h>
|
||||
|
||||
#include "pxl8_types.h"
|
||||
|
|
@ -60,7 +61,9 @@ static inline i32 pxl8_read_i32(pxl8_stream* stream) {
|
|||
|
||||
static inline f32 pxl8_read_f32(pxl8_stream* stream) {
|
||||
u32 val = pxl8_read_u32(stream);
|
||||
return *(f32*)&val;
|
||||
f32 result;
|
||||
memcpy(&result, &val, sizeof(f32));
|
||||
return result;
|
||||
}
|
||||
|
||||
static inline void pxl8_read_bytes(pxl8_stream* stream, void* dest, u32 count) {
|
||||
|
|
|
|||
|
|
@ -467,12 +467,12 @@ void pxl8_procgen_tex(u8* buffer, const pxl8_procgen_tex_params* params) {
|
|||
i32 ix = (i32)((f32)x * params->scale);
|
||||
i32 iy = (i32)((f32)y * params->scale);
|
||||
|
||||
u32 block_hash = (ix * 374761393 + iy * 668265263) ^ params->seed;
|
||||
u32 block_hash = ((u32)ix * 374761393u + (u32)iy * 668265263u) ^ params->seed;
|
||||
block_hash ^= block_hash >> 13;
|
||||
block_hash ^= block_hash << 17;
|
||||
block_hash ^= block_hash >> 5;
|
||||
|
||||
u32 pixel_hash = (x * 1597334677 + y * 3812015801) ^ params->seed;
|
||||
u32 pixel_hash = ((u32)x * 1597334677u + (u32)y * 3812015801u) ^ params->seed;
|
||||
pixel_hash ^= pixel_hash >> 13;
|
||||
pixel_hash ^= pixel_hash << 17;
|
||||
pixel_hash ^= pixel_hash >> 5;
|
||||
|
|
|
|||
|
|
@ -18,7 +18,7 @@ struct pxl8_script {
|
|||
pxl8_gfx* gfx;
|
||||
pxl8_input_state* input;
|
||||
pxl8_ui* ui;
|
||||
char last_error[1024];
|
||||
char last_error[2048];
|
||||
char main_path[256];
|
||||
char watch_dir[256];
|
||||
time_t latest_mod_time;
|
||||
|
|
@ -56,7 +56,7 @@ static void pxl8_script_repl_promote_locals(const char* input, char* output, siz
|
|||
|
||||
if (!in_string && input[i] == '(' &&
|
||||
strncmp(&input[i], "(local ", 7) == 0) {
|
||||
strncpy(&output[j], "(global ", 8);
|
||||
memcpy(&output[j], "(global ", 8);
|
||||
j += 8;
|
||||
i += 7;
|
||||
continue;
|
||||
|
|
@ -847,8 +847,10 @@ static void* pxl8_script_repl_stdin_thread(void* user_data) {
|
|||
|
||||
u32 next_tail = (repl->tail + 1) % PXL8_REPL_RING_BUFFER_SIZE;
|
||||
if (next_tail != repl->head) {
|
||||
strncpy(repl->ring_buffer[repl->tail].buffer, repl->accumulator, PXL8_MAX_REPL_COMMAND_SIZE - 1);
|
||||
repl->ring_buffer[repl->tail].buffer[PXL8_MAX_REPL_COMMAND_SIZE - 1] = '\0';
|
||||
size_t len = strlen(repl->accumulator);
|
||||
size_t copy_len = len < PXL8_MAX_REPL_COMMAND_SIZE - 1 ? len : PXL8_MAX_REPL_COMMAND_SIZE - 1;
|
||||
memcpy(repl->ring_buffer[repl->tail].buffer, repl->accumulator, copy_len);
|
||||
repl->ring_buffer[repl->tail].buffer[copy_len] = '\0';
|
||||
repl->tail = next_tail;
|
||||
repl->waiting_for_eval = true;
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue