fix compiler warnings

This commit is contained in:
2026-02-20 12:44:18 -06:00
parent 54e5be0773
commit c0aff9e9bf
13 changed files with 33 additions and 24 deletions

View File

@@ -42,7 +42,7 @@ static JSValue js_miniz_read(JSContext *js, JSValue self, int argc, JSValue *arg
{
size_t len;
void *data = js_get_blob_data(js, &len, argv[0]);
if (data == -1)
if (data == (void *)-1)
return JS_EXCEPTION;
mz_zip_archive *zip = calloc(sizeof(*zip), 1);
@@ -109,7 +109,7 @@ static JSValue js_miniz_compress(JSContext *js, JSValue this_val,
in_ptr = cstring;
} else {
in_ptr = js_get_blob_data(js, &in_len, argv[0]);
if (in_ptr == -1)
if (in_ptr == (const void *)-1)
return JS_EXCEPTION;
}
@@ -153,7 +153,7 @@ static JSValue js_miniz_decompress(JSContext *js,
/* grab compressed data */
size_t in_len;
void *in_ptr = js_get_blob_data(js, &in_len, argv[0]);
if (in_ptr == -1)
if (in_ptr == (void *)-1)
return JS_EXCEPTION;
/* zlib header present → tell tinfl to parse it */
@@ -196,7 +196,7 @@ JSValue js_writer_add_file(JSContext *js, JSValue self, int argc, JSValue *argv)
size_t dataLen;
void *data = js_get_blob_data(js, &dataLen, argv[1]);
if (data == -1) {
if (data == (void *)-1) {
JS_FreeCString(js, pathInZip);
return JS_EXCEPTION;
}

View File

@@ -56,7 +56,7 @@
static void *get_blob_check_bits(JSContext *js, JSValue val, size_t expected_bits, const char *name) {
size_t bits;
void* result = js_get_blob_data_bits(js, &bits, val);
if (result == -1) {
if (result == (void *)-1) {
return NULL; // Exception already thrown by js_get_blob_data_bits
}
@@ -70,7 +70,7 @@ static void *get_blob_check_bits(JSContext *js, JSValue val, size_t expected_bit
// Helper to get any blob data (checking it is a stoned blob)
static void *get_blob_any(JSContext *js, JSValue val, size_t *out_bits, const char *name) {
void *result = js_get_blob_data_bits(js, out_bits, val);
if (result == -1)
if (result == (void *)-1)
return NULL;
return result;
}

View File

@@ -40,7 +40,8 @@ static int js2fd(JSContext *ctx, JSValueConst val)
// Helper function for writing
static ssize_t js_fd_write_helper(JSContext *js, int fd, JSValue val)
{
(void)js; (void)fd; (void)val;
return -1;
}
@@ -85,7 +86,7 @@ JSC_CCALL(fd_write,
JS_FreeCString(js, data);
} else {
void *data = js_get_blob_data(js, &len, argv[1]);
if (data == -1)
if (data == (void *)-1)
return JS_EXCEPTION;
wrote = write(fd, data, len);
}

View File

@@ -140,7 +140,7 @@ foreach inc : includes
includers += include_directories(inc)
endforeach
qbe_c_args = ['-x', 'c']
qbe_c_args = ['-x', 'c', '-Wno-deprecated-declarations']
qbe_lib = static_library('qbe',
qbe_files,
include_directories: includers,

View File

@@ -146,7 +146,6 @@ static JSValue js_enet_host_service(JSContext *ctx, JSValueConst this_val, int a
if (!host) return JS_EXCEPTION;
if (argc < 1 || !JS_IsFunction(argv[0])) return JS_RaiseDisrupt(ctx, "Expected a callback function as first argument");
JSValue callback = JS_DupValue(ctx, argv[0]);
double secs;
JS_ToFloat64(ctx, &secs, argv[1]);
@@ -186,7 +185,6 @@ static JSValue js_enet_host_service(JSContext *ctx, JSValueConst this_val, int a
JS_FreeValue(ctx, event_obj);
}
JS_FreeValue(ctx, callback);
return JS_NULL;
}

View File

@@ -226,7 +226,10 @@ static int par_easycurl_to_memory(char const *url, par_byte **data, int *nbytes)
CFRelease(cfurlRef);
if (!request) return 0;
#pragma clang diagnostic push
#pragma clang diagnostic ignored "-Wdeprecated-declarations"
CFReadStreamRef stream = CFReadStreamCreateForHTTPRequest(NULL, request);
#pragma clang diagnostic pop
CFRelease(request);
if (!stream) return 0;

2
qop.c
View File

@@ -97,7 +97,7 @@ static int js_qop_ensure_index(JSContext *js, qop_desc *qop) {
JSC_CCALL(qop_open,
size_t len;
void *data = js_get_blob_data(js, &len, argv[0]);
if (data == -1)
if (data == (void *)-1)
ret = JS_EXCEPTION;
else if (!data)
ret = JS_RaiseDisrupt(js, "Empty blob");

View File

@@ -124,7 +124,7 @@ CJSON_PUBLIC(double) cJSON_GetNumberValue(const cJSON * const item)
CJSON_PUBLIC(const char*) cJSON_Version(void)
{
static char version[15];
sprintf(version, "%i.%i.%i", CJSON_VERSION_MAJOR, CJSON_VERSION_MINOR, CJSON_VERSION_PATCH);
snprintf(version, sizeof(version), "%i.%i.%i", CJSON_VERSION_MAJOR, CJSON_VERSION_MINOR, CJSON_VERSION_PATCH);
return version;
}
@@ -606,22 +606,22 @@ static cJSON_bool print_number(const cJSON * const item, printbuffer * const out
/* This checks for NaN and Infinity */
if (isnan(d) || isinf(d))
{
length = sprintf((char*)number_buffer, "null");
length = snprintf((char*)number_buffer, sizeof(number_buffer), "null");
}
else if(d == (double)item->valueint)
{
length = sprintf((char*)number_buffer, "%d", item->valueint);
length = snprintf((char*)number_buffer, sizeof(number_buffer), "%d", item->valueint);
}
else
{
/* Try 15 decimal places of precision to avoid nonsignificant nonzero digits */
length = sprintf((char*)number_buffer, "%1.15g", d);
length = snprintf((char*)number_buffer, sizeof(number_buffer), "%1.15g", d);
/* Check whether the original double can be recovered */
if ((sscanf((char*)number_buffer, "%lg", &test) != 1) || !compare_double((double)test, d))
{
/* If not, print with 17 decimal places of precision */
length = sprintf((char*)number_buffer, "%1.17g", d);
length = snprintf((char*)number_buffer, sizeof(number_buffer), "%1.17g", d);
}
}
@@ -1055,7 +1055,7 @@ static cJSON_bool print_string_ptr(const unsigned char * const input, printbuffe
break;
default:
/* escape and print as unicode codepoint */
sprintf((char*)output_pointer, "u%04x", *input_pointer);
snprintf((char*)output_pointer, 6, "u%04x", *input_pointer);
output_pointer += 4;
break;
}

View File

@@ -757,9 +757,9 @@ double cell_random() {
return (double)buf / 9007199254740992.0;
}
void cell_trace_sethook(cell_hook)
void cell_trace_sethook(cell_hook hook)
{
(void)hook;
}
int uncaught_exception(JSContext *js, JSValue v)

View File

@@ -947,6 +947,11 @@ vm_dispatch:
#ifdef __GNUC__
/* Computed goto dispatch — each opcode gets its own branch predictor entry */
/* Use a macro to generate consistent dispatch table entries and labels */
#pragma GCC diagnostic push
#pragma GCC diagnostic ignored "-Woverride-init"
#ifdef __clang__
#pragma clang diagnostic ignored "-Winitializer-overrides"
#endif
#define DT(x) [x] = &&op_##x
static const void *dispatch_table[256] = {
[0 ... 255] = &&op_DEFAULT,
@@ -1017,6 +1022,7 @@ vm_dispatch:
DT(MACH_IS_RECORD), DT(MACH_IS_STONE),
DT(MACH_LENGTH), DT(MACH_IS_PROXY),
};
#pragma GCC diagnostic pop
#undef DT
#define VM_DECODE() do { \
ctx->reg_current_frame = frame_ref.val; \

View File

@@ -126,8 +126,7 @@ JSC_CCALL(actor_removetimer,
cell_rt *actor = JS_GetContextOpaque(js);
uint32_t timer_id;
JS_ToUint32(js, &timer_id, argv[0]);
JSValue removed = actor_remove_timer(actor, timer_id);
JS_FreeValue(js, removed);
(void)actor_remove_timer(actor, timer_id);
)
/* Log callback bridge: called from JS_Log, calls ƿit log(channel, [msg, stack])

View File

@@ -671,7 +671,9 @@ const char *send_message(const char *id, void *msg)
void actor_turn(cell_rt *actor)
{
pthread_mutex_lock(actor->mutex);
#ifdef ACTOR_TRACE
int prev_state = actor->state;
#endif
actor->state = ACTOR_RUNNING;
#ifdef ACTOR_TRACE
fprintf(stderr, "[ACTOR_TRACE] %s: %d -> RUNNING\n",

View File

@@ -43,11 +43,11 @@ static uint gvntbln;
static Ins *
gvndup(Ins *i, int insert)
{
uint idx, n;
uint idx;
Ins *ii;
idx = ihash(i) % gvntbln;
for (n=1;; n++) {
for (;;) {
ii = gvntbl[idx];
if (!ii)
break;