mirror of
https://gitee.com/mirrors_PX4/PX4-Autopilot.git
synced 2026-10-21 05:33:35 +08:00
clang-tidy modernize-use-nullptr
This commit is contained in:
@@ -64,7 +64,7 @@ static const char *kTmpData = MOUNTPOINT "/$log$.txt";
|
||||
|
||||
//-------------------------------------------------------------------
|
||||
static bool
|
||||
stat_file(const char *file, time_t *date = 0, uint32_t *size = 0)
|
||||
stat_file(const char *file, time_t *date = nullptr, uint32_t *size = nullptr)
|
||||
{
|
||||
struct stat st;
|
||||
|
||||
@@ -89,7 +89,7 @@ MavlinkLogHandler::new_instance(Mavlink *mavlink)
|
||||
//-------------------------------------------------------------------
|
||||
MavlinkLogHandler::MavlinkLogHandler(Mavlink *mavlink)
|
||||
: MavlinkStream(mavlink)
|
||||
, _pLogHandlerHelper(0)
|
||||
, _pLogHandlerHelper(nullptr)
|
||||
{
|
||||
|
||||
}
|
||||
@@ -184,7 +184,7 @@ MavlinkLogHandler::_log_request_list(const mavlink_message_t *msg)
|
||||
//-- Is this a new request?
|
||||
if ((request.end - request.start) > _pLogHandlerHelper->log_count) {
|
||||
delete _pLogHandlerHelper;
|
||||
_pLogHandlerHelper = NULL;
|
||||
_pLogHandlerHelper = nullptr;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -269,7 +269,7 @@ MavlinkLogHandler::_log_request_erase(const mavlink_message_t * /*msg*/)
|
||||
*/
|
||||
if (_pLogHandlerHelper) {
|
||||
delete _pLogHandlerHelper;
|
||||
_pLogHandlerHelper = 0;
|
||||
_pLogHandlerHelper = nullptr;
|
||||
}
|
||||
|
||||
//-- Delete all logs
|
||||
@@ -305,7 +305,7 @@ MavlinkLogHandler::_log_request_end(const mavlink_message_t * /*msg*/)
|
||||
|
||||
if (_pLogHandlerHelper) {
|
||||
delete _pLogHandlerHelper;
|
||||
_pLogHandlerHelper = 0;
|
||||
_pLogHandlerHelper = nullptr;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -378,7 +378,7 @@ LogListHelper::LogListHelper()
|
||||
, current_log_size(0)
|
||||
, current_log_data_offset(0)
|
||||
, current_log_data_remaining(0)
|
||||
, current_log_filep(0)
|
||||
, current_log_filep(nullptr)
|
||||
{
|
||||
_init();
|
||||
}
|
||||
@@ -435,7 +435,7 @@ LogListHelper::open_for_transmit()
|
||||
{
|
||||
if (current_log_filep) {
|
||||
::fclose(current_log_filep);
|
||||
current_log_filep = 0;
|
||||
current_log_filep = nullptr;
|
||||
}
|
||||
|
||||
current_log_filep = ::fopen(current_log_filename, "rb");
|
||||
@@ -605,7 +605,7 @@ LogListHelper::_get_log_time_size(const char *path, const char *file, time_t &da
|
||||
if (sscanf(&file[3], "%u", &u) == 1) {
|
||||
date += (u * 60);
|
||||
|
||||
if (stat_file(path, 0, &size)) {
|
||||
if (stat_file(path, nullptr, &size)) {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1062,7 +1062,7 @@ Mavlink::find_broadcast_address()
|
||||
#else
|
||||
// On Linux, we can determine the required size of the
|
||||
// buffer first by providing NULL to ifc_req.
|
||||
ifconf.ifc_req = NULL;
|
||||
ifconf.ifc_req = nullptr;
|
||||
ifconf.ifc_len = 0;
|
||||
|
||||
ret = ioctl(_socket_fd, SIOCGIFCONF, &ifconf);
|
||||
@@ -1455,7 +1455,7 @@ Mavlink::message_buffer_init(int size)
|
||||
|
||||
int ret;
|
||||
|
||||
if (_message_buffer.data == 0) {
|
||||
if (_message_buffer.data == nullptr) {
|
||||
ret = PX4_ERROR;
|
||||
_message_buffer.size = 0;
|
||||
|
||||
@@ -1718,7 +1718,7 @@ Mavlink::task_main(int argc, char *argv[])
|
||||
* set error flag instead */
|
||||
bool err_flag = false;
|
||||
int myoptind = 1;
|
||||
const char *myoptarg = NULL;
|
||||
const char *myoptarg = nullptr;
|
||||
#ifdef __PX4_POSIX
|
||||
char *eptr;
|
||||
int temp_int_arg;
|
||||
@@ -1727,7 +1727,7 @@ Mavlink::task_main(int argc, char *argv[])
|
||||
while ((ch = px4_getopt(argc, argv, "b:r:d:u:o:m:t:fpvwx", &myoptind, &myoptarg)) != EOF) {
|
||||
switch (ch) {
|
||||
case 'b':
|
||||
_baudrate = strtoul(myoptarg, NULL, 10);
|
||||
_baudrate = strtoul(myoptarg, nullptr, 10);
|
||||
|
||||
if (_baudrate < 9600 || _baudrate > 3000000) {
|
||||
warnx("invalid baud rate '%s'", myoptarg);
|
||||
@@ -1737,7 +1737,7 @@ Mavlink::task_main(int argc, char *argv[])
|
||||
break;
|
||||
|
||||
case 'r':
|
||||
_datarate = strtoul(myoptarg, NULL, 10);
|
||||
_datarate = strtoul(myoptarg, nullptr, 10);
|
||||
|
||||
if (_datarate < 10 || _datarate > MAX_DATA_RATE) {
|
||||
warnx("invalid data rate '%s'", myoptarg);
|
||||
@@ -1905,7 +1905,7 @@ Mavlink::task_main(int argc, char *argv[])
|
||||
}
|
||||
|
||||
/* initialize send mutex */
|
||||
pthread_mutex_init(&_send_mutex, NULL);
|
||||
pthread_mutex_init(&_send_mutex, nullptr);
|
||||
|
||||
/* if we are passing on mavlink messages, we need to prepare a buffer for this instance */
|
||||
if (_forwarding_on || _ftp_on) {
|
||||
@@ -1919,7 +1919,7 @@ Mavlink::task_main(int argc, char *argv[])
|
||||
}
|
||||
|
||||
/* initialize message buffer mutex */
|
||||
pthread_mutex_init(&_message_buffer_mutex, NULL);
|
||||
pthread_mutex_init(&_message_buffer_mutex, nullptr);
|
||||
}
|
||||
|
||||
/* Initialize system properties */
|
||||
@@ -2366,7 +2366,7 @@ Mavlink::task_main(int argc, char *argv[])
|
||||
}
|
||||
|
||||
/* first wait for threads to complete before tearing down anything */
|
||||
pthread_join(_receive_thread, NULL);
|
||||
pthread_join(_receive_thread, nullptr);
|
||||
|
||||
delete _subscribe_to_stream;
|
||||
_subscribe_to_stream = nullptr;
|
||||
|
||||
@@ -74,7 +74,7 @@ MavlinkFtpTest::~MavlinkFtpTest()
|
||||
void MavlinkFtpTest::_init(void)
|
||||
{
|
||||
_expected_seq_number = 0;
|
||||
_ftp_server = new MavlinkFTP(NULL);
|
||||
_ftp_server = new MavlinkFTP(nullptr);
|
||||
_ftp_server->set_unittest_worker(MavlinkFtpTest::receive_message_handler_generic, this);
|
||||
|
||||
_cleanup_microsd();
|
||||
|
||||
Reference in New Issue
Block a user