Skip to content

Remove the ENABLED/DISABLED macros #4515

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

Merged
merged 1 commit into from
Feb 4, 2021

Conversation

rerobika
Copy link
Member

@rerobika rerobika commented Jan 20, 2021

The removal of these macros enabled cppcheck to reveal new errors.
These errors are also fixed by the patch.

JerryScript-DCO-1.0-Signed-off-by: Robert Fancsik [email protected]

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.

Looks good in general. But

  • There are some new cppcheck suppressions. Cannot these be removed/avoided?
  • Why is the new cppcheck-specific macro/guard necessary in the code? Especially in a public header! (jerryscript-compiler.h)
  • Rebase and resolve conflicts.
  • A humble suggestion to improve a bit on the commit message: "Remove the ENABLED/DISABLED macros // The removal of these macros enabled cppcheck to reveal new errors. These errors are also fixed/suppressed by the patch."

@@ -41,8 +41,10 @@ extern "C"
#define JERRY_ATTR_PURE __attribute__((pure))
#define JERRY_ATTR_WARN_UNUSED_RESULT __attribute__((warn_unused_result))

#ifndef _CPP_CHECK_
Copy link
Member

Choose a reason for hiding this comment

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

This is something new. At least to me. Why is this necessary?

Copy link
Member Author

Choose a reason for hiding this comment

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

This macro was used to prevent JERRY_LIKELY(x) to use __builtin_expect since it's only a GCC extension and cppcheck does not know how to interpret it correctly. Until this workaround there were false positive alarms for the following like of code parts:

any_kind *obj_p = do_somenthing();

if (JERRY_UNLIKELY (obj_p == NULL)) {
 return;
}

JERRY_ASSERT(obj_p);
obj_p->anything++; // warning(nullPointerRedundantCheck): Either the condition 'obj_p==NULL' is redundant or there is possible null pointer dereference: obj_p.

So now whenever the cppcheck is running the JERRY_{UN}LIKELY macros are forced to JERRY_{UN}LIKELY(x), without _CPP_CHECK_. See here.

Moreover, there are no new inline suppressions by the patch and the number of already existing ones have been reduced to 1. This can be resolved later, but I didn't find a good solution it for now.

@rerobika rerobika changed the title Remove the usage of ENABLED macro Remove the ENABLED/DISABLED macros Feb 4, 2021
@rerobika rerobika added the ecma core Related to core ECMA functionality label Feb 4, 2021
@rerobika rerobika force-pushed the drop_enabled branch 3 times, most recently from 4243a12 to 46041b7 Compare February 4, 2021 13:52
Copy link
Member

@dbatyai dbatyai 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
Copy link
Member

Please, rebase and resolve conflicts.

The removal of these macros enabled cppcheck to reveal new errors.
These errors are also fixed by the patch.

JerryScript-DCO-1.0-Signed-off-by: Robert Fancsik [email protected]
@rerobika
Copy link
Member Author

rerobika commented Feb 4, 2021

@akosthekiss The patch is rebased.

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 0628ae1 into jerryscript-project:master Feb 4, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
ecma core Related to core ECMA functionality
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants