* Use new(std::nothrow) everywhere (NULL checks were already there).

* Fix a warning if trace output is not enabled.


git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@27456 a95241bf-73f2-0310-859d-f6bbb57e9c96
This commit is contained in:
Michael Lotz
2008-09-12 17:00:28 +00:00
parent 8395debafa
commit 11b9aad7f7
3 changed files with 16 additions and 9 deletions
@@ -7,6 +7,7 @@
#include <kernel_cpp.h>
#include <stdlib.h>
#include <string.h>
#include <new>
struct device_list_entry {
char * name;
@@ -40,7 +41,7 @@ DeviceList::~DeviceList()
status_t
DeviceList::AddDevice(const char *name, void *device)
{
device_list_entry *entry = new device_list_entry;
device_list_entry *entry = new(std::nothrow) device_list_entry;
if (entry == NULL)
return B_NO_MEMORY;
@@ -16,6 +16,8 @@
#include "BeOSCompatibility.h" // for pseudo mutex
#endif
#include <new>
int32 api_version = B_CUR_DRIVER_API_VERSION;
usb_module_info *gUSBModule = NULL;
@@ -68,9 +70,9 @@ usb_hid_device_added(usb_device device, void **cookie)
const usb_interface_info *interface = config->interface[i].active;
uint8 interfaceClass = interface->descr->interface_class;
uint8 interfaceSubclass = interface->descr->interface_subclass;
uint8 interfaceProtocol = interface->descr->interface_protocol;
TRACE("interface %lu: class: %u; subclass: %u; protocol: %u\n",
i, interfaceClass, interfaceSubclass, interfaceProtocol);
i, interfaceClass, interfaceSubclass,
interface->descr->interface_protocol);
if (interfaceClass == USB_INTERFACE_CLASS_HID
&& interfaceSubclass == USB_INTERFACE_SUBCLASS_HID_BOOT) {
@@ -221,7 +223,7 @@ init_driver()
if (get_module(B_USB_MODULE_NAME, (module_info **)&gUSBModule) != B_OK)
return B_ERROR;
gDeviceList = new DeviceList();
gDeviceList = new(std::nothrow) DeviceList();
if (gDeviceList == NULL) {
put_module(B_USB_MODULE_NAME);
return B_NO_MEMORY;
@@ -8,6 +8,7 @@
#include <usb/USB_hid.h>
#include <stdio.h>
#include <string.h>
#include <new>
// includes for the different device types
#include "KeyboardDevice.h"
@@ -181,11 +182,14 @@ HIDDevice::MakeHIDDevice(usb_device device,
// determine device type and create the device object
if (deviceType == USB_HID_DEVICE_TYPE_KEYBOARD) {
return new KeyboardDevice(device, interruptPipe, interfaceIndex,
finalInstructions, instructionCount, totalReportSize);
} else if (deviceType == USB_HID_DEVICE_TYPE_MOUSE) {
return new MouseDevice(device, interruptPipe, interfaceIndex,
finalInstructions, instructionCount, totalReportSize);
return new(std::nothrow) KeyboardDevice(device, interruptPipe,
interfaceIndex, finalInstructions, instructionCount,
totalReportSize);
} else if (deviceType == USB_HID_DEVICE_TYPE_MOUSE
|| deviceType == 0x01250015) {
return new(std::nothrow) MouseDevice(device, interruptPipe,
interfaceIndex, finalInstructions, instructionCount,
totalReportSize);
}
TRACE_ALWAYS("unsupported device type 0x%08lx\n", deviceType);