* 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:
@@ -7,6 +7,7 @@
|
|||||||
#include <kernel_cpp.h>
|
#include <kernel_cpp.h>
|
||||||
#include <stdlib.h>
|
#include <stdlib.h>
|
||||||
#include <string.h>
|
#include <string.h>
|
||||||
|
#include <new>
|
||||||
|
|
||||||
struct device_list_entry {
|
struct device_list_entry {
|
||||||
char * name;
|
char * name;
|
||||||
@@ -40,7 +41,7 @@ DeviceList::~DeviceList()
|
|||||||
status_t
|
status_t
|
||||||
DeviceList::AddDevice(const char *name, void *device)
|
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)
|
if (entry == NULL)
|
||||||
return B_NO_MEMORY;
|
return B_NO_MEMORY;
|
||||||
|
|
||||||
|
|||||||
@@ -16,6 +16,8 @@
|
|||||||
#include "BeOSCompatibility.h" // for pseudo mutex
|
#include "BeOSCompatibility.h" // for pseudo mutex
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
#include <new>
|
||||||
|
|
||||||
|
|
||||||
int32 api_version = B_CUR_DRIVER_API_VERSION;
|
int32 api_version = B_CUR_DRIVER_API_VERSION;
|
||||||
usb_module_info *gUSBModule = NULL;
|
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;
|
const usb_interface_info *interface = config->interface[i].active;
|
||||||
uint8 interfaceClass = interface->descr->interface_class;
|
uint8 interfaceClass = interface->descr->interface_class;
|
||||||
uint8 interfaceSubclass = interface->descr->interface_subclass;
|
uint8 interfaceSubclass = interface->descr->interface_subclass;
|
||||||
uint8 interfaceProtocol = interface->descr->interface_protocol;
|
|
||||||
TRACE("interface %lu: class: %u; subclass: %u; protocol: %u\n",
|
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
|
if (interfaceClass == USB_INTERFACE_CLASS_HID
|
||||||
&& interfaceSubclass == USB_INTERFACE_SUBCLASS_HID_BOOT) {
|
&& interfaceSubclass == USB_INTERFACE_SUBCLASS_HID_BOOT) {
|
||||||
@@ -221,7 +223,7 @@ init_driver()
|
|||||||
if (get_module(B_USB_MODULE_NAME, (module_info **)&gUSBModule) != B_OK)
|
if (get_module(B_USB_MODULE_NAME, (module_info **)&gUSBModule) != B_OK)
|
||||||
return B_ERROR;
|
return B_ERROR;
|
||||||
|
|
||||||
gDeviceList = new DeviceList();
|
gDeviceList = new(std::nothrow) DeviceList();
|
||||||
if (gDeviceList == NULL) {
|
if (gDeviceList == NULL) {
|
||||||
put_module(B_USB_MODULE_NAME);
|
put_module(B_USB_MODULE_NAME);
|
||||||
return B_NO_MEMORY;
|
return B_NO_MEMORY;
|
||||||
|
|||||||
@@ -8,6 +8,7 @@
|
|||||||
#include <usb/USB_hid.h>
|
#include <usb/USB_hid.h>
|
||||||
#include <stdio.h>
|
#include <stdio.h>
|
||||||
#include <string.h>
|
#include <string.h>
|
||||||
|
#include <new>
|
||||||
|
|
||||||
// includes for the different device types
|
// includes for the different device types
|
||||||
#include "KeyboardDevice.h"
|
#include "KeyboardDevice.h"
|
||||||
@@ -181,11 +182,14 @@ HIDDevice::MakeHIDDevice(usb_device device,
|
|||||||
|
|
||||||
// determine device type and create the device object
|
// determine device type and create the device object
|
||||||
if (deviceType == USB_HID_DEVICE_TYPE_KEYBOARD) {
|
if (deviceType == USB_HID_DEVICE_TYPE_KEYBOARD) {
|
||||||
return new KeyboardDevice(device, interruptPipe, interfaceIndex,
|
return new(std::nothrow) KeyboardDevice(device, interruptPipe,
|
||||||
finalInstructions, instructionCount, totalReportSize);
|
interfaceIndex, finalInstructions, instructionCount,
|
||||||
} else if (deviceType == USB_HID_DEVICE_TYPE_MOUSE) {
|
totalReportSize);
|
||||||
return new MouseDevice(device, interruptPipe, interfaceIndex,
|
} else if (deviceType == USB_HID_DEVICE_TYPE_MOUSE
|
||||||
finalInstructions, instructionCount, totalReportSize);
|
|| deviceType == 0x01250015) {
|
||||||
|
return new(std::nothrow) MouseDevice(device, interruptPipe,
|
||||||
|
interfaceIndex, finalInstructions, instructionCount,
|
||||||
|
totalReportSize);
|
||||||
}
|
}
|
||||||
|
|
||||||
TRACE_ALWAYS("unsupported device type 0x%08lx\n", deviceType);
|
TRACE_ALWAYS("unsupported device type 0x%08lx\n", deviceType);
|
||||||
|
|||||||
Reference in New Issue
Block a user