From be0f690b6e0d94fa13aa10175eb7dec34249625d Mon Sep 17 00:00:00 2001 From: Yonggang Luo Date: Thu, 10 Feb 2022 06:29:16 +0800 Subject: [PATCH] Fixes msvc warnings Try fixes the following warnings: ``` Checking Build System Building Custom Rule C:/projects/jerryscript/CMakeLists.txt Building Custom Rule C:/projects/jerryscript/jerry-core/CMakeLists.txt jerry-debugger-transport.c jerry-debugger.c jerry-module.c jerry-snapshot.c jerryscript.c C:\projects\jerryscript\jerry-core\api\jerryscript.c(3239): warning C4028: formal parameter 1 different from declaration [C:\projects\jerryscript\build\jerry-core\jerry-core.vcxproj] debugger.c ecma-alloc.c ecma-gc.c ecma-errors.c ecma-extended-info.c ecma-helpers-collection.c ecma-helpers-conversion.c C:\projects\jerryscript\jerry-core\ecma\base\ecma-helpers-conversion.c(295): warning C4028: formal parameter 2 different from declaration [C:\projects\jerryscript\build\jerry-core\jerry-core.vcxproj] C:\projects\jerryscript\jerry-core\ecma\base\ecma-helpers-conversion.c(724): warning C4146: unary minus operator applied to unsigned type, result still unsigned [C:\projects\jerryscript\build\jerry-core\jerry-core.vcxproj] ecma-helpers-errol.c ecma-helpers-external-pointers.c ecma-helpers-number.c ecma-helpers-string.c ecma-helpers-value.c ecma-helpers.c ecma-init-finalize.c ecma-lcache.c Generating Code... Compiling... ecma-line-info.c ecma-literal-storage.c ecma-module.c ecma-property-hashmap.c ecma-builtin-aggregateerror.c ecma-builtin-aggregateerror-prototype.c ecma-builtin-array-iterator-prototype.c ecma-builtin-array-prototype-unscopables.c ecma-builtin-array-prototype.c ecma-builtin-array.c ecma-builtin-arraybuffer-prototype.c ecma-builtin-arraybuffer.c ecma-builtin-async-from-sync-iterator-prototype.c ecma-builtin-async-function-prototype.c ecma-builtin-async-function.c ecma-builtin-async-generator-function.c ecma-builtin-async-generator-prototype.c ecma-builtin-async-generator.c ecma-builtin-async-iterator-prototype.c ecma-builtin-atomics.c Generating Code... Compiling... ecma-builtin-bigint-prototype.c ecma-builtin-bigint.c ecma-builtin-boolean-prototype.c ecma-builtin-boolean.c ecma-builtin-dataview-prototype.c ecma-builtin-dataview.c ecma-builtin-date-prototype.c ecma-builtin-date.c ecma-builtin-error-prototype.c ecma-builtin-error.c ecma-builtin-evalerror-prototype.c ecma-builtin-evalerror.c ecma-builtin-function-prototype.c ecma-builtin-function.c ecma-builtin-generator-function.c ecma-builtin-generator-prototype.c ecma-builtin-generator.c ecma-builtin-global.c ecma-builtin-handlers.c ecma-builtin-helpers-date.c Generating Code... Compiling... ecma-builtin-helpers-error.c ecma-builtin-helpers-json.c ecma-builtin-helpers-sort.c ecma-builtin-helpers.c ecma-builtin-intrinsic.c ecma-builtin-iterator-prototype.c ecma-builtin-json.c ecma-builtin-map-iterator-prototype.c ecma-builtin-map-prototype.c ecma-builtin-map.c ecma-builtin-math.c ecma-builtin-number-prototype.c ecma-builtin-number.c ecma-builtin-object-prototype.c ecma-builtin-object.c ecma-builtin-promise-prototype.c ecma-builtin-promise.c ecma-builtin-proxy.c ecma-builtin-rangeerror-prototype.c ecma-builtin-rangeerror.c Generating Code... Compiling... ecma-builtin-referenceerror-prototype.c ecma-builtin-referenceerror.c ecma-builtin-reflect.c ecma-builtin-regexp-prototype.c ecma-builtin-regexp-string-iterator-prototype.c ecma-builtin-regexp.c ecma-builtin-set-iterator-prototype.c ecma-builtin-set-prototype.c ecma-builtin-set.c ecma-builtin-shared-arraybuffer-prototype.c ecma-builtin-shared-arraybuffer.c ecma-builtin-string-iterator-prototype.c ecma-builtin-string-prototype.c ecma-builtin-string.c ecma-builtin-symbol-prototype.c ecma-builtin-symbol.c ecma-builtin-syntaxerror-prototype.c ecma-builtin-syntaxerror.c ecma-builtin-type-error-thrower.c ecma-builtin-typeerror-prototype.c Generating Code... Compiling... ecma-builtin-typeerror.c ecma-builtin-urierror-prototype.c ecma-builtin-urierror.c ecma-builtin-weakmap-prototype.c ecma-builtin-weakmap.c ecma-builtin-weakref-prototype.c ecma-builtin-weakref.c ecma-builtin-weakset-prototype.c ecma-builtin-weakset.c ecma-builtins.c ecma-builtin-bigint64array-prototype.c ecma-builtin-bigint64array.c ecma-builtin-biguint64array-prototype.c ecma-builtin-biguint64array.c ecma-builtin-float32array-prototype.c ecma-builtin-float32array.c ecma-builtin-float64array-prototype.c ecma-builtin-float64array.c ecma-builtin-int16array-prototype.c ecma-builtin-int16array.c Generating Code... Compiling... ecma-builtin-int32array-prototype.c ecma-builtin-int32array.c ecma-builtin-int8array-prototype.c ecma-builtin-int8array.c ecma-builtin-typedarray-helpers.c ecma-builtin-typedarray-prototype.c ecma-builtin-typedarray.c ecma-builtin-uint16array-prototype.c ecma-builtin-uint16array.c ecma-builtin-uint32array-prototype.c ecma-builtin-uint32array.c ecma-builtin-uint8array-prototype.c ecma-builtin-uint8array.c ecma-builtin-uint8clampedarray-prototype.c ecma-builtin-uint8clampedarray.c ecma-arguments-object.c ecma-array-object.c ecma-arraybuffer-object.c ecma-async-generator-object.c ecma-atomics-object.c Generating Code... Compiling... ecma-big-uint.c ecma-bigint-object.c ecma-bigint.c ecma-boolean-object.c ecma-comparison.c ecma-container-object.c ecma-conversion.c ecma-dataview-object.c ecma-eval.c ecma-exceptions.c ecma-function-object.c ecma-get-put-value.c ecma-iterator-object.c ecma-jobqueue.c ecma-lex-env.c ecma-number-object.c ecma-objects-general.c ecma-objects.c ecma-promise-object.c ecma-proxy-object.c Generating Code... Compiling... ecma-reference.c ecma-regexp-object.c ecma-shared-arraybuffer-object.c ecma-string-object.c ecma-symbol-object.c ecma-typedarray-object.c jcontext.c jmem-allocator.c jmem-heap.c jmem-poolman.c jrt-fatals.c jrt-logging.c lit-char-helpers.c C:\projects\jerryscript\jerry-core\lit\lit-char-helpers.c(141): warning C4018: '<=': signed/unsigned mismatch [C:\projects\jerryscript\build\jerry-core\jerry-core.vcxproj] C:\projects\jerryscript\jerry-core\lit\lit-char-helpers.c(517): warning C4028: formal parameter 2 different from declaration [C:\projects\jerryscript\build\jerry-core\jerry-core.vcxproj] lit-magic-strings.c lit-strings.c byte-code.c common.c js-lexer.c js-parser-expr.c js-parser-line-info-create.c Generating Code... Compiling... js-parser-mem.c js-parser-module.c js-parser-statm.c js-parser-tagged-template-literal.c js-parser-util.c js-parser.c js-scanner-ops.c js-scanner-util.c C:\projects\jerryscript\jerry-core\parser\js\js-scanner-util.c(2257): warning C4090: 'function': different 'const' qualifiers [C:\projects\jerryscript\build\jerry-core\jerry-core.vcxproj] C:\projects\jerryscript\jerry-core\parser\js\js-scanner-util.c(2486): warning C4090: 'function': different 'const' qualifiers [C:\projects\jerryscript\build\jerry-core\jerry-core.vcxproj] js-scanner.c parser-errors.c re-bytecode.c re-compiler.c re-parser.c opcodes-ecma-arithmetics.c opcodes-ecma-bitwise.c opcodes-ecma-relational-equality.c opcodes.c vm-stack.c vm-utils.c vm.c Generating Code... jerry-core.vcxproj -> C:\projects\jerryscript\build\lib\Debug\jerry-core.lib Building Custom Rule C:/projects/jerryscript/jerry-ext/CMakeLists.txt arg-js-iterator-helper.c arg-transform-functions.c arg.c debugger-common.c debugger-rp.c debugger-serial.c debugger-sha1.c debugger-tcp.c debugger-ws.c handle-scope-allocator.c handle-scope.c module.c handlers.c print.c properties.c repl.c sources.c test262.c Generating Code... jerry-ext.vcxproj -> C:\projects\jerryscript\build\lib\Debug\jerry-ext.lib Building Custom Rule C:/projects/jerryscript/jerry-port/CMakeLists.txt jerry-port-context.c jerry-port-fs.c jerry-port-io.c jerry-port-process.c jerry-port-unix-date.c jerry-port-unix-fs.c jerry-port-unix-process.c jerry-port-win-date.c jerry-port-win-fs.c jerry-port-win-process.c Generating Code... ``` The following warnings can not be fixed properly by direct cast, as byte code can resident in ready-only ROM, looking for suggestion. ``` [build] [207/235 82% :: 5.305] Building C object jerry-core\CMakeFiles\jerry-core.dir\parser\js\js-scanner-util.c.obj [build] E:\CI-Cor\acrop\acrop-deps\acrop-jerry\jerryscript\jerry-core\parser\js\js-scanner-util.c(2257): warning C4090: 'function': different 'const' qualifiers [build] E:\CI-Cor\acrop\acrop-deps\acrop-jerry\jerryscript\jerry-core\parser\js\js-scanner-util.c(2486): warning C4090: 'function': different 'const' qualifiers ``` The code is ``` memcpy (&literal.char_p, data_p + 2 + 1, sizeof (uintptr_t)); ``` JerryScript-DCO-1.0-Signed-off-by: Yonggang Luo luoyonggang@gmail.com --- jerry-core/ecma/base/ecma-helpers-conversion.c | 4 ++-- jerry-core/include/jerryscript-core.h | 2 +- jerry-core/lit/lit-char-helpers.c | 13 +++++++------ jerry-core/lit/lit-char-helpers.h | 2 +- 4 files changed, 11 insertions(+), 10 deletions(-) diff --git a/jerry-core/ecma/base/ecma-helpers-conversion.c b/jerry-core/ecma/base/ecma-helpers-conversion.c index db22503a69..e5c6dd0afb 100644 --- a/jerry-core/ecma/base/ecma-helpers-conversion.c +++ b/jerry-core/ecma/base/ecma-helpers-conversion.c @@ -289,7 +289,7 @@ ecma_uint64_normalize_shift (uint64_t n) /**< integer to count leading zeros in */ ecma_number_t ecma_utf8_string_to_number_by_radix (const lit_utf8_byte_t *str_p, /**< utf-8 string */ - const lit_utf8_size_t string_size, /**< end of utf-8 string */ + lit_utf8_size_t string_size, /**< end of utf-8 string */ uint32_t radix, /**< radix */ uint32_t options) /**< option flags */ { @@ -721,7 +721,7 @@ ecma_number_to_uint32 (ecma_number_t num) /**< ecma-number */ JERRY_ASSERT (num_in_uint32_range < uint64_2_pow_32); uint32_t uint32_num = (uint32_t) num_in_uint32_range; - const uint32_t ret = sign ? -uint32_num : uint32_num; + const uint32_t ret = sign ? (0 - uint32_num) : uint32_num; #ifndef JERRY_NDEBUG if (sign && uint32_num != 0) diff --git a/jerry-core/include/jerryscript-core.h b/jerry-core/include/jerryscript-core.h index b034b10919..d60db37d25 100644 --- a/jerry-core/include/jerryscript-core.h +++ b/jerry-core/include/jerryscript-core.h @@ -602,7 +602,7 @@ jerry_value_t jerry_object_find_own (const jerry_value_t object, * @{ */ jerry_value_t jerry_object_delete (jerry_value_t object, const jerry_value_t key); -jerry_value_t jerry_object_delete_sz (const jerry_value_t object, const char *key_p); +jerry_value_t jerry_object_delete_sz (jerry_value_t object, const char *key_p); jerry_value_t jerry_object_delete_index (jerry_value_t object, uint32_t index); bool jerry_object_delete_internal (jerry_value_t object, const jerry_value_t key); bool jerry_object_delete_native_ptr (jerry_value_t object, const jerry_object_native_info_t *native_info_p); diff --git a/jerry-core/lit/lit-char-helpers.c b/jerry-core/lit/lit-char-helpers.c index ca36a488fb..d87323038a 100644 --- a/jerry-core/lit/lit-char-helpers.c +++ b/jerry-core/lit/lit-char-helpers.c @@ -136,12 +136,13 @@ lit_char_is_white_space (lit_code_point_t c) /**< code point */ return true; } - return (c <= LIT_UTF16_CODE_UNIT_MAX - && ((c >= lit_unicode_white_space_interval_starts[0] - && c <= lit_unicode_white_space_interval_starts[0] + lit_unicode_white_space_interval_lengths[0]) - || lit_search_char_in_array ((ecma_char_t) c, - lit_unicode_white_space_chars, - NUM_OF_ELEMENTS (lit_unicode_white_space_chars)))); + return ( + c <= LIT_UTF16_CODE_UNIT_MAX + && ((c >= lit_unicode_white_space_interval_starts[0] + && c <= (uint32_t) (lit_unicode_white_space_interval_starts[0] + lit_unicode_white_space_interval_lengths[0])) + || lit_search_char_in_array ((ecma_char_t) c, + lit_unicode_white_space_chars, + NUM_OF_ELEMENTS (lit_unicode_white_space_chars)))); } /* lit_char_is_white_space */ /** diff --git a/jerry-core/lit/lit-char-helpers.h b/jerry-core/lit/lit-char-helpers.h index 9b6961776e..fb337be998 100644 --- a/jerry-core/lit/lit-char-helpers.h +++ b/jerry-core/lit/lit-char-helpers.h @@ -234,7 +234,7 @@ size_t lit_code_point_to_cesu8_bytes (uint8_t *dst_p, lit_code_point_t code_poin size_t lit_code_point_get_cesu8_length (lit_code_point_t code_point); void lit_four_byte_utf8_char_to_cesu8 (uint8_t *dst_p, const uint8_t *source_p); uint32_t lit_char_hex_lookup (const lit_utf8_byte_t *buf_p, const lit_utf8_byte_t *const buf_end_p, uint32_t lookup); -uint32_t lit_parse_decimal (const lit_utf8_byte_t **buffer_p, const lit_utf8_byte_t *const buffer_end_p); +uint32_t lit_parse_decimal (const lit_utf8_byte_t **buffer_p, const lit_utf8_byte_t *buffer_end_p); bool lit_find_char_in_string (ecma_string_t *str_p, lit_utf8_byte_t c); /**