| FazBrowse GitHub Viewer | Trending | | Home |
| Tools: [Download Repo ZIP] [Original HTTPS Page] |
There was a problem hiding this comment.
I think Number.isFinite does both checks in one call
Sorry, something went wrong.
There was a problem hiding this comment.
@targos Ah, you are correct. I updated now. PTAL.
Sorry, something went wrong.
|
Out of curiousity, what was the motivation behind these changes? |
Sorry, something went wrong.
Sorry, something went wrong.
There was a problem hiding this comment.
Just seeing the error message. If you want to ensure it is an integer, you can drop Number.isFinite and use Number.isInteger instead
Sorry, something went wrong.
There was a problem hiding this comment.
@targos Man, that's wonderful. I didn't know about that function and that is exactly what we need here. Thanks :-) Updated the PR.
Sorry, something went wrong.
There was a problem hiding this comment.
Change in functionality. Here's an approximate test:
if (typeof path === 'number' && !Number.isInteger(path))
throw new TypeError('Not an integer');
Sorry, something went wrong.
There was a problem hiding this comment.
or are you just short-circuiting for the fast path?
Sorry, something went wrong.
There was a problem hiding this comment.
This is a legacy functionality it seems. If we pass an fd to truncate it internally delegates it to ftruncate. So we cannot throw error here. We are just checking if it is a positive integer and move on to the next check if is not.
Are you suggesting to not to call ftruncate at all?
Sorry, something went wrong.
There was a problem hiding this comment.
I just followed the logic paths for current and this patch, and there seemed to be a discrepancy.
Sorry, something went wrong.
There was a problem hiding this comment.
@trevnorris Agree, but wouldn't this check be better?
Sorry, something went wrong.
There was a problem hiding this comment.
My assumption was to land most these changes on a minor, then making any breaking changes, that push this to semver-major, to another PR. If you're cool with this staying on major then I'll have another look from that perspective.
Sorry, something went wrong.
There was a problem hiding this comment.
@trevnorris I am okay with this being in major :-) Let's get this done right. Please suggest improvements as well :-)
Sorry, something went wrong.
|
Bump! |
Sorry, something went wrong.
There was a problem hiding this comment.
Change this and the below line to:
CHECK(args[1]->IsNumber());
const int64_t = args[1]->IntegerValue();Reason for the CHECK() is because we're now making an assumption about the incoming value. Always want to catch that if incorrect, because at this point if the value is incorrect then we've screwed up.
Sorry, something went wrong.
There was a problem hiding this comment.
wait. nm. read this as the fd value, not the len value.
EDIT: meaning, no need for the CHECK(). can still collapse the other.
Sorry, something went wrong.
|
to recap
|
Sorry, something went wrong.
|
@targos Ah, I have this open for a loooong time. I'll get to it this week. Thanks for reminding :-) Last week @benjamingr also reminded me of this. |
Sorry, something went wrong.
|
@trevnorris Sorry for the delay in getting your review comments addressed. PTAL. |
Sorry, something went wrong.
|
Added semver-major tag based on the discussion thread. Feel free to change that if it turns out not to be major after all. |
Sorry, something went wrong.
There was a problem hiding this comment.
Change this to a TypeError. Also I'd replace "positive" with "unsigned".
Sorry, something went wrong.
There was a problem hiding this comment.
Done!
Sorry, something went wrong.
|
@trevnorris Changed positive to unsigned now. |
Sorry, something went wrong.
|
Thanks for the change, and test. LGTM. |
Sorry, something went wrong.
|
Rebased and improved the isFD function. CI Run: https://ci.nodejs.org/job/node-test-pull-request/3365/ |
Sorry, something went wrong.
This patch moves the basic validation of arguments to `truncate` family of functions to the JavaScript from the C++ layer.
|
Rebased, after landing #7168. CI Run: https://ci.nodejs.org/job/node-test-pull-request/3378/ |
Sorry, something went wrong.
This patch
1. moves the basic validation of arguments to `truncate` family
of functions to the JavaScript layer from the C++ layer.
2. makes sure that the File Descriptors are validated strictly.
PR-URL: #2498
Reviewed-By: Trevor Norris <trev.norris@gmail.com>
This reverts commit c86c1ee. original commit message: This patch 1. moves the basic validation of arguments to `truncate` family of functions to the JavaScript layer from the C++ layer. 2. makes sure that the File Descriptors are validated strictly. PR-URL: nodejs#2498 Reviewed-By: Trevor Norris <trev.norris@gmail.com>
This reverts commit c86c1ee. original commit message: This patch 1. moves the basic validation of arguments to `truncate` family of functions to the JavaScript layer from the C++ layer. 2. makes sure that the File Descriptors are validated strictly. PR-URL: nodejs#2498 Reviewed-By: Trevor Norris <trev.norris@gmail.com> PR-URL: nodejs#7950 Reviewed-By: Julien Gilli <jgilli@nodejs.org> Reviewed-By: Rod Vagg <rod@vagg.org> Reviewed-By: Minwoo Jung <jmwsoft@gmail.com> Reviewed-By: James M Snell <jasnell@gmail.com>
| Back | FazBrowse Home | New Git URL |
This patch moves the basic validation of arguments to truncate family
of functions to the JavaScript from the C++ layer.
cc @bnoordhuis
CI Run: https://jenkins-iojs.nodesource.com/job/node-test-pull-request/131/