fix compiler warnings
This commit is contained in:
@@ -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;
|
||||
}
|
||||
|
||||
@@ -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)
|
||||
|
||||
@@ -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; \
|
||||
|
||||
@@ -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])
|
||||
|
||||
@@ -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",
|
||||
|
||||
Reference in New Issue
Block a user