From: Dmitry Volyntsev Date: Fri, 21 Jun 2024 00:26:14 +0000 (-0700) Subject: Fixed ‘length’ may be used uninitialized in Array.prototype.pop(). X-Git-Tag: 0.8.6~48 X-Git-Url: http://www.kaiwu.me/postgresql/commit/?a=commitdiff_plain;h=1c2c7af35e5efe9ec32975467dfff7e4cc014afd;p=njs.git Fixed ‘length’ may be used uninitialized in Array.prototype.pop(). When building by GCC with -O3 and -flto flags the following warning was reported: src/njs_array.c: In function ‘njs_array_prototype_pop’: src/njs_array.c:1009:8: error: ‘length’ may be used uninitialized in this function [-Werror=maybe-uninitialized] 1009 | if (length == 0) { | ^ Returning a specific code in njs_value_to_number() helps GCC to infer that there are only 2 return values are possible and both of them are handled. --- diff --git a/src/njs_value_conversion.h b/src/njs_value_conversion.h index f5a0e676..24483aa2 100644 --- a/src/njs_value_conversion.h +++ b/src/njs_value_conversion.h @@ -17,7 +17,7 @@ njs_value_to_number(njs_vm_t *vm, njs_value_t *value, double *dst) if (njs_slow_path(!njs_is_primitive(value))) { ret = njs_value_to_primitive(vm, &primitive, value, 0); if (njs_slow_path(ret != NJS_OK)) { - return ret; + return NJS_ERROR; } value = &primitive;