mirror of
https://github.com/mozilla/gecko-dev.git
synced 2025-02-21 17:59:34 +00:00
Bug 784739 - Switch from NULL to nullptr in hal/. r=ehsan
This commit is contained in:
parent
5bae25cea8
commit
0d87358ff5
@ -217,7 +217,7 @@ public:
|
||||
}
|
||||
|
||||
void BroadcastInformation(const InfoType& aInfo) {
|
||||
// It is possible for mObservers to be NULL here on some platforms,
|
||||
// It is possible for mObservers to be nullptr here on some platforms,
|
||||
// because a call to BroadcastInformation gets queued up asynchronously
|
||||
// while RemoveObserver is running (and before the notifications are
|
||||
// disabled). The queued call can then get run after mObservers has
|
||||
@ -746,12 +746,12 @@ SwitchState GetCurrentSwitchState(SwitchDevice aDevice)
|
||||
|
||||
typedef mozilla::ObserverList<SwitchEvent> SwitchObserverList;
|
||||
|
||||
static SwitchObserverList *sSwitchObserverLists = NULL;
|
||||
static SwitchObserverList *sSwitchObserverLists = nullptr;
|
||||
|
||||
static SwitchObserverList&
|
||||
GetSwitchObserverList(SwitchDevice aDevice) {
|
||||
MOZ_ASSERT(0 <= aDevice && aDevice < NUM_SWITCH_DEVICE);
|
||||
if (sSwitchObserverLists == NULL) {
|
||||
if (sSwitchObserverLists == nullptr) {
|
||||
sSwitchObserverLists = new SwitchObserverList[NUM_SWITCH_DEVICE];
|
||||
}
|
||||
return sSwitchObserverLists[aDevice];
|
||||
@ -766,7 +766,7 @@ ReleaseObserversIfNeeded() {
|
||||
|
||||
//The length of every list is 0, no observer in the list.
|
||||
delete [] sSwitchObserverLists;
|
||||
sSwitchObserverLists = NULL;
|
||||
sSwitchObserverLists = nullptr;
|
||||
}
|
||||
|
||||
void
|
||||
|
@ -49,11 +49,11 @@ class Gamepad {
|
||||
vector<Axis> axes;
|
||||
|
||||
public:
|
||||
Gamepad() : mDevice(NULL), mSuperIndex(-1) {}
|
||||
Gamepad() : mDevice(nullptr), mSuperIndex(-1) {}
|
||||
bool operator==(IOHIDDeviceRef device) const { return mDevice == device; }
|
||||
bool empty() const { return mDevice == NULL; }
|
||||
bool empty() const { return mDevice == nullptr; }
|
||||
void clear() {
|
||||
mDevice = NULL;
|
||||
mDevice = nullptr;
|
||||
buttons.clear();
|
||||
axes.clear();
|
||||
mSuperIndex = -1;
|
||||
@ -70,7 +70,7 @@ class Gamepad {
|
||||
if (buttons[i].element == element)
|
||||
return &buttons[i];
|
||||
}
|
||||
return NULL;
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
const Axis* lookupAxis(IOHIDElementRef element) const {
|
||||
@ -78,7 +78,7 @@ class Gamepad {
|
||||
if (axes[i].element == element)
|
||||
return &axes[i];
|
||||
}
|
||||
return NULL;
|
||||
return nullptr;
|
||||
}
|
||||
};
|
||||
|
||||
@ -87,7 +87,7 @@ void Gamepad::init(IOHIDDeviceRef device) {
|
||||
mDevice = device;
|
||||
|
||||
CFArrayRef elements = IOHIDDeviceCopyMatchingElements(device,
|
||||
NULL,
|
||||
nullptr,
|
||||
kIOHIDOptionsTypeNone);
|
||||
CFIndex n = CFArrayGetCount(elements);
|
||||
for (CFIndex i = 0; i < n; i++) {
|
||||
@ -247,13 +247,13 @@ MatchingDictionary(UInt32 inUsagePage, UInt32 inUsage)
|
||||
&kCFTypeDictionaryKeyCallBacks,
|
||||
&kCFTypeDictionaryValueCallBacks);
|
||||
if (!dict)
|
||||
return NULL;
|
||||
return nullptr;
|
||||
CFNumberRef number = CFNumberCreate(kCFAllocatorDefault,
|
||||
kCFNumberIntType,
|
||||
&inUsagePage);
|
||||
if (!number) {
|
||||
CFRelease(dict);
|
||||
return NULL;
|
||||
return nullptr;
|
||||
}
|
||||
CFDictionarySetValue(dict, CFSTR(kIOHIDDeviceUsagePageKey), number);
|
||||
CFRelease(number);
|
||||
@ -261,7 +261,7 @@ MatchingDictionary(UInt32 inUsagePage, UInt32 inUsage)
|
||||
number = CFNumberCreate(kCFAllocatorDefault, kCFNumberIntType, &inUsage);
|
||||
if (!number) {
|
||||
CFRelease(dict);
|
||||
return NULL;
|
||||
return nullptr;
|
||||
}
|
||||
CFDictionarySetValue(dict, CFSTR(kIOHIDDeviceUsageKey), number);
|
||||
CFRelease(number);
|
||||
@ -269,17 +269,17 @@ MatchingDictionary(UInt32 inUsagePage, UInt32 inUsage)
|
||||
return dict;
|
||||
}
|
||||
|
||||
DarwinGamepadService::DarwinGamepadService() : mManager(NULL) {}
|
||||
DarwinGamepadService::DarwinGamepadService() : mManager(nullptr) {}
|
||||
|
||||
DarwinGamepadService::~DarwinGamepadService()
|
||||
{
|
||||
if (mManager != NULL)
|
||||
if (mManager != nullptr)
|
||||
CFRelease(mManager);
|
||||
}
|
||||
|
||||
void DarwinGamepadService::Startup()
|
||||
{
|
||||
if (mManager != NULL)
|
||||
if (mManager != nullptr)
|
||||
return;
|
||||
|
||||
IOHIDManagerRef manager = IOHIDManagerCreate(kCFAllocatorDefault,
|
||||
@ -302,7 +302,7 @@ void DarwinGamepadService::Startup()
|
||||
}
|
||||
|
||||
CFArrayRef criteria =
|
||||
CFArrayCreate(kCFAllocatorDefault, (const void**)criteria_arr, 2, NULL);
|
||||
CFArrayCreate(kCFAllocatorDefault, (const void**)criteria_arr, 2, nullptr);
|
||||
if (!criteria) {
|
||||
CFRelease(criteria_arr[1]);
|
||||
CFRelease(criteria_arr[0]);
|
||||
@ -342,7 +342,7 @@ void DarwinGamepadService::Shutdown()
|
||||
if (manager) {
|
||||
IOHIDManagerClose(manager, 0);
|
||||
CFRelease(manager);
|
||||
mManager = NULL;
|
||||
mManager = nullptr;
|
||||
}
|
||||
}
|
||||
|
||||
@ -351,7 +351,7 @@ void DarwinGamepadService::Shutdown()
|
||||
namespace mozilla {
|
||||
namespace hal_impl {
|
||||
|
||||
DarwinGamepadService* gService = NULL;
|
||||
DarwinGamepadService* gService = nullptr;
|
||||
|
||||
void StartMonitoringGamepadStatus()
|
||||
{
|
||||
@ -369,7 +369,7 @@ void StopMonitoringGamepadStatus()
|
||||
|
||||
gService->Shutdown();
|
||||
delete gService;
|
||||
gService = NULL;
|
||||
gService = nullptr;
|
||||
}
|
||||
|
||||
} // namespace hal_impl
|
||||
|
@ -203,7 +203,7 @@ runTavaruaRadio(void *)
|
||||
if (!sRadioEnabled) {
|
||||
NS_DispatchToMainThread(new RadioUpdate(hal::FM_RADIO_OPERATION_ENABLE,
|
||||
hal::FM_RADIO_OPERATION_STATUS_FAIL));
|
||||
return NULL;
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
uint8_t buf[128];
|
||||
@ -240,7 +240,7 @@ runTavaruaRadio(void *)
|
||||
}
|
||||
}
|
||||
|
||||
return NULL;
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
/* This runs on the main thread but most of the
|
||||
@ -282,7 +282,7 @@ EnableFMRadio(const hal::FMRadioSettings& aInfo)
|
||||
|
||||
// Tavarua specific start
|
||||
sTavaruaVersion = cap.version;
|
||||
pthread_create(&sRadioThread, NULL, runTavaruaRadio, NULL);
|
||||
pthread_create(&sRadioThread, nullptr, runTavaruaRadio, nullptr);
|
||||
// Tavarua specific end
|
||||
}
|
||||
|
||||
@ -301,7 +301,7 @@ DisableFMRadio()
|
||||
}
|
||||
// Tavarua specific end
|
||||
|
||||
pthread_join(sRadioThread, NULL);
|
||||
pthread_join(sRadioThread, nullptr);
|
||||
|
||||
close(sRadioFD);
|
||||
|
||||
|
@ -183,7 +183,7 @@ VibratorRunnable::Run()
|
||||
mMonitor.Wait();
|
||||
}
|
||||
}
|
||||
sVibratorRunnable = NULL;
|
||||
sVibratorRunnable = nullptr;
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
@ -345,7 +345,7 @@ UnregisterBatteryObserverIOThread()
|
||||
MOZ_ASSERT(sBatteryObserver);
|
||||
|
||||
UnregisterUeventListener(sBatteryObserver);
|
||||
sBatteryObserver = NULL;
|
||||
sBatteryObserver = nullptr;
|
||||
}
|
||||
|
||||
void
|
||||
@ -593,7 +593,7 @@ SetCpuSleepAllowed(bool aAllowed)
|
||||
UpdateCpuSleepState();
|
||||
}
|
||||
|
||||
static light_device_t* sLights[hal::eHalLightID_Count]; // will be initialized to NULL
|
||||
static light_device_t* sLights[hal::eHalLightID_Count]; // will be initialized to nullptr
|
||||
|
||||
light_device_t* GetDevice(hw_module_t* module, char const* name)
|
||||
{
|
||||
@ -603,14 +603,14 @@ light_device_t* GetDevice(hw_module_t* module, char const* name)
|
||||
if (err == 0) {
|
||||
return (light_device_t*)device;
|
||||
} else {
|
||||
return NULL;
|
||||
return nullptr;
|
||||
}
|
||||
}
|
||||
|
||||
void
|
||||
InitLights()
|
||||
{
|
||||
// assume that if backlight is NULL, nothing has been set yet
|
||||
// assume that if backlight is nullptr, nothing has been set yet
|
||||
// if this is not true, the initialization will occur everytime a light is read or set!
|
||||
if (!sLights[hal::eHalLightID_Backlight]) {
|
||||
int err;
|
||||
@ -651,7 +651,8 @@ SetLight(hal::LightType light, const hal::LightConfiguration& aConfig)
|
||||
|
||||
InitLights();
|
||||
|
||||
if (light < 0 || light >= hal::eHalLightID_Count || sLights[light] == NULL) {
|
||||
if (light < 0 || light >= hal::eHalLightID_Count ||
|
||||
sLights[light] == nullptr) {
|
||||
return false;
|
||||
}
|
||||
|
||||
@ -676,7 +677,8 @@ GetLight(hal::LightType light, hal::LightConfiguration* aConfig)
|
||||
InitLights();
|
||||
#endif
|
||||
|
||||
if (light < 0 || light >= hal::eHalLightID_Count || sLights[light] == NULL) {
|
||||
if (light < 0 || light >= hal::eHalLightID_Count ||
|
||||
sLights[light] == nullptr) {
|
||||
return false;
|
||||
}
|
||||
|
||||
@ -848,7 +850,7 @@ public:
|
||||
|
||||
int AlarmData::sNextGeneration = 0;
|
||||
|
||||
AlarmData* sAlarmData = NULL;
|
||||
AlarmData* sAlarmData = nullptr;
|
||||
|
||||
class AlarmFiredEvent : public nsRunnable {
|
||||
public:
|
||||
@ -920,7 +922,7 @@ WaitForAlarm(void* aData)
|
||||
}
|
||||
|
||||
pthread_cleanup_pop(1);
|
||||
return NULL;
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
bool
|
||||
@ -941,7 +943,7 @@ EnableAlarm()
|
||||
sigemptyset(&actions.sa_mask);
|
||||
actions.sa_flags = 0;
|
||||
actions.sa_handler = ShutDownAlarm;
|
||||
if (sigaction(SIGUSR1, &actions, NULL)) {
|
||||
if (sigaction(SIGUSR1, &actions, nullptr)) {
|
||||
HAL_LOG(("Failed to set SIGUSR1 signal for alarm-watcher thread."));
|
||||
return false;
|
||||
}
|
||||
@ -956,7 +958,7 @@ EnableAlarm()
|
||||
int status = pthread_create(&sAlarmFireWatcherThread, &attr, WaitForAlarm,
|
||||
alarmData.get());
|
||||
if (status) {
|
||||
alarmData = NULL;
|
||||
alarmData = nullptr;
|
||||
delete sInternalLockCpuMonitor;
|
||||
HAL_LOG(("Failed to create alarm-watcher thread. Status: %d.", status));
|
||||
return false;
|
||||
@ -975,7 +977,7 @@ DisableAlarm()
|
||||
MOZ_ASSERT(sAlarmData);
|
||||
|
||||
// NB: this must happen-before the thread cancellation.
|
||||
sAlarmData = NULL;
|
||||
sAlarmData = nullptr;
|
||||
|
||||
// The cancel will interrupt the thread and destroy it, freeing the
|
||||
// data pointed at by sAlarmData.
|
||||
|
@ -229,7 +229,7 @@ static void
|
||||
SetSensorState(SensorType aSensor, bool activate)
|
||||
{
|
||||
int type = HalSensorToHardwareSensor(aSensor);
|
||||
const sensor_t* sensors = NULL;
|
||||
const sensor_t* sensors = nullptr;
|
||||
|
||||
int size = sSensorModule->get_sensors_list(sSensorModule, &sensors);
|
||||
for (ssize_t i = 0; i < size; i++) {
|
||||
@ -253,7 +253,7 @@ EnableSensorNotifications(SensorType aSensor)
|
||||
|
||||
sensors_open(&sSensorModule->common, &sSensorDevice);
|
||||
if (!sSensorDevice) {
|
||||
sSensorModule = NULL;
|
||||
sSensorModule = nullptr;
|
||||
LOGE("Can't get sensor poll device from module \n");
|
||||
return;
|
||||
}
|
||||
|
@ -359,7 +359,7 @@ ReleaseResourceIfNeed()
|
||||
{
|
||||
if (sSwitchObserver->GetEnableCount() == 0) {
|
||||
UnregisterUeventListener(sSwitchObserver);
|
||||
sSwitchObserver = NULL;
|
||||
sSwitchObserver = nullptr;
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -183,7 +183,7 @@ InitializeUevent()
|
||||
static void
|
||||
ShutdownUevent()
|
||||
{
|
||||
sPoller = NULL;
|
||||
sPoller = nullptr;
|
||||
}
|
||||
|
||||
void
|
||||
|
@ -120,7 +120,9 @@ LinuxGamepadService::AddDevice(struct udev_device* dev)
|
||||
mUdev.udev_device_get_property_value(dev, "ID_MODEL_ID");
|
||||
if (!vendor_id || !model_id) {
|
||||
struct udev_device* parent =
|
||||
mUdev.udev_device_get_parent_with_subsystem_devtype(dev, "input", NULL);
|
||||
mUdev.udev_device_get_parent_with_subsystem_devtype(dev,
|
||||
"input",
|
||||
nullptr);
|
||||
if (parent) {
|
||||
vendor_id = mUdev.udev_device_get_sysattr_value(parent, "id/vendor");
|
||||
model_id = mUdev.udev_device_get_sysattr_value(parent, "id/product");
|
||||
|
@ -115,8 +115,10 @@ EnableSensorNotifications(SensorType aSensor)
|
||||
}
|
||||
|
||||
nsRefPtr<ISensorManager> manager;
|
||||
if (FAILED(CoCreateInstance(CLSID_SensorManager, NULL, CLSCTX_INPROC_SERVER,
|
||||
IID_ISensorManager, getter_AddRefs(manager)))) {
|
||||
if (FAILED(CoCreateInstance(CLSID_SensorManager, nullptr,
|
||||
CLSCTX_INPROC_SERVER,
|
||||
IID_ISensorManager,
|
||||
getter_AddRefs(manager)))) {
|
||||
return;
|
||||
}
|
||||
|
||||
@ -143,7 +145,7 @@ EnableSensorNotifications(SensorType aSensor)
|
||||
// Set report interval to 100ms if possible.
|
||||
// Default value depends on drivers.
|
||||
nsRefPtr<IPortableDeviceValues> values;
|
||||
if (SUCCEEDED(CoCreateInstance(CLSID_PortableDeviceValues, NULL,
|
||||
if (SUCCEEDED(CoCreateInstance(CLSID_PortableDeviceValues, nullptr,
|
||||
CLSCTX_INPROC_SERVER,
|
||||
IID_IPortableDeviceValues,
|
||||
getter_AddRefs(values)))) {
|
||||
@ -173,7 +175,7 @@ void
|
||||
DisableSensorNotifications(SensorType aSensor)
|
||||
{
|
||||
if (aSensor == SENSOR_ACCELERATION && sAccelerometer) {
|
||||
sAccelerometer->SetEventSink(NULL);
|
||||
sAccelerometer->SetEventSink(nullptr);
|
||||
sAccelerometer = nullptr;
|
||||
}
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user