FazBrowse GitHub Viewer | Trending |
URL:
| Home
Tools: [Download Repo ZIP]   [Original HTTPS Page]

n-api: tighten null-checking and clean up last error by gabrielschulhof · Pull Request #12539 · nodejs/node · GitHub

/ node Public

n-api: tighten null-checking and clean up last error - #12539

Closed
gabrielschulhof wants to merge 1 commit into
nodejs:masterfrom
gabrielschulhof:227-add-null-checks
Closed

n-api: tighten null-checking and clean up last error#12539
gabrielschulhof wants to merge 1 commit into
nodejs:masterfrom
gabrielschulhof:227-add-null-checks

Conversation

Copy link
Copy Markdown
Contributor

We left out null-checks for many of the parameters passed to our APIs.
In particular, arguments of type napi_value were often accepted
without a null-check, even though they should never be null.

Additionally, many APIs simply returned napi_ok on success. This
leaves in place an error that may have occurred in a previous N-API
call. Others (those which perform NAPI_PREAMBLE(env) at the top)
OTOH explicitly clear the last error before proceeding. With this
modification all APIs explicitly clear the last error on success.

Fixes nodejs/abi-stable-node#227

Checklist
  • make -j4 test (UNIX), or vcbuild test (Windows) passes
  • commit message follows commit guidelines
Affected core subsystem(s)

n-api

nodejs-github-bot added c++ Issues and PRs that require attention from people who are familiar with C++. node-api Issues and PRs related to the Node-API. labels Apr 20, 2017
Comment thread src/node_api.cc Outdated

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Choose a reason Spam Abuse Off Topic Outdated Duplicate Resolved Low Quality

This change throws off the indentation of the following lines.

mhdawson left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Choose a reason Spam Abuse Off Topic Outdated Duplicate Resolved Low Quality

LGTM

Copy link
Copy Markdown
Member

This would need a rebase, and since #12366 most of the internals here are wrapped in an anonymous namespace so the statics here would be redundant

We left out null-checks for many of the parameters passed to our APIs.
In particular, arguments of type `napi_value` were often accepted
without a null-check, even though they should never be null.

Additionally, many APIs simply returned `napi_ok` on success. This
leaves in place an error that may have occurred in a previous N-API
call. Others (those which perform `NAPI_PREAMBLE(env)` at the top)
OTOH explicitly clear the last error before proceeding. With this
modification all APIs explicitly clear the last error on success.

Fixes nodejs/abi-stable-node#227

Copy link
Copy Markdown
Contributor Author

@addaleax rebased. I believe the static function touched in this PR are outside of a namespace, but you're right, there are now functions in src/node_api.cc which need no longer be static.

Copy link
Copy Markdown
Contributor Author

@cjihrig all good now?

Copy link
Copy Markdown
Contributor Author

@mhdawson @jasongin @addaleax thanks for taking a look!

Copy link
Copy Markdown
Member

Ran out of time today, will plan to land tomorrow (Tuesday)

mhdawson self-assigned this Apr 24, 2017

Copy link
Copy Markdown
Member

Copy link
Copy Markdown
Member

CI good landing.

Copy link
Copy Markdown
Member

@mhdawson Did you intend to merge this?
I'm just reminding you because I'm waiting on it for #12524

Copy link
Copy Markdown
Member

Landed in ba7bac5

addaleax closed this Apr 25, 2017
addaleax pushed a commit that referenced this pull request Apr 25, 2017
We left out null-checks for many of the parameters passed to our APIs.
In particular, arguments of type `napi_value` were often accepted
without a null-check, even though they should never be null.

Additionally, many APIs simply returned `napi_ok` on success. This
leaves in place an error that may have occurred in a previous N-API
call. Others (those which perform `NAPI_PREAMBLE(env)` at the top)
OTOH explicitly clear the last error before proceeding. With this
modification all APIs explicitly clear the last error on success.

Fixes: nodejs/abi-stable-node#227
PR-URL: #12539
Reviewed-By: Michael Dawson <michael_dawson@ca.ibm.com>
Reviewed-By: Anna Henningsen <anna@addaleax.net>
Reviewed-By: Colin Ihrig <cjihrig@gmail.com>

Copy link
Copy Markdown
Member

Just got back after lunch and tried to push seeing the CI green, but see @addaleax already has.

gabrielschulhof deleted the 227-add-null-checks branch April 26, 2017 19:24
jasnell mentioned this pull request May 11, 2017
gabrielschulhof pushed a commit to gabrielschulhof/node that referenced this pull request Apr 10, 2018
We left out null-checks for many of the parameters passed to our APIs.
In particular, arguments of type `napi_value` were often accepted
without a null-check, even though they should never be null.

Additionally, many APIs simply returned `napi_ok` on success. This
leaves in place an error that may have occurred in a previous N-API
call. Others (those which perform `NAPI_PREAMBLE(env)` at the top)
OTOH explicitly clear the last error before proceeding. With this
modification all APIs explicitly clear the last error on success.

Fixes: nodejs/abi-stable-node#227
PR-URL: nodejs#12539
Reviewed-By: Michael Dawson <michael_dawson@ca.ibm.com>
Reviewed-By: Anna Henningsen <anna@addaleax.net>
Reviewed-By: Colin Ihrig <cjihrig@gmail.com>
MylesBorins pushed a commit that referenced this pull request Apr 16, 2018
We left out null-checks for many of the parameters passed to our APIs.
In particular, arguments of type `napi_value` were often accepted
without a null-check, even though they should never be null.

Additionally, many APIs simply returned `napi_ok` on success. This
leaves in place an error that may have occurred in a previous N-API
call. Others (those which perform `NAPI_PREAMBLE(env)` at the top)
OTOH explicitly clear the last error before proceeding. With this
modification all APIs explicitly clear the last error on success.

Fixes: nodejs/abi-stable-node#227
Backport-PR-URL: #19447
PR-URL: #12539
Reviewed-By: Michael Dawson <michael_dawson@ca.ibm.com>
Reviewed-By: Anna Henningsen <anna@addaleax.net>
Reviewed-By: Colin Ihrig <cjihrig@gmail.com>
MylesBorins mentioned this pull request Apr 16, 2018
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode characters
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

c++ Issues and PRs that require attention from people who are familiar with C++. node-api Issues and PRs related to the Node-API.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

napi_call_function (and maybe others) - we assume napi_value passed in is not NULL

6 participants


Back | FazBrowse Home | New Git URL