Fix warnings

This commit is contained in:
2025-08-17 14:42:39 +02:00
parent 504c4582e1
commit e67eb4175b
3 changed files with 36 additions and 15 deletions
+27 -11
View File
@@ -68,12 +68,14 @@ static bool is_hex_digit(char c)
return (c >= '0' && c <= '9') || (c >= 'a' && c <= 'f') || (c >= 'A' && c <= 'F'); return (c >= '0' && c <= '9') || (c >= 'a' && c <= 'f') || (c >= 'A' && c <= 'F');
} }
#if 0
static char to_lower(char c) static char to_lower(char c)
{ {
if (c >= 'A' && c <= 'Z') if (c >= 'A' && c <= 'Z')
return c - 'A' + 'a'; return c - 'A' + 'a';
return c; return c;
} }
#endif
static int hex_digit_to_int(char c) static int hex_digit_to_int(char c)
{ {
@@ -96,6 +98,7 @@ static bool streq(String a, String b)
return true; return true;
} }
#if 0
static bool streqcase(String a, String b) static bool streqcase(String a, String b)
{ {
if (a.len != b.len) if (a.len != b.len)
@@ -105,7 +108,7 @@ static bool streqcase(String a, String b)
return false; return false;
return true; return true;
} }
#endif
#define REPORT(err, fmt, ...) report((err), __FILE__, __LINE__, fmt, ## __VA_ARGS__) #define REPORT(err, fmt, ...) report((err), __FILE__, __LINE__, fmt, ## __VA_ARGS__)
static void report(Error *err, char *file, int line, char *fmt, ...) static void report(Error *err, char *file, int line, char *fmt, ...)
@@ -158,6 +161,7 @@ static bool grow_alloc(WL_Arena *a, char *p, int new_len)
return true; return true;
} }
#if 0
static String copystr(String s, WL_Arena *a) static String copystr(String s, WL_Arena *a)
{ {
char *p = alloc(a, s.len, 1); char *p = alloc(a, s.len, 1);
@@ -166,6 +170,7 @@ static String copystr(String s, WL_Arena *a)
memcpy(p, s.ptr, s.len); memcpy(p, s.ptr, s.len);
return (String) { p, s.len }; return (String) { p, s.len };
} }
#endif
///////////////////////////////////////////////////////////////////////// /////////////////////////////////////////////////////////////////////////
// WRITER // WRITER
@@ -188,14 +193,14 @@ static void write_raw_mem(Writer *w, void *ptr, int len)
} }
static void write_raw_u8 (Writer *w, uint8_t x) { write_raw_mem(w, &x, SIZEOF(x)); } static void write_raw_u8 (Writer *w, uint8_t x) { write_raw_mem(w, &x, SIZEOF(x)); }
static void write_raw_u16(Writer *w, uint16_t x) { write_raw_mem(w, &x, SIZEOF(x)); } //static void write_raw_u16(Writer *w, uint16_t x) { write_raw_mem(w, &x, SIZEOF(x)); }
static void write_raw_u32(Writer *w, uint32_t x) { write_raw_mem(w, &x, SIZEOF(x)); } static void write_raw_u32(Writer *w, uint32_t x) { write_raw_mem(w, &x, SIZEOF(x)); }
static void write_raw_u64(Writer *w, uint64_t x) { write_raw_mem(w, &x, SIZEOF(x)); } //static void write_raw_u64(Writer *w, uint64_t x) { write_raw_mem(w, &x, SIZEOF(x)); }
static void write_raw_s8 (Writer *w, int8_t x) { write_raw_mem(w, &x, SIZEOF(x)); } //static void write_raw_s8 (Writer *w, int8_t x) { write_raw_mem(w, &x, SIZEOF(x)); }
static void write_raw_s16(Writer *w, int16_t x) { write_raw_mem(w, &x, SIZEOF(x)); } //static void write_raw_s16(Writer *w, int16_t x) { write_raw_mem(w, &x, SIZEOF(x)); }
static void write_raw_s32(Writer *w, int32_t x) { write_raw_mem(w, &x, SIZEOF(x)); } //static void write_raw_s32(Writer *w, int32_t x) { write_raw_mem(w, &x, SIZEOF(x)); }
static void write_raw_s64(Writer *w, int64_t x) { write_raw_mem(w, &x, SIZEOF(x)); } static void write_raw_s64(Writer *w, int64_t x) { write_raw_mem(w, &x, SIZEOF(x)); }
static void write_raw_f32(Writer *w, float x) { write_raw_mem(w, &x, SIZEOF(x)); } //static void write_raw_f32(Writer *w, float x) { write_raw_mem(w, &x, SIZEOF(x)); }
static void write_raw_f64(Writer *w, double x) { write_raw_mem(w, &x, SIZEOF(x)); } static void write_raw_f64(Writer *w, double x) { write_raw_mem(w, &x, SIZEOF(x)); }
static void write_text(Writer *w, String str) static void write_text(Writer *w, String str)
@@ -410,6 +415,7 @@ static bool consume_str(Scanner *s, String x)
return true; return true;
} }
#if 0
static void write_token(Writer *w, Token token) static void write_token(Writer *w, Token token)
{ {
switch (token.type) { switch (token.type) {
@@ -463,6 +469,7 @@ static void write_token(Writer *w, Token token)
} }
} }
#endif
static void parser_report(Parser *p, char *fmt, ...) static void parser_report(Parser *p, char *fmt, ...)
{ {
@@ -1990,6 +1997,14 @@ static void write_node(Writer *w, Node *node)
write_text(w, S(")")); write_text(w, S(")"));
break; break;
case NODE_OPER_SHOVEL:
write_text(w, S("("));
write_node(w, node->left);
write_text(w, S("<<"));
write_node(w, node->right);
write_text(w, S(")"));
break;
case NODE_VALUE_INT: case NODE_VALUE_INT:
write_text_s64(w, node->ival); write_text_s64(w, node->ival);
break; break;
@@ -3440,7 +3455,7 @@ static int write_instr(Writer *w, char *src, int len, String data)
static int write_program(WL_Program program, char *dst, int cap) static int write_program(WL_Program program, char *dst, int cap)
{ {
if (program.len < 3 * sizeof(uint32_t)) if ((uint32_t) program.len < 3 * sizeof(uint32_t))
return -1; return -1;
uint32_t magic; uint32_t magic;
@@ -3454,7 +3469,7 @@ static int write_program(WL_Program program, char *dst, int cap)
if (magic != WL_MAGIC) if (magic != WL_MAGIC)
return -1; return -1;
if (code_len + data_len + 3 * sizeof(uint32_t) != program.len) if (code_len + data_len + 3 * sizeof(uint32_t) != (uint32_t) program.len)
return -1; return -1;
String code = { program.ptr + 3 * sizeof(uint32_t) , code_len }; String code = { program.ptr + 3 * sizeof(uint32_t) , code_len };
@@ -4529,7 +4544,7 @@ struct WL_Runtime {
WL_Runtime *wl_runtime_init(WL_Arena *arena, WL_Program program) WL_Runtime *wl_runtime_init(WL_Arena *arena, WL_Program program)
{ {
if (program.len < 3 * sizeof(uint32_t)) if ((uint32_t) program.len < 3 * sizeof(uint32_t))
return NULL; return NULL;
uint32_t magic; uint32_t magic;
@@ -4631,7 +4646,7 @@ static String rt_read_str(WL_Runtime *rt)
ASSERT(rt->state == RUNTIME_LOOP); ASSERT(rt->state == RUNTIME_LOOP);
uint32_t off = rt_read_u32(rt); uint32_t off = rt_read_u32(rt);
uint32_t len = rt_read_u32(rt); uint32_t len = rt_read_u32(rt);
ASSERT(off + len <= rt->data.len); ASSERT(off + len <= (uint32_t) rt->data.len);
return (String) { rt->data.ptr + off, len }; return (String) { rt->data.ptr + off, len };
} }
@@ -5142,6 +5157,7 @@ WL_EvalResult wl_runtime_eval(WL_Runtime *rt)
switch (rt->state) { switch (rt->state) {
case RUNTIME_BEGIN:
case RUNTIME_LOOP: case RUNTIME_LOOP:
UNREACHABLE; UNREACHABLE;
+1 -1
View File
@@ -113,7 +113,7 @@ int user_exists(SQLiteCache *dbcache, HTTP_String name, HTTP_String pass)
int rawhashlen = sqlite3_column_bytes(stmt, 1); int rawhashlen = sqlite3_column_bytes(stmt, 1);
PasswordHash hash; PasswordHash hash;
if (rawhashlen >= sizeof(hash.data)) { if (rawhashlen >= (int) sizeof(hash.data)) {
sqlite3_reset(stmt); sqlite3_reset(stmt);
return -500; return -500;
} }
+8 -3
View File
@@ -81,7 +81,7 @@ struct LoadedFile {
char data[]; char data[];
}; };
static LoadedFile *load_file(WL_String path, WL_Arena *arena) static LoadedFile *load_file(WL_String path)
{ {
char buf[1<<10]; char buf[1<<10];
if (path.len >= (int) sizeof(buf)) if (path.len >= (int) sizeof(buf))
@@ -153,7 +153,7 @@ static int compile(WL_String path, WL_Program *program, WL_Arena *arena)
for (int i = 0;; i++) { for (int i = 0;; i++) {
LoadedFile *loaded_file = load_file(path, arena); LoadedFile *loaded_file = load_file(path);
if (loaded_file == NULL) { if (loaded_file == NULL) {
TRACE("Couldn't load file '%.*s'", path.len, path.ptr); TRACE("Couldn't load file '%.*s'", path.len, path.ptr);
free_loaded_files(loaded_file_head); free_loaded_files(loaded_file_head);
@@ -295,6 +295,8 @@ static int query_routine(WL_Runtime *rt, SQLiteCache *dbcache)
static void push_sysvar(WL_Runtime *rt, WL_String name, SQLiteCache *dbcache, int user_id, int post_id) static void push_sysvar(WL_Runtime *rt, WL_String name, SQLiteCache *dbcache, int user_id, int post_id)
{ {
(void) dbcache;
if (wl_streq(name, "login_user_id", -1)) { if (wl_streq(name, "login_user_id", -1)) {
if (user_id < 0) if (user_id < 0)
@@ -337,7 +339,7 @@ static int get_or_create_program(TemplateCache *cache, WL_String path, WL_Arena
memcpy(p, program.ptr, program.len); memcpy(p, program.ptr, program.len);
program.ptr = p; program.ptr = p;
if (sizeof(cache->pool->path) <= path.len) if ((int) sizeof(cache->pool->path) <= path.len)
return -1; return -1;
memcpy(cache->pool[i].path, path.ptr, path.len); memcpy(cache->pool[i].path, path.ptr, path.len);
cache->pool[i].path[path.len] = '\0'; cache->pool[i].path[path.len] = '\0';
@@ -402,6 +404,9 @@ void template_eval(HTTP_ResponseBuilder builder, int status,
case WL_EVAL_OUTPUT: case WL_EVAL_OUTPUT:
http_response_builder_body(builder, (HTTP_String) { result.str.ptr, result.str.len }); http_response_builder_body(builder, (HTTP_String) { result.str.ptr, result.str.len });
break; break;
default:
break;
} }
} }
} }