diff --git a/archive/miniz.c b/archive/miniz.c index effd6209..65657c55 100644 --- a/archive/miniz.c +++ b/archive/miniz.c @@ -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; } diff --git a/crypto.c b/crypto.c index f10f7afc..184db195 100644 --- a/crypto.c +++ b/crypto.c @@ -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; } diff --git a/internal/fd.c b/internal/fd.c index f35a5feb..657a80ae 100644 --- a/internal/fd.c +++ b/internal/fd.c @@ -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); } diff --git a/meson.build b/meson.build index 28ea6cc9..369a008a 100644 --- a/meson.build +++ b/meson.build @@ -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, diff --git a/net/enet.c b/net/enet.c index b1eb7b22..e2654ea6 100644 --- a/net/enet.c +++ b/net/enet.c @@ -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; } diff --git a/net/http.c b/net/http.c index dc57603e..674ab227 100644 --- a/net/http.c +++ b/net/http.c @@ -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; diff --git a/qop.c b/qop.c index 9d443f8a..222509ff 100644 --- a/qop.c +++ b/qop.c @@ -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"); diff --git a/source/cJSON.c b/source/cJSON.c index 6e4fb0dd..635d9004 100644 --- a/source/cJSON.c +++ b/source/cJSON.c @@ -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; } diff --git a/source/cell.c b/source/cell.c index 0bb7d4c2..dd4573b6 100644 --- a/source/cell.c +++ b/source/cell.c @@ -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) diff --git a/source/mach.c b/source/mach.c index 4d01669b..21797be2 100644 --- a/source/mach.c +++ b/source/mach.c @@ -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; \ diff --git a/source/qjs_actor.c b/source/qjs_actor.c index 2f40e554..c0f11afe 100644 --- a/source/qjs_actor.c +++ b/source/qjs_actor.c @@ -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]) diff --git a/source/scheduler.c b/source/scheduler.c index acb4273b..c9c08a1f 100644 --- a/source/scheduler.c +++ b/source/scheduler.c @@ -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", diff --git a/src/qbe/gvn.c b/src/qbe/gvn.c index 92ee5eb9..24171502 100644 --- a/src/qbe/gvn.c +++ b/src/qbe/gvn.c @@ -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;