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

Conversation

matetokodi
Copy link
Contributor

This patch depends on #5106
Once that is merged, this patch will be rebased on only include the cppcheck commit.

In this patch:

  • Re-enable cppcheck CI job
  • Update cppcheck suppression list:
    The new version of cppcheck raises warnings for many potential
    issues that are guarded against, so those warnings have been
    supressed.
  • Handle realloc failures:
    • jerry-ext/util/sources.c
    • jerry-port/common/jerry-port-io.c

if (tmp == NULL) {
return jerry_throw_sz(JERRY_ERROR_COMMON, "Out of memory.");
}
source_p = tmp;
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

is a new temporary needed? why not simply

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

?

{
jerry_port_fatal (JERRY_FATAL_OUT_OF_MEMORY);
}
line_p = tmp;
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

same here.

line_p = realloc (line_p, allocated);
if (line_p == NULL)
{
  jerry_port_fatal (JERRY_FATAL_OUT_OF_MEMORY);
}

?

jerry_value_t handler = jerry_object ();
jerry_value_t proxy = jerry_proxy (target, handler);
jerry_value_t handler_ = jerry_object ();
jerry_value_t proxy = jerry_proxy (target, handler_);
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

this isn't nice. what is the problem of cppcheck with handler?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The problem was that is shadowed the handler function defined at line 64.
I agree its not a good name, it was just a placeholder.

tests/unit-core/test-snapshot.c Show resolved Hide resolved
@matetokodi matetokodi force-pushed the update_cppcheck branch 2 times, most recently from 32c4f76 to f7182d7 Compare November 20, 2023 14:54
@matetokodi matetokodi marked this pull request as ready for review November 20, 2023 15:06
@matetokodi matetokodi force-pushed the update_cppcheck branch 3 times, most recently from df7afee to 901a7af Compare November 21, 2023 11:27
Re-enable cppcheck CI job

Update cppcheck suppression list:
    The new version of cppcheck raises warnings for many potential
    issues that are guarded against, so those warnings have been
    supressed.

Handle realloc failures:
    - jerry-ext/util/sources.c
    - jerry-port/common/jerry-port-io.c

Refactor test-snapshot: move each test to separate functions like some
others already were.

Rename `handler` variables inside `main` of `test-api.c` as they
shadowed the `handler` function in the same file.

JerryScript-DCO-1.0-Signed-off-by: Máté Tokodi [email protected]
Copy link
Member

@zherczeg zherczeg left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

Copy link
Member

@akosthekiss akosthekiss left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

lgtm

@akosthekiss akosthekiss merged commit ef4cb2b into jerryscript-project:master Nov 22, 2023
23 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants