Cleanup unused-variable warnings

This commit is contained in:
Andrew Johnson 2024-06-24 13:40:42 +03:00 committed by Saúl Ibarra Corretgé
parent 2ea0848616
commit 136f5a2c66
2 changed files with 9 additions and 24 deletions

View file

@ -35,7 +35,6 @@ xcheck_add_c_compiler_flag(-Wno-implicit-fallthrough)
xcheck_add_c_compiler_flag(-Wno-sign-compare) xcheck_add_c_compiler_flag(-Wno-sign-compare)
xcheck_add_c_compiler_flag(-Wno-missing-field-initializers) xcheck_add_c_compiler_flag(-Wno-missing-field-initializers)
xcheck_add_c_compiler_flag(-Wno-unused-parameter) xcheck_add_c_compiler_flag(-Wno-unused-parameter)
xcheck_add_c_compiler_flag(-Wno-unused-variable)
xcheck_add_c_compiler_flag(-Wno-unused-but-set-variable) xcheck_add_c_compiler_flag(-Wno-unused-but-set-variable)
xcheck_add_c_compiler_flag(-Wno-array-bounds) xcheck_add_c_compiler_flag(-Wno-array-bounds)
xcheck_add_c_compiler_flag(-Wno-format-truncation) xcheck_add_c_compiler_flag(-Wno-format-truncation)
@ -173,7 +172,7 @@ if(CMAKE_BUILD_TYPE MATCHES Debug OR DUMP_LEAKS)
) )
endif() endif()
target_include_directories(qjs PUBLIC target_include_directories(qjs PUBLIC
$<BUILD_INTERFACE:${CMAKE_CURRENT_SOURCE_DIR}> $<BUILD_INTERFACE:${CMAKE_CURRENT_SOURCE_DIR}>
$<INSTALL_INTERFACE:${CMAKE_INSTALL_INCLUDEDIR}> $<INSTALL_INTERFACE:${CMAKE_INSTALL_INCLUDEDIR}>
) )

View file

@ -2188,15 +2188,13 @@ static inline void set_value(JSContext *ctx, JSValue *pval, JSValue new_val)
void JS_SetClassProto(JSContext *ctx, JSClassID class_id, JSValue obj) void JS_SetClassProto(JSContext *ctx, JSClassID class_id, JSValue obj)
{ {
JSRuntime *rt = ctx->rt; assert(class_id < ctx->rt->class_count);
assert(class_id < rt->class_count);
set_value(ctx, &ctx->class_proto[class_id], obj); set_value(ctx, &ctx->class_proto[class_id], obj);
} }
JSValue JS_GetClassProto(JSContext *ctx, JSClassID class_id) JSValue JS_GetClassProto(JSContext *ctx, JSClassID class_id)
{ {
JSRuntime *rt = ctx->rt; assert(class_id < ctx->rt->class_count);
assert(class_id < rt->class_count);
return js_dup(ctx->class_proto[class_id]); return js_dup(ctx->class_proto[class_id]);
} }
@ -11083,8 +11081,6 @@ static int js_ecvt(double d, int n_digits,
char dest[minimum_length(JS_ECVT_BUF_SIZE)], char dest[minimum_length(JS_ECVT_BUF_SIZE)],
size_t size, int *decpt) size_t size, int *decpt)
{ {
int i;
if (n_digits == 0) { if (n_digits == 0) {
/* find the minimum number of digits (XXX: inefficient but simple) */ /* find the minimum number of digits (XXX: inefficient but simple) */
// TODO(chqrlie) use direct method from quickjs-printf // TODO(chqrlie) use direct method from quickjs-printf
@ -11134,7 +11130,7 @@ static int js_ecvt(double d, int n_digits,
return n_digits; /* truncate the 2 extra digits */ return n_digits; /* truncate the 2 extra digits */
} }
/* round up in the string */ /* round up in the string */
for(i = n_digits;; i--) { for(int i = n_digits;; i--) {
/* ignore the locale specific decimal point */ /* ignore the locale specific decimal point */
if (is_digit(dest[i])) { if (is_digit(dest[i])) {
if (dest[i]++ < '9') if (dest[i]++ < '9')
@ -11164,7 +11160,7 @@ static size_t js_fcvt(double d, int n_digits,
char dest[minimum_length(JS_FCVT_BUF_SIZE)], size_t size) char dest[minimum_length(JS_FCVT_BUF_SIZE)], size_t size)
{ {
#if defined(FE_DOWNWARD) && defined(FE_TONEAREST) #if defined(FE_DOWNWARD) && defined(FE_TONEAREST)
int i, n1, n2; int i, n1;
/* generate 2 extra digits: 99% chances to avoid 2 calls */ /* generate 2 extra digits: 99% chances to avoid 2 calls */
n1 = snprintf(dest, size, "%.*f", n_digits + 2, d) - 2; n1 = snprintf(dest, size, "%.*f", n_digits + 2, d) - 2;
if (dest[n1] >= '5') { if (dest[n1] >= '5') {
@ -11427,7 +11423,6 @@ done:
JSValue JS_ToStringInternal(JSContext *ctx, JSValue val, BOOL is_ToPropertyKey) JSValue JS_ToStringInternal(JSContext *ctx, JSValue val, BOOL is_ToPropertyKey)
{ {
uint32_t tag; uint32_t tag;
const char *str;
char buf[32]; char buf[32];
size_t len; size_t len;
@ -12061,8 +12056,7 @@ static JSValue JS_CompactBigInt1(JSContext *ctx, JSValue val)
return val; /* fail safe */ return val; /* fail safe */
bf_t *a = JS_GetBigInt(val); bf_t *a = JS_GetBigInt(val);
if (a->expn == BF_EXP_ZERO && a->sign) { if (a->expn == BF_EXP_ZERO && a->sign) {
JSBigInt *p = JS_VALUE_GET_PTR(val); assert(((JSBigInt*)JS_VALUE_GET_PTR(val))->header.ref_count == 1);
assert(p->header.ref_count == 1);
a->sign = 0; a->sign = 0;
} }
return val; return val;
@ -18830,7 +18824,6 @@ static __exception int js_parse_string(JSParseState *s, int sep,
break; break;
} }
if (c == '\\') { if (c == '\\') {
const uint8_t *p0 = p;
c = *p; c = *p;
switch(c) { switch(c) {
case '\0': case '\0':
@ -27030,7 +27023,6 @@ static JSValue js_dynamic_import_job(JSContext *ctx,
JSValue *resolving_funcs = argv; JSValue *resolving_funcs = argv;
JSValue basename_val = argv[2]; JSValue basename_val = argv[2];
JSValue specifier = argv[3]; JSValue specifier = argv[3];
JSModuleDef *m;
const char *basename = NULL, *filename; const char *basename = NULL, *filename;
JSValue ret, err; JSValue ret, err;
@ -27371,7 +27363,7 @@ static int js_inner_module_evaluation(JSContext *ctx, JSModuleDef *m,
JSReqModuleEntry *rme = &m->req_module_entries[i]; JSReqModuleEntry *rme = &m->req_module_entries[i];
m1 = rme->module; m1 = rme->module;
index = js_inner_module_evaluation(ctx, m1, index, pstack_top, pvalue); index = js_inner_module_evaluation(ctx, m1, index, pstack_top, pvalue);
if (index < 0) if (index < 0)
return -1; return -1;
assert(m1->status == JS_MODULE_STATUS_EVALUATING || assert(m1->status == JS_MODULE_STATUS_EVALUATING ||
m1->status == JS_MODULE_STATUS_EVALUATING_ASYNC || m1->status == JS_MODULE_STATUS_EVALUATING_ASYNC ||
@ -32962,11 +32954,10 @@ JSValue JS_EvalThis(JSContext *ctx, JSValue this_obj,
const char *input, size_t input_len, const char *input, size_t input_len,
const char *filename, int eval_flags) const char *filename, int eval_flags)
{ {
int eval_type = eval_flags & JS_EVAL_TYPE_MASK;
JSValue ret; JSValue ret;
assert(eval_type == JS_EVAL_TYPE_GLOBAL || assert((eval_flags & JS_EVAL_TYPE_MASK) == JS_EVAL_TYPE_GLOBAL ||
eval_type == JS_EVAL_TYPE_MODULE); (eval_flags & JS_EVAL_TYPE_MASK) == JS_EVAL_TYPE_MODULE);
ret = JS_EvalInternal(ctx, this_obj, input, input_len, filename, ret = JS_EvalInternal(ctx, this_obj, input, input_len, filename,
eval_flags, -1); eval_flags, -1);
return ret; return ret;
@ -34400,8 +34391,6 @@ static JSValue JS_ReadFunctionTag(BCReaderState *s)
int idx, i, local_count, has_debug_info; int idx, i, local_count, has_debug_info;
int function_size, cpool_offset, byte_code_offset; int function_size, cpool_offset, byte_code_offset;
int closure_var_offset, vardefs_offset; int closure_var_offset, vardefs_offset;
uint32_t ic_len;
JSAtom atom;
memset(&bc, 0, sizeof(bc)); memset(&bc, 0, sizeof(bc));
bc.header.ref_count = 1; bc.header.ref_count = 1;
@ -37659,8 +37648,6 @@ static JSValue js_array_at(JSContext *ctx, JSValue this_val,
{ {
JSValue obj, ret; JSValue obj, ret;
int64_t len, idx; int64_t len, idx;
JSValue *arrp;
uint32_t count;
ret = JS_EXCEPTION; ret = JS_EXCEPTION;
obj = JS_ToObject(ctx, this_val); obj = JS_ToObject(ctx, this_val);
@ -52250,7 +52237,6 @@ static JSValue js_atomics_wait(JSContext *ctx,
int32_t v32; int32_t v32;
void *ptr; void *ptr;
int64_t timeout; int64_t timeout;
struct timespec ts;
JSAtomicsWaiter waiter_s, *waiter; JSAtomicsWaiter waiter_s, *waiter;
int ret, size_log2, res; int ret, size_log2, res;
double d; double d;