Closed
Bug 1361548
Opened 7 years ago
Closed 7 years ago
Coverity CID 748633 Logically dead code In nsFrameSelection::DeleteFromDocument()
Categories
(Core :: DOM: Selection, enhancement)
Core
DOM: Selection
Tracking
()
RESOLVED
FIXED
mozilla57
Tracking | Status | |
---|---|---|
firefox57 | --- | fixed |
People
(Reporter: MatsPalmgren_bugz, Assigned: lorena9921)
References
(Blocks 1 open bug)
Details
(Keywords: coverity)
Attachments
(1 file)
Coverity CID 748633 Logically dead code The indicated dead code may have performed some action; that action will never occur. In nsFrameSelection::DeleteFromDocument(): Code can never be reached because of a logical contradiction 3411nsresult 3412nsFrameSelection::DeleteFromDocument() 3413{ 3414 nsresult res; 3415 3416 // If we're already collapsed, then we do nothing (bug 719503). 3417 bool isCollapsed; 3418 int8_t index = GetIndexFromSelectionType(SelectionType::eNormal); 3419 if (!mDomSelections[index]) 3420 return NS_ERROR_NULL_POINTER; 3421 3422 mDomSelections[index]->GetIsCollapsed( &isCollapsed); cond_const: Condition isCollapsed, taking false branch. Now the value of isCollapsed is equal to 0. 3423 if (isCollapsed) 3424 { 3425 return NS_OK; 3426 } 3427 3428 RefPtr<Selection> selection = mDomSelections[index]; 3429 for (uint32_t rangeIdx = 0; rangeIdx < selection->RangeCount(); ++rangeIdx) { 3430 RefPtr<nsRange> range = selection->GetRangeAt(rangeIdx); 3431 res = range->DeleteContents(); 3432 if (NS_FAILED(res)) 3433 return res; 3434 } 3435 3436 // Collapse to the new location. 3437 // If we deleted one character, then we move back one element. 3438 // FIXME We don't know how to do this past frame boundaries yet. const: At condition isCollapsed, the value of isCollapsed must be equal to 0. dead_error_condition: The condition isCollapsed cannot be true. 3439 if (isCollapsed) CID 748633 (#1 of 1): Logically dead code (DEADCODE)dead_error_line: Execution cannot reach this statement: this->mDomSelections[index].... 3440 mDomSelections[index]->Collapse(mDomSelections[index]->GetAnchorNode(), mDomSelections[index]->AnchorOffset()-1); 3441 else if (mDomSelections[index]->AnchorOffset() > 0) 3442 mDomSelections[index]->Collapse(mDomSelections[index]->GetAnchorNode(), mDomSelections[index]->AnchorOffset()); 3443#ifdef DEBUG 3444 else 3445 printf("Don't know how to set selection back past frame boundary\n"); 3446#endif 3447 3448 return NS_OK; 3449} 3450
Reporter | ||
Comment 1•7 years ago
|
||
When isCollapsed is true we would have already returned on line 3425: http://searchfox.org/mozilla-central/rev/abe68d5dad139e376d5521ca1d4b7892e1e7f1ba/layout/generic/nsSelection.cpp#3425,3439
Comment hidden (mozreview-request) |
Reporter | ||
Comment 4•7 years ago
|
||
mozreview-review |
Comment on attachment 8905217 [details] Bug 1361548 - Removed unreachable isCollapsed if condition. https://reviewboard.mozilla.org/r/177004/#review182468 Thanks! ::: commit-message-93dd2:1 (Diff revision 1) > +Bug 1361548 - Removed unreachable isCollapsed if condition Please add a period at the end of the sentence. Also, we usually add the r=<reviewer> at the end of the commit message, so it looks like this: Bug 1361548 - Removed unreachable isCollapsed if condition. r=mats
Attachment #8905217 -
Flags: review?(mats) → review+
Reporter | ||
Updated•7 years ago
|
Assignee: nobody → lorena9921
Flags: needinfo?(mats)
Comment hidden (mozreview-request) |
Reporter | ||
Updated•7 years ago
|
Keywords: checkin-needed
Pushed by ryanvm@gmail.com: https://hg.mozilla.org/integration/autoland/rev/0fd16b5ccce0 Removed unreachable isCollapsed if condition. r=mats
Keywords: checkin-needed
Comment 7•7 years ago
|
||
bugherder |
https://hg.mozilla.org/mozilla-central/rev/0fd16b5ccce0
Status: NEW → RESOLVED
Closed: 7 years ago
status-firefox57:
--- → fixed
Resolution: --- → FIXED
Target Milestone: --- → mozilla57
Updated•6 years ago
|
Blocks: coverity-analysis
You need to log in
before you can comment on or make changes to this bug.
Description
•