added missing nothrow parameter

git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@18868 a95241bf-73f2-0310-859d-f6bbb57e9c96
This commit is contained in:
Marcus Overhagen 2006-09-16 23:25:56 +00:00
parent 0ff6a5fd11
commit 82029bdae8
19 changed files with 66 additions and 59 deletions

View File

@ -57,7 +57,7 @@ Directory::Open(void **_cookie, int mode)
{
_inherited::Open(_cookie, mode);
HashIterator *iterator = new HashIterator(fVolume.Device(), fNode);
HashIterator *iterator = new(nothrow) HashIterator(fVolume.Device(), fNode);
if (iterator == NULL)
return B_NO_MEMORY;
@ -102,9 +102,9 @@ Directory::Lookup(const char *name, bool traverseLinks)
if (node->GetName(fileName, sizeof(fileName)) == B_OK
&& !strcmp(name, fileName)) {
if (node->IsFile())
return new File(fVolume, block);
return new(nothrow) File(fVolume, block);
if (node->IsDirectory())
return new Directory(fVolume, block);
return new(nothrow) Directory(fVolume, block);
return NULL;
}

View File

@ -185,7 +185,7 @@ File::InitCheck()
status_t
File::Open(void **_cookie, int mode)
{
Stream *stream = new Stream(fVolume.Device(), fNode);
Stream *stream = new(nothrow) Stream(fVolume.Device(), fNode);
if (stream == NULL)
return B_NO_MEMORY;

View File

@ -75,7 +75,7 @@ Volume::Volume(boot::Partition *partition)
buffer = newBuffer;
fRootNode.SetTo(buffer, blockSize);
fRoot = new Directory(*this, fRootNode);
fRoot = new(nothrow) Directory(*this, fRootNode);
// fRoot will free the buffer for us upon destruction
}
@ -103,7 +103,7 @@ Volume::InitCheck()
static status_t
amiga_ffs_get_file_system(boot::Partition *partition, ::Directory **_root)
{
Volume *volume = new Volume(partition);
Volume *volume = new(nothrow) Volume(partition);
if (volume == NULL)
return B_NO_MEMORY;

View File

@ -63,7 +63,7 @@ Directory::Open(void **_cookie, int mode)
{
_inherited::Open(_cookie, mode);
*_cookie = (void *)new TreeIterator(&fTree);
*_cookie = (void *)new(nothrow) TreeIterator(&fTree);
if (*_cookie == NULL)
return B_NO_MEMORY;

View File

@ -403,12 +403,12 @@ Stream::NodeFactory(Volume &volume, off_t id)
return NULL;
if (stream.IsContainer())
return new Directory(stream);
return new(nothrow) Directory(stream);
if (stream.IsSymlink())
return new Link(stream);
return new(nothrow) Link(stream);
return new File(stream);
return new(nothrow) File(stream);
}

View File

@ -55,7 +55,7 @@ Volume::Volume(boot::Partition *partition)
TRACE(("bfs: we do have a valid super block (name = %s)!\n", fSuperBlock.name));
fRootNode = new BFS::Directory(*this, Root());
fRootNode = new(nothrow) BFS::Directory(*this, Root());
if (fRootNode == NULL)
return;
@ -135,7 +135,7 @@ Volume::ToBlockRun(off_t block) const
static status_t
bfs_get_file_system(boot::Partition *partition, ::Directory **_root)
{
Volume *volume = new Volume(partition);
Volume *volume = new(nothrow) Volume(partition);
if (volume == NULL)
return B_NO_MEMORY;

View File

@ -38,7 +38,7 @@ HFSPlus::get_root_block(int fDevice, char *buffer, int32 blockSize, off_t partit
static status_t
hfs_plus_get_file_system(boot::Partition *partition, ::Directory **_root)
{
/* Volume *volume = new Volume(partition);
/* Volume *volume = new(nothrow) Volume(partition);
if (volume == NULL)
return B_NO_MEMORY;

View File

@ -296,7 +296,7 @@ TarFS::Directory::Open(void **_cookie, int mode)
{
_inherited::Open(_cookie, mode);
EntryIterator *iterator = new EntryIterator(fEntries.GetIterator());
EntryIterator *iterator = new(nothrow) EntryIterator(fEntries.GetIterator());
if (iterator == NULL)
return B_NO_MEMORY;
@ -414,7 +414,7 @@ TarFS::Directory::AddDirectory(char *dirName, TarFS::Directory **_dir)
return B_ERROR;
} else {
// doesn't exist yet -- create it
dir = new TarFS::Directory(dirName);
dir = new(nothrow) TarFS::Directory(dirName);
if (!dir)
return B_NO_MEMORY;
@ -456,7 +456,7 @@ TarFS::Directory::AddFile(tar_header *header)
}
// create the file
TarFS::File *file = new TarFS::File(header, leaf);
TarFS::File *file = new(nothrow) TarFS::File(header, leaf);
if (!file)
return B_NO_MEMORY;
@ -654,7 +654,7 @@ TarFS::Volume::Init(boot::Partition *partition)
static status_t
tarfs_get_file_system(boot::Partition *partition, ::Directory **_root)
{
TarFS::Volume *volume = new TarFS::Volume;
TarFS::Volume *volume = new(nothrow) TarFS::Volume;
if (volume == NULL)
return B_NO_MEMORY;

View File

@ -288,7 +288,7 @@ Menu::AddItem(MenuItem *item)
status_t
Menu::AddSeparatorItem()
{
MenuItem *item = new MenuItem();
MenuItem *item = new(nothrow) MenuItem();
if (item == NULL)
return B_NO_MEMORY;
@ -368,7 +368,7 @@ user_menu_boot_volume(Menu *menu, MenuItem *item)
static Menu *
add_boot_volume_menu(Directory *bootVolume)
{
Menu *menu = new Menu(CHOICE_MENU, "Select Boot Volume");
Menu *menu = new(nothrow) Menu(CHOICE_MENU, "Select Boot Volume");
MenuItem *item;
void *cookie;
int32 count = 0;
@ -382,7 +382,7 @@ add_boot_volume_menu(Directory *bootVolume)
char name[B_FILE_NAME_LENGTH];
if (volume->GetName(name, sizeof(name)) == B_OK) {
menu->AddItem(item = new MenuItem(name));
menu->AddItem(item = new(nothrow) MenuItem(name));
item->SetTarget(user_menu_boot_volume);
item->SetData(volume);
@ -399,20 +399,20 @@ add_boot_volume_menu(Directory *bootVolume)
if (count == 0) {
// no boot volume found yet
menu->AddItem(item = new MenuItem("<No boot volume found>"));
menu->AddItem(item = new(nothrow) MenuItem("<No boot volume found>"));
item->SetType(MENU_ITEM_NO_CHOICE);
item->SetEnabled(false);
}
menu->AddSeparatorItem();
menu->AddItem(item = new MenuItem("Rescan volumes"));
menu->AddItem(item = new(nothrow) MenuItem("Rescan volumes"));
item->SetHelpText("Please insert a Haiku CD-ROM or attach a USB disk - depending on your system, you can then boot from them.");
item->SetType(MENU_ITEM_NO_CHOICE);
if (count == 0)
item->Select(true);
menu->AddItem(item = new MenuItem("Return to main menu"));
menu->AddItem(item = new(nothrow) MenuItem("Return to main menu"));
item->SetType(MENU_ITEM_NO_CHOICE);
if (gKernelArgs.boot_disk.booted_from_image)
@ -425,33 +425,33 @@ add_boot_volume_menu(Directory *bootVolume)
static Menu *
add_safe_mode_menu()
{
Menu *safeMenu = new Menu(SAFE_MODE_MENU, "Safe Mode Options");
Menu *safeMenu = new(nothrow) Menu(SAFE_MODE_MENU, "Safe Mode Options");
MenuItem *item;
safeMenu->AddItem(item = new MenuItem("Safe mode"));
safeMenu->AddItem(item = new(nothrow) MenuItem("Safe mode"));
item->SetData(B_SAFEMODE_SAFE_MODE);
item->SetType(MENU_ITEM_MARKABLE);
item->SetHelpText("Puts the system into safe mode. This can be enabled independently "
"from the other options.");
safeMenu->AddItem(item = new MenuItem("Disable user add-ons"));
safeMenu->AddItem(item = new(nothrow) MenuItem("Disable user add-ons"));
item->SetData(B_SAFEMODE_DISABLE_USER_ADD_ONS);
item->SetType(MENU_ITEM_MARKABLE);
item->SetHelpText("Prevent all user installed add-ons to be loaded. Only the add-ons "
"in the system directory will be used.");
safeMenu->AddItem(item = new MenuItem("Disable IDE DMA"));
safeMenu->AddItem(item = new(nothrow) MenuItem("Disable IDE DMA"));
item->SetData(B_SAFEMODE_DISABLE_IDE_DMA);
item->SetType(MENU_ITEM_MARKABLE);
platform_add_menus(safeMenu);
safeMenu->AddItem(item = new MenuItem("Enable on screen debug output"));
safeMenu->AddItem(item = new(nothrow) MenuItem("Enable on screen debug output"));
item->SetData("debug_screen");
item->SetType(MENU_ITEM_MARKABLE);
safeMenu->AddSeparatorItem();
safeMenu->AddItem(item = new MenuItem("Return to main menu"));
safeMenu->AddItem(item = new(nothrow) MenuItem("Return to main menu"));
return safeMenu;
}
@ -491,26 +491,26 @@ user_menu_reboot(Menu *menu, MenuItem *item)
status_t
user_menu(Directory **_bootVolume)
{
Menu *menu = new Menu(MAIN_MENU);
Menu *menu = new(nothrow) Menu(MAIN_MENU);
Menu *safeModeMenu;
MenuItem *item;
// Add boot volume
menu->AddItem(item = new MenuItem("Select boot volume", add_boot_volume_menu(*_bootVolume)));
menu->AddItem(item = new(nothrow) MenuItem("Select boot volume", add_boot_volume_menu(*_bootVolume)));
// Add safe mode
menu->AddItem(item = new MenuItem("Select safe mode options", safeModeMenu = add_safe_mode_menu()));
menu->AddItem(item = new(nothrow) MenuItem("Select safe mode options", safeModeMenu = add_safe_mode_menu()));
// Add platform dependent menus
platform_add_menus(menu);
menu->AddSeparatorItem();
if (*_bootVolume == NULL) {
menu->AddItem(item = new MenuItem("Reboot"));
menu->AddItem(item = new(nothrow) MenuItem("Reboot"));
item->SetTarget(user_menu_reboot);
}
menu->AddItem(item = new MenuItem("Continue booting"));
menu->AddItem(item = new(nothrow) MenuItem("Continue booting"));
if (*_bootVolume == NULL) {
item->SetEnabled(false);
menu->ItemAt(0)->Select(true);

View File

@ -287,7 +287,7 @@ Descriptor::Release()
status_t
vfs_init(stage2_args *args)
{
gRoot = new RootFileSystem();
gRoot = new(nothrow) RootFileSystem();
if (gRoot == NULL)
return B_NO_MEMORY;
@ -543,7 +543,7 @@ open_node(Node *node, int mode)
TRACE(("could open node at %p\n", node));
Descriptor *descriptor = new Descriptor(node, cookie);
Descriptor *descriptor = new(nothrow) Descriptor(node, cookie);
if (descriptor == NULL)
return B_NO_MEMORY;

View File

@ -494,7 +494,7 @@ add_block_devices(NodeList *devicesList, bool identifierMissing)
if (driveID == gBootDriveID)
continue;
BIOSDrive *drive = new BIOSDrive(driveID);
BIOSDrive *drive = new(nothrow) BIOSDrive(driveID);
if (drive->InitCheck() != B_OK) {
dprintf("could not add drive %u\n", driveID);
delete drive;
@ -741,7 +741,7 @@ platform_add_boot_device(struct stage2_args *args, NodeList *devicesList)
{
TRACE(("boot drive ID: %x\n", gBootDriveID));
BIOSDrive *drive = new BIOSDrive(gBootDriveID);
BIOSDrive *drive = new(nothrow) BIOSDrive(gBootDriveID);
if (drive->InitCheck() != B_OK) {
dprintf("no boot drive!\n");
return B_ERROR;

View File

@ -19,16 +19,16 @@ platform_add_menus(Menu *menu)
switch (menu->Type()) {
case MAIN_MENU:
menu->AddItem(item = new MenuItem("Select fail-safe video mode", video_mode_menu()));
menu->AddItem(item = new(nothrow) MenuItem("Select fail-safe video mode", video_mode_menu()));
item->SetTarget(video_mode_hook);
break;
case SAFE_MODE_MENU:
smp_add_safemode_menus(menu);
menu->AddItem(item = new MenuItem("Don't call the BIOS"));
menu->AddItem(item = new(nothrow) MenuItem("Don't call the BIOS"));
item->SetType(MENU_ITEM_MARKABLE);
menu->AddItem(item = new MenuItem("Disable APM"));
menu->AddItem(item = new(nothrow) MenuItem("Disable APM"));
item->SetType(MENU_ITEM_MARKABLE);
item->SetData("disable_apm");
item->SetHelpText("This overrides the APM setting in the kernel settings file");

View File

@ -510,13 +510,13 @@ smp_add_safemode_menus(Menu *menu)
// ToDo: this should work with dual CPUs with HT as well!
if (gKernelArgs.num_cpus > 2 || !supports_hyper_threading()) {
menu->AddItem(item = new MenuItem("Disable SMP"));
menu->AddItem(item = new(nothrow) MenuItem("Disable SMP"));
item->SetData(B_SAFEMODE_DISABLE_SMP);
item->SetType(MENU_ITEM_MARKABLE);
}
if (supports_hyper_threading()) {
menu->AddItem(item = new MenuItem("Disable Hyper-Threading"));
menu->AddItem(item = new(nothrow) MenuItem("Disable Hyper-Threading"));
item->SetData(B_SAFEMODE_DISABLE_HYPER_THREADING);
item->SetType(MENU_ITEM_MARKABLE);
}

View File

@ -412,29 +412,29 @@ video_mode_hook(Menu *menu, MenuItem *item)
Menu *
video_mode_menu()
{
Menu *menu = new Menu(CHOICE_MENU, "Select Video Mode");
Menu *menu = new(nothrow) Menu(CHOICE_MENU, "Select Video Mode");
MenuItem *item;
menu->AddItem(item = new MenuItem("Default"));
menu->AddItem(item = new(nothrow) MenuItem("Default"));
item->SetMarked(true);
item->Select(true);
item->SetHelpText("The Default video mode is the one currently configured in "
"the system. If there is no mode configured yet, a viable mode will be chosen "
"automatically.");
menu->AddItem(new MenuItem("Standard VGA"));
menu->AddItem(new(nothrow) MenuItem("Standard VGA"));
video_mode *mode = NULL;
while ((mode = (video_mode *)list_get_next_item(&sModeList, mode)) != NULL) {
char label[64];
sprintf(label, "%ldx%ld %ld bit", mode->width, mode->height, mode->bits_per_pixel);
menu->AddItem(item = new MenuItem(label));
menu->AddItem(item = new(nothrow) MenuItem(label));
item->SetData(mode);
}
menu->AddSeparatorItem();
menu->AddItem(item = new MenuItem("Return to main menu"));
menu->AddItem(item = new(nothrow) MenuItem("Return to main menu"));
item->SetType(MENU_ITEM_NO_CHOICE);
return menu;

View File

@ -77,7 +77,7 @@ platform_add_boot_device(struct stage2_args *args, NodeList *devicesList)
return B_ERROR;
}
Handle *device = new Handle(handle);
Handle *device = new(nothrow) Handle(handle);
if (device == NULL)
return B_NO_MEMORY;
@ -174,7 +174,7 @@ platform_add_block_devices(stage2_args *args, NodeList *devicesList)
continue;
}
Handle *device = new Handle(handle);
Handle *device = new(nothrow) Handle(handle);
printf("\t\t(could open device, handle = %p, node = %p)\n", (void *)handle, device);
devicesList->Add(device);

View File

@ -30,7 +30,7 @@ static ItemList sItemList;
status_t
add_boot_item(const char *name, void *data, size_t size)
{
boot_item *item = new boot_item;
boot_item *item = new(nothrow) boot_item;
if (item == NULL)
return B_NO_MEMORY;

View File

@ -298,7 +298,7 @@ block_cache::FreeBlock(cached_block *block)
cached_block *
block_cache::NewBlock(off_t blockNumber)
{
cached_block *block = new cached_block;
cached_block *block = new(nothrow) cached_block;
if (block == NULL) {
FATAL(("could not allocate block!\n"));
return NULL;
@ -679,7 +679,7 @@ cache_start_transaction(void *_cache)
if (cache->last_transaction && cache->last_transaction->open)
panic("last transaction (%ld) still open!\n", cache->last_transaction->id);
cache_transaction *transaction = new cache_transaction;
cache_transaction *transaction = new(nothrow) cache_transaction;
if (transaction == NULL)
return B_NO_MEMORY;
@ -841,7 +841,7 @@ cache_detach_sub_transaction(void *_cache, int32 id,
return B_BAD_VALUE;
// create a new transaction for the sub transaction
cache_transaction *newTransaction = new cache_transaction;
cache_transaction *newTransaction = new(nothrow) cache_transaction;
if (transaction == NULL)
return B_NO_MEMORY;
@ -1081,7 +1081,7 @@ block_cache_delete(void *_cache, bool allowWrites)
extern "C" void *
block_cache_create(int fd, off_t numBlocks, size_t blockSize, bool readOnly)
{
block_cache *cache = new block_cache(fd, numBlocks, blockSize, readOnly);
block_cache *cache = new(nothrow) block_cache(fd, numBlocks, blockSize, readOnly);
if (cache == NULL)
return NULL;

View File

@ -180,7 +180,9 @@ next_entry:
goto next_entry;
if (S_ISDIR(stat.st_mode) && fRecursive) {
KPath *nextPath = new KPath(path);
KPath *nextPath = new(nothrow) KPath(path);
if (!nextPath)
return B_NO_MEMORY;
if (fPaths.Push(nextPath) != B_OK)
return B_NO_MEMORY;
@ -211,7 +213,9 @@ DirectoryIterator::Unset()
void
DirectoryIterator::AddPath(const char *basePath, const char *subPath)
{
KPath *path = new KPath(basePath);
KPath *path = new(nothrow) KPath(basePath);
if (!path)
panic("out of memory");
if (subPath != NULL)
path->Append(subPath);

View File

@ -866,8 +866,11 @@ publish_device(struct devfs *fs, const char *path, device_node_info *deviceNode,
// every raw disk gets an I/O scheduler object attached
// ToDo: the driver should ask for a scheduler (ie. using its devfs node attributes)
if (isDisk && !strcmp(node->name, "raw"))
node->stream.u.dev.scheduler = new IOScheduler(path, info);
if (isDisk && !strcmp(node->name, "raw")) {
node->stream.u.dev.scheduler = new(nothrow) IOScheduler(path, info);
if (!node->stream.u.dev.scheduler)
return B_NO_MEMORY;
}
return status;
}