Fix some defects identifies by Coverity Prevent. All are false

positives, but I've restructured the code to be more explicit.

Review URL: http://codereview.chromium.org/159192

git-svn-id: http://v8.googlecode.com/svn/branches/bleeding_edge@2521 ce2b1a6d-e550-0410-aec6-3dcde31c8c00
parent 1cbe7a24
...@@ -194,7 +194,10 @@ HashMap::Entry* HashMap::Probe(void* key, uint32_t hash) { ...@@ -194,7 +194,10 @@ HashMap::Entry* HashMap::Probe(void* key, uint32_t hash) {
void HashMap::Initialize(uint32_t capacity) { void HashMap::Initialize(uint32_t capacity) {
ASSERT(IsPowerOf2(capacity)); ASSERT(IsPowerOf2(capacity));
map_ = reinterpret_cast<Entry*>(allocator_->New(capacity * sizeof(Entry))); map_ = reinterpret_cast<Entry*>(allocator_->New(capacity * sizeof(Entry)));
if (map_ == NULL) V8::FatalProcessOutOfMemory("HashMap::Initialize"); if (map_ == NULL) {
V8::FatalProcessOutOfMemory("HashMap::Initialize");
return;
}
capacity_ = capacity; capacity_ = capacity;
Clear(); Clear();
} }
......
...@@ -3857,7 +3857,7 @@ Result CodeGenerator::LoadFromGlobalSlotCheckExtensions( ...@@ -3857,7 +3857,7 @@ Result CodeGenerator::LoadFromGlobalSlotCheckExtensions(
s = s->outer_scope(); s = s->outer_scope();
} }
if (s->is_eval_scope()) { if (s != NULL && s->is_eval_scope()) {
// Loop up the context chain. There is no frame effect so it is // Loop up the context chain. There is no frame effect so it is
// safe to use raw labels here. // safe to use raw labels here.
Label next, fast; Label next, fast;
...@@ -5388,12 +5388,6 @@ void CodeGenerator::VisitUnaryOperation(UnaryOperation* node) { ...@@ -5388,12 +5388,6 @@ void CodeGenerator::VisitUnaryOperation(UnaryOperation* node) {
} else { } else {
Load(node->expression()); Load(node->expression());
switch (op) { switch (op) {
case Token::NOT:
case Token::DELETE:
case Token::TYPEOF:
UNREACHABLE(); // handled above
break;
case Token::SUB: { case Token::SUB: {
bool overwrite = bool overwrite =
(node->AsBinaryOperation() != NULL && (node->AsBinaryOperation() != NULL &&
...@@ -5448,6 +5442,8 @@ void CodeGenerator::VisitUnaryOperation(UnaryOperation* node) { ...@@ -5448,6 +5442,8 @@ void CodeGenerator::VisitUnaryOperation(UnaryOperation* node) {
} }
default: default:
// NOT, DELETE, TYPEOF, and VOID are handled outside the
// switch.
UNREACHABLE(); UNREACHABLE();
} }
} }
......
...@@ -176,7 +176,10 @@ Address Zone::NewExpand(int size) { ...@@ -176,7 +176,10 @@ Address Zone::NewExpand(int size) {
new_size = Max(kSegmentOverhead + size, kMaximumSegmentSize); new_size = Max(kSegmentOverhead + size, kMaximumSegmentSize);
} }
Segment* segment = Segment::New(new_size); Segment* segment = Segment::New(new_size);
if (segment == NULL) V8::FatalProcessOutOfMemory("Zone"); if (segment == NULL) {
V8::FatalProcessOutOfMemory("Zone");
return NULL;
}
// Recompute 'top' and 'limit' based on the new segment. // Recompute 'top' and 'limit' based on the new segment.
Address result = RoundUp(segment->start(), kAlignment); Address result = RoundUp(segment->start(), kAlignment);
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment