Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Update cppcheck #5108

Merged
merged 1 commit into from
Nov 22, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 4 additions & 4 deletions .github/workflows/gh-actions.yml
Original file line number Diff line number Diff line change
Expand Up @@ -17,8 +17,8 @@ jobs:
python-version: '3.10'
- run: sudo apt update
# TODO: update checkers to current versions available in ubuntu 22.04
# - run: sudo apt install clang-format-10 cppcheck python-serial
- run: sudo apt install pylint doxygen
# - run: sudo apt install clang-format-10 python-serial
- run: sudo apt install pylint doxygen cppcheck
- run: $RUNNER --check-signed-off=gh-actions
if: ${{ always() }}
- run: $RUNNER --check-doxygen
Expand All @@ -31,8 +31,8 @@ jobs:
# if: ${{ always() }}
- run: $RUNNER --check-pylint
if: ${{ always() }}
# - run: $RUNNER --check-cppcheck
# if: ${{ always() }}
- run: $RUNNER --check-cppcheck
if: ${{ always() }}

Linux_x86-64_Build_Correctness_Debugger_Tests:
runs-on: ubuntu-latest
Expand Down
16 changes: 8 additions & 8 deletions jerry-core/ecma/base/ecma-helpers-errol.c
Original file line number Diff line number Diff line change
Expand Up @@ -143,24 +143,24 @@ ecma_errol0_dtoa (double val, /**< ecma number */
int32_t *exp_p) /**< [out] exponent */
{
double power_of_10 = 1.0;
int32_t exp = 1;
int32_t exponent = 1;

/* normalize the midpoint */
ecma_high_prec_t mid;

mid.value = val;
mid.offset = 0.0;

while (((mid.value > 10.0) || ((mid.value == 10.0) && (mid.offset >= 0.0))) && (exp < 308))
while (((mid.value > 10.0) || ((mid.value == 10.0) && (mid.offset >= 0.0))) && (exponent < 308))
{
exp++;
exponent++;
ecma_divide_high_prec_by_10 (&mid);
power_of_10 /= 10.0;
}

while (((mid.value < 1.0) || ((mid.value == 1.0) && (mid.offset < 0.0))) && (exp > -307))
while (((mid.value < 1.0) || ((mid.value == 1.0) && (mid.offset < 0.0))) && (exponent > -307))
{
exp--;
exponent--;
ecma_multiply_high_prec_by_10 (&mid);
power_of_10 *= 10.0;
}
Expand All @@ -185,14 +185,14 @@ ecma_errol0_dtoa (double val, /**< ecma number */

while (high_bound.value > 10.0 || (high_bound.value == 10.0 && (high_bound.offset >= 0.0)))
{
exp++;
exponent++;
ecma_divide_high_prec_by_10 (&high_bound);
ecma_divide_high_prec_by_10 (&low_bound);
}

while (high_bound.value < 1.0 || (high_bound.value == 1.0 && (high_bound.offset < 0.0)))
{
exp--;
exponent--;
ecma_multiply_high_prec_by_10 (&high_bound);
ecma_multiply_high_prec_by_10 (&low_bound);
}
Expand Down Expand Up @@ -234,7 +234,7 @@ ecma_errol0_dtoa (double val, /**< ecma number */
double mdig = (high_bound.value + low_bound.value) / 2.0 + 0.5;
*dst_p++ = (lit_utf8_byte_t) ('0' + (uint8_t) mdig);

*exp_p = exp;
*exp_p = exponent;

return (lit_utf8_size_t) (dst_p - buffer_p);
} /* ecma_errol0_dtoa */
Expand Down
3 changes: 0 additions & 3 deletions jerry-ext/handle-scope/handle-scope.c
Original file line number Diff line number Diff line change
Expand Up @@ -254,10 +254,7 @@ jerryx_escape_handle_internal (jerryx_escapable_handle_scope scope,
* Escape handle to parent scope
*/
*result = jerryx_handle_scope_add_handle_to (found_handle, parent);
}

if (should_promote)
{
scope->escaped = true;
}
return jerryx_handle_scope_ok;
Expand Down
4 changes: 4 additions & 0 deletions jerry-ext/util/sources.c
Original file line number Diff line number Diff line change
Expand Up @@ -146,6 +146,10 @@ jerryx_source_exec_stdin (void)

jerry_size_t new_size = source_size + line_size;
source_p = realloc (source_p, new_size);
if (source_p == NULL)
{
return jerry_throw_sz (JERRY_ERROR_COMMON, "Out of memory.");
}

memcpy (source_p + source_size, line_p, line_size);
jerry_port_line_free (line_p);
Expand Down
4 changes: 4 additions & 0 deletions jerry-port/common/jerry-port-io.c
Original file line number Diff line number Diff line change
Expand Up @@ -71,6 +71,10 @@ jerry_port_line_read (jerry_size_t *out_size_p)
{
allocated += 64;
line_p = realloc (line_p, allocated);
if (line_p == NULL)
{
jerry_port_fatal (JERRY_FATAL_OUT_OF_MEMORY);
}

while (bytes < allocated - 1)
{
Expand Down
12 changes: 6 additions & 6 deletions tests/unit-core/test-api.c
Original file line number Diff line number Diff line change
Expand Up @@ -709,12 +709,12 @@ main (void)
if (jerry_feature_enabled (JERRY_FEATURE_PROXY))
{
jerry_value_t target = jerry_object ();
jerry_value_t handler = jerry_object ();
jerry_value_t proxy = jerry_proxy (target, handler);
jerry_value_t proxy_handler = jerry_object ();
jerry_value_t proxy = jerry_proxy (target, proxy_handler);
jerry_value_t obj_proto = jerry_eval ((jerry_char_t *) "Object.prototype", 16, JERRY_PARSE_NO_OPTS);

jerry_value_free (target);
jerry_value_free (handler);
jerry_value_free (proxy_handler);
proto_val = jerry_object_proto (proxy);
TEST_ASSERT (!jerry_value_is_exception (proto_val));
TEST_ASSERT (proto_val == obj_proto);
Expand Down Expand Up @@ -745,8 +745,8 @@ main (void)
if (jerry_feature_enabled (JERRY_FEATURE_PROXY))
{
jerry_value_t target = jerry_object ();
jerry_value_t handler = jerry_object ();
jerry_value_t proxy = jerry_proxy (target, handler);
jerry_value_t proxy_handler = jerry_object ();
jerry_value_t proxy = jerry_proxy (target, proxy_handler);
new_proto = jerry_eval ((jerry_char_t *) "Function.prototype", 18, JERRY_PARSE_NO_OPTS);

res = jerry_object_set_proto (proxy, new_proto);
Expand All @@ -755,7 +755,7 @@ main (void)
TEST_ASSERT (target_proto == new_proto);

jerry_value_free (target);
jerry_value_free (handler);
jerry_value_free (proxy_handler);
jerry_value_free (proxy);
jerry_value_free (new_proto);
jerry_value_free (target_proto);
Expand Down
Loading
Loading