Closed
Bug 117418
Opened 23 years ago
Closed 23 years ago
nsWSRunObject.cpp:704: warning: `PRInt32 curStartOffset' might be used uninitialized in this function
Categories
(Core :: DOM: Editor, defect, P3)
Tracking
()
VERIFIED
FIXED
mozilla0.9.9
People
(Reporter: timeless, Assigned: mozeditor)
References
()
Details
Attachments
(2 files, 3 obsolete files)
13.48 KB,
patch
|
Brade
:
review+
kinmoz
:
superreview+
|
Details | Diff | Splinter Review |
3.10 KB,
patch
|
Brade
:
review+
kinmoz
:
superreview+
|
Details | Diff | Splinter Review |
/mnt/3/braddr/mozilla/Linux_2.4.17- rc1_Clobber/mozilla/editor/libeditor/html/nsWSRunObject.cpp: In function `static nsresult nsWSRunObject::PrepareToJoinBlocks(nsHTMLEditor *, nsIDOMNode *, nsIDOMNode *)': /mnt/3/braddr/mozilla/Linux_2.4.17- rc1_Clobber/mozilla/editor/libeditor/html/nsWSRunObject.cpp:158: warning: unused variable `nsresult res' /mnt/3/braddr/mozilla/Linux_2.4.17- rc1_Clobber/mozilla/editor/libeditor/html/nsWSRunObject.cpp: In function `static nsresult nsWSRunObject::PrepareToDeleteRange(nsHTMLEditor *, nsCOMPtr<nsIDOMNode> *, PRInt32 *, nsCOMPtr<nsIDOMNode> *, PRInt32 *)': /mnt/3/braddr/mozilla/Linux_2.4.17- rc1_Clobber/mozilla/editor/libeditor/html/nsWSRunObject.cpp:176: warning: unused variable `nsresult res' /mnt/3/braddr/mozilla/Linux_2.4.17- rc1_Clobber/mozilla/editor/libeditor/html/nsWSRunObject.cpp: In function `static nsresult nsWSRunObject::PrepareToSplitAcrossBlocks(nsHTMLEditor *, nsCOMPtr<nsIDOMNode> *, PRInt32 *)': /mnt/3/braddr/mozilla/Linux_2.4.17- rc1_Clobber/mozilla/editor/libeditor/html/nsWSRunObject.cpp:213: warning: unused variable `nsresult res' /mnt/3/braddr/mozilla/Linux_2.4.17- rc1_Clobber/mozilla/editor/libeditor/html/nsWSRunObject.cpp: In method `nsresult nsWSRunObject::InsertText(const nsAReadableString &, nsCOMPtr<nsIDOMNode> *, PRInt32 *, nsIDOMDocument *)': /mnt/3/braddr/mozilla/Linux_2.4.17- rc1_Clobber/mozilla/editor/libeditor/html/nsWSRunObject.cpp:447: warning: comparison between signed and unsigned /mnt/3/braddr/mozilla/Linux_2.4.17- rc1_Clobber/mozilla/editor/libeditor/html/nsWSRunObject.cpp: In method `nsresult nsWSRunObject::PriorVisibleNode(nsIDOMNode *, int, nsCOMPtr<nsIDOMNode> *, PRInt32 *, PRInt16 *)': /mnt/3/braddr/mozilla/Linux_2.4.17- rc1_Clobber/mozilla/editor/libeditor/html/nsWSRunObject.cpp:572: warning: unused variable `nsresult res' /mnt/3/braddr/mozilla/Linux_2.4.17- rc1_Clobber/mozilla/editor/libeditor/html/nsWSRunObject.cpp: In method `nsresult nsWSRunObject::NextVisibleNode(nsIDOMNode *, int, nsCOMPtr<nsIDOMNode> *, PRInt32 *, PRInt16 *)': /mnt/3/braddr/mozilla/Linux_2.4.17- rc1_Clobber/mozilla/editor/libeditor/html/nsWSRunObject.cpp:627: warning: unused variable `nsresult res' /mnt/3/braddr/mozilla/Linux_2.4.17- rc1_Clobber/mozilla/editor/libeditor/html/nsWSRunObject.cpp: In method `nsresult nsWSRunObject::GetWSNodes()': /mnt/3/braddr/mozilla/Linux_2.4.17- rc1_Clobber/mozilla/editor/libeditor/html/nsWSRunObject.cpp:704: warning: `PRInt32 curStartOffset' might be used uninitialized in this function /mnt/3/braddr/mozilla/Linux_2.4.17- rc1_Clobber/mozilla/editor/libeditor/html/nsWSRunObject.cpp:704: warning: `PRInt32 curEndOffset' might be used uninitialized in this function /mnt/3/braddr/mozilla/Linux_2.4.17- rc1_Clobber/mozilla/editor/libeditor/html/nsWSRunObject.cpp: In method `nsresult nsWSRunObject::DeleteChars(nsIDOMNode *, int, nsIDOMNode *, int)': /mnt/3/braddr/mozilla/Linux_2.4.17- rc1_Clobber/mozilla/editor/libeditor/html/nsWSRunObject.cpp:1604: warning: comparison between signed and unsigned /mnt/3/braddr/mozilla/Linux_2.4.17- rc1_Clobber/mozilla/editor/libeditor/html/nsWSRunObject.cpp:1615: warning: comparison between signed and unsigned /mnt/3/braddr/mozilla/Linux_2.4.17- rc1_Clobber/mozilla/editor/libeditor/html/nsWSRunObject.cpp: In method `nsresult nsWSRunObject::GetCharAfter(nsWSRunObject::WSPoint &, nsWSRunObject::WSPoint *)': /mnt/3/braddr/mozilla/Linux_2.4.17- rc1_Clobber/mozilla/editor/libeditor/html/nsWSRunObject.cpp:1730: warning: statement with no effect The highlighted portions are for the #704 build warnings. they're especially scary and strange. there are only two assignments: curStartOffset = 0; curEndOffset = len; otherwise both of them are undefined. please clean this code out, it's scary. as is the code could be rewritten with cur*Offset as #defines.
Assignee | ||
Comment 1•23 years ago
|
||
098
Severity: normal → major
Status: NEW → ASSIGNED
Target Milestone: --- → mozilla0.9.8
Hey Joe, this is pretty easy to fix, though, I wasn't sure if you were intentionally not checking for returned error values in some cases. Also, as timeless points out, it's a bit strange how curStartOffset is used in nsWSRunObject::GetWSNodes(), was there some code that used to exist in that method that modified curStartOffset? If not perhaps we should just remove it, and init curEndOffset to zero.
Assignee: kin → jfrancis
Status: ASSIGNED → NEW
Priority: -- → P3
Assignee | ||
Comment 3•23 years ago
|
||
I have begun auditing this code, which was written in a blur of caffeine. But I'm not done yet. As you describe, it looks halfway rewritten.
Status: NEW → ASSIGNED
Assignee | ||
Comment 4•23 years ago
|
||
pushing off 098 to 099
Target Milestone: mozilla0.9.8 → mozilla0.9.9
Assignee | ||
Comment 5•23 years ago
|
||
the swami says: things that will not land in 099!
Target Milestone: mozilla0.9.9 → mozilla1.0
Keywords: mozilla0.9.9
Target Milestone: mozilla1.0 → ---
Comment 7•23 years ago
|
||
Comment on attachment 66420 [details] [diff] [review] i prefer guru's Strangely, I'm not seeing these warnings, though I usually do see "might be used uninitialized" warnings. Anyway, the fix looks like a good idea, r=akkana
Attachment #66420 -
Flags: review+
Comment 8•23 years ago
|
||
Comment on attachment 66420 [details] [diff] [review] i prefer guru's sr=brendan@mozilla.org
Attachment #66420 -
Flags: superreview+
Comment 9•23 years ago
|
||
Another "uninitialized" warnings that are still there: editor/libeditor/html/nsWSRunObject.cpp:1804 `PRInt32 startOffset' might be used uninitialized in this function `PRInt32 endOffset' might be used uninitialized in this function
Blocks: 59652
Reporter | ||
Comment 10•23 years ago
|
||
fix checked in
Status: ASSIGNED → RESOLVED
Closed: 23 years ago
Resolution: --- → FIXED
Reporter | ||
Comment 11•23 years ago
|
||
hrm, yes i checked in *a* fix, but this bug isn't fixed. what in the world was i thinking?
Status: RESOLVED → REOPENED
Resolution: FIXED → ---
Assignee | ||
Comment 12•23 years ago
|
||
I have rewritten this routine.
Attachment #66420 -
Attachment is obsolete: true
Assignee | ||
Updated•23 years ago
|
Status: REOPENED → ASSIGNED
Whiteboard: fixinhand; need r=,sr=
Target Milestone: --- → mozilla0.9.9
Reporter | ||
Comment 13•23 years ago
|
||
more lines removed than added :-) nsCOMPtr<nsIDOMNode> priorNode; while (!mStartNode) { // we haven't found the start of ws yet. Keep looking + res = GetPreviousWSNode(curStartNode, blockParent, address_of(priorNode)); + NS_ENSURE_SUCCESS(res, res); 1230 nsresult 1231 nsWSRunObject::GetPreviousWSNode(nsIDOMNode *aStartNode, 1232 nsIDOMNode *aBlockParent, 1233 nsCOMPtr<nsIDOMNode> *aPriorNode) 1234 { 1235 // can't really recycle various getnext/prior routines because we have special needs 1236 // here. Need to step into inline containers but not block containers. 1237 if (!aStartNode || !aBlockParent || !aPriorNode) return NS_ERROR_NULL_POINTER; at first i thought i hade found a problem, and then i noticed the address_of. conclusion: this code is *scary*. As lxr qa, http://lxr.mozilla.org/seamonkey/ident?i=GetPreviousWSNode turned up two hits for the same function definition, i'll try to file a bug about it later.
Assignee | ||
Comment 14•23 years ago
|
||
fixing typo in prior diff
Attachment #67673 -
Attachment is obsolete: true
Assignee | ||
Comment 15•23 years ago
|
||
When it's this hard to get something right, it's a sign you have the wrong data structures for the job. I revamped some stuff to make this routine simpler.
Attachment #67675 -
Attachment is obsolete: true
Assignee | ||
Comment 16•23 years ago
|
||
header file changes
Assignee | ||
Comment 17•23 years ago
|
||
timeless, with latest patch yo uwill see 3 versions of GetPreviousWSNode(). However, this is not a bug, merely overloading. Nor is using pointers to comptrs a bug, though I admit it is pretty ugly here.
Reporter | ||
Comment 18•23 years ago
|
||
ok. it turns out my eyes deceived me. the problem was that i thought i saw two links to the same line, it turns out i transposed digits. If i had seen three, i probably wouldn't have worried (although it'd really help if i rewrote lxr to display the definitions).
Comment 19•23 years ago
|
||
Comment on attachment 67680 [details] [diff] [review] Differences of nsWSRunObject.cpp sr=kin@netscape.com with the changes we discussed.
Attachment #67680 -
Flags: superreview+
Comment 20•23 years ago
|
||
Comment on attachment 67681 [details] [diff] [review] Differences of nsWSRunObject.h sr=kin@netscape.com
Attachment #67681 -
Flags: superreview+
Comment 21•23 years ago
|
||
Comment on attachment 67681 [details] [diff] [review] Differences of nsWSRunObject.h r=brade
Attachment #67681 -
Flags: review+
Comment 22•23 years ago
|
||
Comment on attachment 67680 [details] [diff] [review] Differences of nsWSRunObject.cpp rs=brade
Attachment #67680 -
Flags: review+
Assignee | ||
Comment 23•23 years ago
|
||
fix landed on trunk
Status: ASSIGNED → RESOLVED
Closed: 23 years ago → 23 years ago
Resolution: --- → FIXED
Reporter | ||
Comment 24•23 years ago
|
||
Can you fix this too: 9-10. editor/libeditor/html/nsWSRunObject.cpp:1711 (See 1st of 2 warnings in build log) `PRInt32 startOffset' might be used uninitialized in this function `PRInt32 endOffset' might be used uninitialized in this function 1709 1710 nsCOMPtr<nsIDOMNode> startNode, endNode; 1711 PRInt32 startOffset, endOffset; 1712 1713 nsresult res = NS_OK; you might fix the following for bonus points: 8. editor/libeditor/html/nsWSRunObject.cpp:1614 (See build log excerpt) Statement with no effect 1612 { 1613 *outPoint = aPoint; 1614 outPoint->mOffset; 1615 outPoint->mChar = GetCharAt(aPoint.mTextNode, aPoint.mOffset); 1616 } 15. editor/libeditor/html/nsWSRunObject.cpp:71 (See build log excerpt) `PRBool IsInlineNode(nsIDOMNode *)' defined but not used 69 70 static PRBool IsInlineNode(nsIDOMNode* node) 71 { 72 return !IsBlockNode(node); 73 }
Comment 25•23 years ago
|
||
timeless can you verify this one? thanks.
Comment 26•23 years ago
|
||
I still see some "might be used uninitialized" warnings in nsWSRunObject.cpp editor/libeditor/html/nsWSRunObject.cpp:1711 `PRInt32 startOffset' might be used uninitialized in this function `PRInt32 endOffset' might be used uninitialized in this function
Comment 27•23 years ago
|
||
reopen to address uninitialized variables
Status: RESOLVED → REOPENED
Resolution: FIXED → ---
Whiteboard: fixinhand; need r=
Assignee | ||
Comment 28•23 years ago
|
||
might be, but theyt aren't. Compiler seems a bit picky here.
Status: REOPENED → RESOLVED
Closed: 23 years ago → 23 years ago
Resolution: --- → FIXED
Comment 29•23 years ago
|
||
If GetCharAfter/GetCharBefore fails or returns a point with a null mTextNode, startOffset and endOffset will be used (and returned in outStartOffset and outEndOffset!) uninitialized in nsWSRunObject::GetAsciiWSBounds
Status: RESOLVED → REOPENED
Resolution: FIXED → ---
Comment 30•23 years ago
|
||
Even aside from that: warnings make it more difficult for other developers, since they have to wade through old warnings to figure out whether they've introduced any new problems.
Comment 31•23 years ago
|
||
editor no longer has any "xxx might be used uninitialized" warnings. Thanks!
Status: REOPENED → RESOLVED
Closed: 23 years ago → 23 years ago
Resolution: --- → FIXED
You need to log in
before you can comment on or make changes to this bug.
Description
•