Use C++ language supported 'nullptr' (#13944)

This commit is contained in:
Scott Lahteine
2019-05-09 11:45:55 -05:00
committed by GitHub
parent e53d7e5517
commit ad4ffa1d2f
70 changed files with 670 additions and 668 deletions

View File

@ -51,7 +51,7 @@ void Timer::init(uint32_t sig_id, uint32_t sim_freq, callback_fn* fn) {
sa.sa_flags = SA_SIGINFO;
sa.sa_sigaction = Timer::handler;
sigemptyset(&sa.sa_mask);
if (sigaction(SIGRTMIN, &sa, NULL) == -1) {
if (sigaction(SIGRTMIN, &sa, nullptr) == -1) {
return; // todo: handle error
}
@ -74,7 +74,7 @@ void Timer::start(uint32_t frequency) {
}
void Timer::enable() {
if (sigprocmask(SIG_UNBLOCK, &mask, NULL) == -1) {
if (sigprocmask(SIG_UNBLOCK, &mask, nullptr) == -1) {
return; // todo: handle error
}
active = true;
@ -82,7 +82,7 @@ void Timer::enable() {
}
void Timer::disable() {
if (sigprocmask(SIG_SETMASK, &mask, NULL) == -1) {
if (sigprocmask(SIG_SETMASK, &mask, nullptr) == -1) {
return; // todo: handle error
}
active = false;
@ -102,7 +102,7 @@ void Timer::setCompare(uint32_t compare) {
its.it_interval.tv_sec = its.it_value.tv_sec;
its.it_interval.tv_nsec = its.it_value.tv_nsec;
if (timer_settime(timerid, 0, &its, NULL) == -1) {
if (timer_settime(timerid, 0, &its, nullptr) == -1) {
printf("timer(%ld) failed, compare: %d(%ld)\n", getID(), compare, its.it_value.tv_nsec);
return; // todo: handle error
}

View File

@ -35,7 +35,7 @@ char filename[] = "eeprom.dat";
bool PersistentStore::access_start() {
const char eeprom_erase_value = 0xFF;
FILE * eeprom_file = fopen(filename, "rb");
if (eeprom_file == NULL) return false;
if (eeprom_file == nullptr) return false;
fseek(eeprom_file, 0L, SEEK_END);
std::size_t file_size = ftell(eeprom_file);
@ -54,7 +54,7 @@ bool PersistentStore::access_start() {
bool PersistentStore::access_finish() {
FILE * eeprom_file = fopen(filename, "wb");
if (eeprom_file == NULL) return false;
if (eeprom_file == nullptr) return false;
fwrite(buffer, sizeof(uint8_t), sizeof(buffer), eeprom_file);
fclose(eeprom_file);
return true;