From a1566b06b7b53d14fa53c169b0989925c54fd69d Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Axel=20D=C3=B6rfler?= Date: Mon, 6 May 2013 21:45:00 +0200 Subject: [PATCH] bfs: removed kernel_cpp.h's new operator. * This fixes bug #9715 from the POV of BFS, ie. the new operator seems to call the constructor on a NULL object on failure. --- src/add-ons/kernel/file_systems/bfs/Inode.cpp | 14 +++++++------ .../kernel/file_systems/bfs/Journal.cpp | 4 ++-- src/add-ons/kernel/file_systems/bfs/Query.cpp | 20 +++++++++---------- .../file_systems/bfs/system_dependencies.h | 1 - 4 files changed, 20 insertions(+), 19 deletions(-) diff --git a/src/add-ons/kernel/file_systems/bfs/Inode.cpp b/src/add-ons/kernel/file_systems/bfs/Inode.cpp index c5e92c2949..d33970a614 100644 --- a/src/add-ons/kernel/file_systems/bfs/Inode.cpp +++ b/src/add-ons/kernel/file_systems/bfs/Inode.cpp @@ -1,5 +1,5 @@ /* - * Copyright 2001-2012, Axel Dörfler, axeld@pinc-software.de. + * Copyright 2001-2013, Axel Dörfler, axeld@pinc-software.de. * This file may be used under the terms of the MIT License. */ @@ -206,7 +206,8 @@ InodeAllocator::New(block_run* parentRun, mode_t mode, block_run& run, } run = fRun; - fInode = new Inode(volume, *fTransaction, volume->ToVnode(run), mode, run); + fInode = new(std::nothrow) Inode(volume, *fTransaction, + volume->ToVnode(run), mode, run); if (fInode == NULL) RETURN_ERROR(B_NO_MEMORY); @@ -235,7 +236,8 @@ InodeAllocator::CreateTree() if ((fInode->Mode() & S_INDEX_TYPES) == 0) fInode->Node().mode |= HOST_ENDIAN_TO_BFS_INT32(S_STR_INDEX); - BPlusTree* tree = fInode->fTree = new BPlusTree(*fTransaction, fInode); + BPlusTree* tree = fInode->fTree + = new(std::nothrow) BPlusTree(*fTransaction, fInode); if (tree == NULL || tree->InitCheck() < B_OK) return B_ERROR; @@ -347,7 +349,7 @@ Inode::Inode(Volume* volume, ino_t id) fOldLastModified = LastModified(); if (IsContainer()) - fTree = new BPlusTree(this); + fTree = new(std::nothrow) BPlusTree(this); if (NeedsFileCache()) { SetFileCache(file_cache_create(fVolume->ID(), ID(), Size())); SetMap(file_map_create(volume->ID(), ID(), Size())); @@ -2881,7 +2883,7 @@ AttributeIterator::GetNext(char* name, size_t* _length, uint32* _type, BPlusTree* tree = fAttributes->Tree(); if (tree == NULL - || (fIterator = new TreeIterator(tree)) == NULL) { + || (fIterator = new(std::nothrow) TreeIterator(tree)) == NULL) { FATAL(("could not get tree in AttributeIterator::GetNext(ino_t" " = %" B_PRIdINO ",name = \"%s\")\n", fInode->ID(), name)); return B_ENTRY_NOT_FOUND; @@ -2892,7 +2894,7 @@ AttributeIterator::GetNext(char* name, size_t* _length, uint32* _type, ino_t id; status_t status = fIterator->GetNextEntry(name, &length, B_FILE_NAME_LENGTH, &id); - if (status < B_OK) + if (status != B_OK) return status; Vnode vnode(volume, id); diff --git a/src/add-ons/kernel/file_systems/bfs/Journal.cpp b/src/add-ons/kernel/file_systems/bfs/Journal.cpp index fa62b52afe..bac5a4342a 100644 --- a/src/add-ons/kernel/file_systems/bfs/Journal.cpp +++ b/src/add-ons/kernel/file_systems/bfs/Journal.cpp @@ -1,5 +1,5 @@ /* - * Copyright 2001-2010, Axel Dörfler, axeld@pinc-software.de. + * Copyright 2001-2013, Axel Dörfler, axeld@pinc-software.de. * This file may be used under the terms of the MIT License. */ @@ -853,7 +853,7 @@ Journal::_WriteTransactionToLog() free(vecs); - LogEntry* logEntry = new LogEntry(this, fVolume->LogEnd(), + LogEntry* logEntry = new(std::nothrow) LogEntry(this, fVolume->LogEnd(), runArrays.LogEntryLength()); if (logEntry == NULL) { FATAL(("no memory to allocate log entries!")); diff --git a/src/add-ons/kernel/file_systems/bfs/Query.cpp b/src/add-ons/kernel/file_systems/bfs/Query.cpp index d6f213cd14..a5e593af34 100644 --- a/src/add-ons/kernel/file_systems/bfs/Query.cpp +++ b/src/add-ons/kernel/file_systems/bfs/Query.cpp @@ -1,5 +1,5 @@ /* - * Copyright 2001-2009, Axel Dörfler, axeld@pinc-software.de. + * Copyright 2001-2013, Axel Dörfler, axeld@pinc-software.de. * Copyright 2010, Clemens Zeidler * This file may be used under the terms of the MIT License. */ @@ -971,7 +971,7 @@ Equation::PrepareQuery(Volume* /*volume*/, Index& index, if (tree == NULL) return B_ERROR; - *iterator = new TreeIterator(tree); + *iterator = new(std::nothrow) TreeIterator(tree); if (*iterator == NULL) return B_NO_MEMORY; @@ -1249,11 +1249,11 @@ Term* Operator::Copy() const { if (fEquation != NULL) { - Equation* equation = new Equation(*fEquation); + Equation* equation = new(std::nothrow) Equation(*fEquation); if (equation == NULL) return NULL; - Term* term = new Term(equation); + Term* term = new(std::nothrow) Term(equation); if (term == NULL) delete equation; @@ -1270,7 +1270,7 @@ Operator::Copy() const return NULL; } - Term* term = new Term(left, fOp, right); + Term* term = new(std::nothrow) Term(left, fOp, right); if (term == NULL) { delete left; delete right; @@ -1393,7 +1393,7 @@ Expression::ParseEquation(char** expr) return term; } - Equation* equation = new Equation(expr); + Equation* equation = new(std::nothrow) Equation(expr); if (equation == NULL || equation->InitCheck() < B_OK) { delete equation; return NULL; @@ -1413,8 +1413,8 @@ Expression::ParseAnd(char** expr) Term* right = ParseAnd(expr); Term* newParent = NULL; - if (right == NULL - || (newParent = new Operator(left, OP_AND, right)) == NULL) { + if (right == NULL || (newParent = new(std::nothrow) Operator(left, + OP_AND, right)) == NULL) { delete left; delete right; @@ -1438,8 +1438,8 @@ Expression::ParseOr(char** expr) Term* right = ParseAnd(expr); Term* newParent = NULL; - if (right == NULL - || (newParent = new Operator(left, OP_OR, right)) == NULL) { + if (right == NULL || (newParent = new(std::nothrow) Operator(left, + OP_OR, right)) == NULL) { delete left; delete right; diff --git a/src/add-ons/kernel/file_systems/bfs/system_dependencies.h b/src/add-ons/kernel/file_systems/bfs/system_dependencies.h index 6e8989670a..aa0773d1aa 100644 --- a/src/add-ons/kernel/file_systems/bfs/system_dependencies.h +++ b/src/add-ons/kernel/file_systems/bfs/system_dependencies.h @@ -18,7 +18,6 @@ #include #include #include -#include #include #include