Closed
Bug 1231900
Opened 9 years ago
Closed 9 years ago
API Document for JS_snprintf() is non-consistent with the Implementation
Categories
(Core :: JavaScript Engine, defect)
Core
JavaScript Engine
Tracking
()
RESOLVED
FIXED
mozilla46
Tracking | Status | |
---|---|---|
firefox46 | --- | fixed |
People
(Reporter: wuwei, Assigned: wuwei)
References
Details
Attachments
(1 file, 1 obsolete file)
1.39 KB,
patch
|
jonco
:
review+
|
Details | Diff | Splinter Review |
Separated from bug 1231581.
According to bug 1231581 comment 2, the document for JS_snprintf() is non-consistent with the code.
Assignee | ||
Comment 1•9 years ago
|
||
PASSED tests and jit-test.
I also modified the return value to outlen when JS_snprintf thought the outlen was converted from negative int32_t. The behaviour is consistent with JS_vsnprintf now. However, I am not sure whether the modification violates anything we care, so please correct me if anything goes wrong.
Attachment #8697517 -
Flags: review?(jcoppeard)
Comment 2•9 years ago
|
||
Comment on attachment 8697517 [details] [diff] [review]
bug1231900.patch
Review of attachment 8697517 [details] [diff] [review]:
-----------------------------------------------------------------
Thanks for fixing this. Just a couple of comments...
::: js/src/jsprf.cpp
@@ +997,5 @@
> int rv;
>
> MOZ_ASSERT(int32_t(outlen) > 0);
> if (int32_t(outlen) <= 0)
> + return outlen;
Please remove the casting to int32_t here as well. I can't see anywhere that int32_t is used to hold the length so we don't need to check for overflow, so this is unnecessary and confusing. The if condition will can just be == since the type will be unsigned.
::: js/src/jsprf.h
@@ +31,5 @@
>
> /*
> ** sprintf into a fixed size buffer. Guarantees that a NUL is at the end
> ** of the buffer. Returns the length of the written output, NOT including
> +** the NUL, or the size of the buffer if an error occurs.
This is over specific. The important thing to say is that the function has succeeded only if the return value is less than the size of the buffer. The fact that we return the buffer length is an implementation detail.
Attachment #8697517 -
Flags: review?(jcoppeard)
Assignee | ||
Comment 3•9 years ago
|
||
ver2
removed the int32_t things.
Attachment #8697517 -
Attachment is obsolete: true
Attachment #8697557 -
Flags: review?(jcoppeard)
Comment 4•9 years ago
|
||
Comment on attachment 8697557 [details] [diff] [review]
v2
Review of attachment 8697557 [details] [diff] [review]:
-----------------------------------------------------------------
Great, thank you.
Attachment #8697557 -
Flags: review?(jcoppeard) → review+
Assignee | ||
Comment 5•9 years ago
|
||
(In reply to Jon Coppeard (:jonco) from comment #4)
> Comment on attachment 8697557 [details] [diff] [review]
> v2
>
> Review of attachment 8697557 [details] [diff] [review]:
> -----------------------------------------------------------------
>
> Great, thank you.
My pleasure! Thank you for your review :)
Keywords: checkin-needed
Keywords: checkin-needed
Comment 7•9 years ago
|
||
bugherder |
Status: NEW → RESOLVED
Closed: 9 years ago
status-firefox46:
--- → fixed
Resolution: --- → FIXED
Target Milestone: --- → mozilla46
You need to log in
before you can comment on or make changes to this bug.
Description
•