Skip to content

Commit

Permalink
Fixes msvc warnings
Browse files Browse the repository at this point in the history
```
[build] [88/235  31% :: 2.167] Building C object jerry-core\CMakeFiles\jerry-core.dir\api\jerryscript.c.obj
[build] E:\CI-Cor\acrop\acrop-deps\acrop-jerry\jerryscript\jerry-core\api\jerryscript.c(3239): warning C4028: formal parameter 1 different from declaration
[build] [89/235  32% :: 2.171] Building C object jerry-core\CMakeFiles\jerry-core.dir\ecma\base\ecma-helpers-conversion.c.obj
[build] E:\CI-Cor\acrop\acrop-deps\acrop-jerry\jerryscript\jerry-core\ecma\base\ecma-helpers-conversion.c(295): warning C4028: formal parameter 2 different from declaration
[build] E:\CI-Cor\acrop\acrop-deps\acrop-jerry\jerryscript\jerry-core\ecma\base\ecma-helpers-conversion.c(724): warning C4146: unary minus operator applied to unsigned type, result still unsigned
[build] [187/235  74% :: 4.786] Building C object jerry-core\CMakeFiles\jerry-core.dir\lit\lit-char-helpers.c.obj
[build] E:\CI-Cor\acrop\acrop-deps\acrop-jerry\jerryscript\jerry-core\lit\lit-char-helpers.c(141): warning C4018: '<=': signed/unsigned mismatch
[build] E:\CI-Cor\acrop\acrop-deps\acrop-jerry\jerryscript\jerry-core\lit\lit-char-helpers.c(517): warning C4028: formal parameter 2 different from declaration
[build] [210/235  83% :: 5.284] 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 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 [email protected]
  • Loading branch information
lygstate committed Feb 9, 2022
1 parent d00f481 commit 7d21071
Show file tree
Hide file tree
Showing 4 changed files with 11 additions and 10 deletions.
2 changes: 1 addition & 1 deletion jerry-core/ecma/base/ecma-helpers-conversion.c
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down
2 changes: 1 addition & 1 deletion jerry-core/ecma/base/ecma-helpers.h
Original file line number Diff line number Diff line change
Expand Up @@ -505,7 +505,7 @@ bool ecma_delete_native_pointer_property (ecma_object_t *obj_p, const jerry_obje
/* ecma-helpers-conversion.c */
ecma_number_t ecma_utf8_string_to_number (const lit_utf8_byte_t *str_p, lit_utf8_size_t str_size, uint32_t option);
ecma_number_t ecma_utf8_string_to_number_by_radix (const lit_utf8_byte_t *str_p,
lit_utf8_size_t str_size,
const lit_utf8_size_t str_size,
uint32_t radix,
uint32_t option);
lit_utf8_size_t ecma_uint32_to_utf8_string (uint32_t value, lit_utf8_byte_t *out_buffer_p, lit_utf8_size_t buffer_size);
Expand Down
2 changes: 1 addition & 1 deletion jerry-core/include/jerryscript-core.h
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down
15 changes: 8 additions & 7 deletions jerry-core/lit/lit-char-helpers.c
Original file line number Diff line number Diff line change
Expand Up @@ -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 */

/**
Expand Down Expand Up @@ -513,7 +514,7 @@ lit_char_hex_lookup (const lit_utf8_byte_t *buf_p, /**< buffer */
*/
uint32_t
lit_parse_decimal (const lit_utf8_byte_t **buffer_p, /**< [in/out] character buffer */
const lit_utf8_byte_t *buffer_end_p) /**< buffer end */
const lit_utf8_byte_t *const buffer_end_p) /**< buffer end */
{
const lit_utf8_byte_t *current_p = *buffer_p;
JERRY_ASSERT (lit_char_is_decimal_digit (*current_p));
Expand Down

0 comments on commit 7d21071

Please sign in to comment.