Skip to content

Commit d6a48b5

Browse files
committed
Turn NULLs into nullptr
Avoids overload problems with Callback(nullptr) versus Callback(fnptr).
1 parent 9577b08 commit d6a48b5

31 files changed

+82
-95
lines changed

components/802.15.4_RF/atmel-rf-driver/source/NanostackRfPhyAtmel.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -524,7 +524,7 @@ static void rf_if_reset_radio(void)
524524
#else
525525
rf->spi.frequency(MBED_CONF_ATMEL_RF_LOW_SPI_SPEED);
526526
#endif
527-
rf->IRQ.rise(0);
527+
rf->IRQ.rise(nullptr);
528528
rf->RST = 1;
529529
ThisThread::sleep_for(2);
530530
rf->RST = 0;

components/wifi/esp8266-driver/ESP8266/ESP8266.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -41,7 +41,7 @@ ESP8266::ESP8266(PinName tx, PinName rx, bool debug, PinName rts, PinName cts)
4141
: _sdk_v(-1, -1, -1),
4242
_at_v(-1, -1, -1),
4343
_tcp_passive(false),
44-
_callback(0),
44+
_callback(),
4545
_serial(tx, rx, MBED_CONF_ESP8266_SERIAL_BAUDRATE),
4646
_serial_rts(rts),
4747
_serial_cts(cts),

components/wifi/esp8266-driver/ESP8266Interface.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -71,7 +71,7 @@ ESP8266Interface::ESP8266Interface()
7171
_connect_retval(NSAPI_ERROR_OK),
7272
_disconnect_retval(NSAPI_ERROR_OK),
7373
_conn_stat(NSAPI_STATUS_DISCONNECTED),
74-
_conn_stat_cb(NULL),
74+
_conn_stat_cb(),
7575
_global_event_queue(mbed_event_queue()), // Needs to be set before attaching event() to SIGIO
7676
_oob_event_id(0),
7777
_connect_event_id(0),
@@ -113,7 +113,7 @@ ESP8266Interface::ESP8266Interface(PinName tx, PinName rx, bool debug, PinName r
113113
_connect_retval(NSAPI_ERROR_OK),
114114
_disconnect_retval(NSAPI_ERROR_OK),
115115
_conn_stat(NSAPI_STATUS_DISCONNECTED),
116-
_conn_stat_cb(NULL),
116+
_conn_stat_cb(),
117117
_global_event_queue(mbed_event_queue()), // Needs to be set before attaching event() to SIGIO
118118
_oob_event_id(0),
119119
_connect_event_id(0),

drivers/SerialBase.h

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -216,7 +216,7 @@ class SerialBase : private NonCopyable<SerialBase> {
216216
/** Begin asynchronous write using 8bit buffer.
217217
*
218218
* The write operation ends with any of the enabled events and invokes
219-
* registered callback function (which can be NULL to not receive callback at all).
219+
* registered callback function (which can be empty to not receive callback at all).
220220
* Events that are not enabled by event argument are simply ignored.
221221
* Operation has to be ended explicitly by calling abort_write() when
222222
* no events are enabled.
@@ -233,7 +233,7 @@ class SerialBase : private NonCopyable<SerialBase> {
233233
/** Begin asynchronous write using 16bit buffer.
234234
*
235235
* The write operation ends with any of the enabled events and invokes
236-
* registered callback function (which can be NULL to not receive callback at all).
236+
* registered callback function (which can be empty to not receive callback at all).
237237
* Events that are not enabled by event argument are simply ignored.
238238
* Operation has to be ended explicitly by calling abort_write() when
239239
* no events are enabled.
@@ -256,7 +256,7 @@ class SerialBase : private NonCopyable<SerialBase> {
256256
/** Begin asynchronous reading using 8bit buffer.
257257
*
258258
* The read operation ends with any of the enabled events and invokes registered
259-
* callback function (which can be NULL to not receive callback at all).
259+
* callback function (which can be empty to not receive callback at all).
260260
* Events that are not enabled by event argument are simply ignored.
261261
* Operation has to be ended explicitly by calling abort_read() when
262262
* no events are enabled.
@@ -274,7 +274,7 @@ class SerialBase : private NonCopyable<SerialBase> {
274274
/** Begin asynchronous reading using 16bit buffer.
275275
*
276276
* The read operation ends with any of the enabled events and invokes registered
277-
* callback function (which can be NULL to not receive callback at all).
277+
* callback function (which can be empty to not receive callback at all).
278278
* Events that are not enabled by event argument are simply ignored.
279279
* Operation has to be ended explicitly by calling abort_read() when
280280
* no events are enabled.

drivers/internal/PolledQueue.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -42,7 +42,7 @@ class PolledQueue: public TaskQueue {
4242
*
4343
* @param cb Callback called when dispatch needs to be called
4444
*/
45-
PolledQueue(mbed::Callback<void()> cb = NULL);
45+
PolledQueue(mbed::Callback<void()> cb = nullptr);
4646

4747
virtual ~PolledQueue();
4848

drivers/internal/USBDevice.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -147,7 +147,7 @@ class USBDevice: public USBPhyEvents {
147147
* @param callback Method pointer to be called when a packet is transferred
148148
* @returns true if successful, false otherwise
149149
*/
150-
bool endpoint_add(usb_ep_t endpoint, uint32_t max_packet, usb_ep_type_t type, mbed::Callback<void()> callback = NULL);
150+
bool endpoint_add(usb_ep_t endpoint, uint32_t max_packet, usb_ep_type_t type, mbed::Callback<void()> callback = nullptr);
151151

152152
/**
153153
* Add an endpoint

drivers/source/CAN.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -56,7 +56,7 @@ CAN::~CAN()
5656

5757
// Detaching interrupts releases the sleep lock if it was locked
5858
for (int irq = 0; irq < IrqCnt; irq++) {
59-
attach(NULL, (IrqType)irq);
59+
attach(nullptr, (IrqType)irq);
6060
}
6161
can_irq_free(&_can);
6262
can_free(&_can);
@@ -147,7 +147,7 @@ void CAN::attach(Callback<void()> func, IrqType type)
147147
if (_irq[(CanIrqType)type]) {
148148
sleep_manager_unlock_deep_sleep();
149149
}
150-
_irq[(CanIrqType)type] = NULL;
150+
_irq[(CanIrqType)type] = nullptr;
151151
can_irq_set(&_can, (CanIrqType)type, 0);
152152
}
153153
unlock();

drivers/source/InterruptIn.cpp

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -26,8 +26,8 @@ namespace mbed {
2626
// constructor, with a default value for the PinMode.
2727
InterruptIn::InterruptIn(PinName pin) : gpio(),
2828
gpio_irq(),
29-
_rise(NULL),
30-
_fall(NULL)
29+
_rise(),
30+
_fall()
3131
{
3232
// No lock needed in the constructor
3333
irq_init(pin);
@@ -37,8 +37,8 @@ InterruptIn::InterruptIn(PinName pin) : gpio(),
3737
InterruptIn::InterruptIn(PinName pin, PinMode mode) :
3838
gpio(),
3939
gpio_irq(),
40-
_rise(NULL),
41-
_fall(NULL)
40+
_rise(),
41+
_fall()
4242
{
4343
// No lock needed in the constructor
4444
irq_init(pin);
@@ -76,7 +76,7 @@ void InterruptIn::rise(Callback<void()> func)
7676
_rise = func;
7777
gpio_irq_set(&gpio_irq, IRQ_RISE, 1);
7878
} else {
79-
_rise = NULL;
79+
_rise = nullptr;
8080
gpio_irq_set(&gpio_irq, IRQ_RISE, 0);
8181
}
8282
core_util_critical_section_exit();
@@ -89,7 +89,7 @@ void InterruptIn::fall(Callback<void()> func)
8989
_fall = func;
9090
gpio_irq_set(&gpio_irq, IRQ_FALL, 1);
9191
} else {
92-
_fall = NULL;
92+
_fall = nullptr;
9393
gpio_irq_set(&gpio_irq, IRQ_FALL, 0);
9494
}
9595
core_util_critical_section_exit();

drivers/source/SPI.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -151,14 +151,14 @@ SPI::~SPI()
151151
lock();
152152
/* Make sure a stale pointer isn't left in peripheral's owner field */
153153
if (_peripheral->owner == this) {
154-
_peripheral->owner = NULL;
154+
_peripheral->owner = nullptr;
155155
}
156156
unlock();
157157
}
158158

159159
SPI::spi_peripheral_s *SPI::_lookup(SPI::SPIName name)
160160
{
161-
SPI::spi_peripheral_s *result = NULL;
161+
SPI::spi_peripheral_s *result = nullptr;
162162
core_util_critical_section_enter();
163163
for (int idx = 0; idx < _peripherals_used; idx++) {
164164
if (_peripherals[idx].name == name) {

drivers/source/Serial.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -28,11 +28,11 @@ Serial::Serial(const serial_pinmap_t &static_pinmap, const char *name, int baud)
2828
{
2929
}
3030

31-
Serial::Serial(PinName tx, PinName rx, int baud): SerialBase(tx, rx, baud), Stream(NULL)
31+
Serial::Serial(PinName tx, PinName rx, int baud): SerialBase(tx, rx, baud), Stream()
3232
{
3333
}
3434

35-
Serial::Serial(const serial_pinmap_t &static_pinmap, int baud): SerialBase(static_pinmap, baud), Stream(NULL)
35+
Serial::Serial(const serial_pinmap_t &static_pinmap, int baud): SerialBase(static_pinmap, baud), Stream()
3636
{
3737
}
3838

0 commit comments

Comments
 (0)