fancy C++ s/NULL/nullptr/

This commit is contained in:
rusefi 2019-10-08 01:26:35 -04:00
parent 7e1e7629ee
commit 15ae9b1580
19 changed files with 33 additions and 43 deletions

View File

@ -110,7 +110,7 @@ public:
private: private:
Pid auxPid; Pid auxPid;
int index = 0; int index = 0;
ValueProvider3D *table = NULL; ValueProvider3D *table = nullptr;
}; };
static AuxPidController instances[AUX_PID_COUNT]; static AuxPidController instances[AUX_PID_COUNT];

View File

@ -325,7 +325,7 @@ static void fillWithSpaces(void) {
void updateHD44780lcd(void) { void updateHD44780lcd(void) {
MenuItem *p = tree.topVisible; MenuItem *p = tree.topVisible;
int screenY = 0; int screenY = 0;
for (; screenY < tree.linesCount && p != NULL; screenY++) { for (; screenY < tree.linesCount && p != nullptr; screenY++) {
lcd_HD44780_set_position(screenY, 0); lcd_HD44780_set_position(screenY, 0);
char firstChar; char firstChar;
if (p == tree.current) { if (p == tree.current) {

View File

@ -38,7 +38,7 @@ EXTERN_ENGINE
tps_tps_Map3D_t tpsTpsMap("tpsTps"); tps_tps_Map3D_t tpsTpsMap("tpsTps");
static Logging *logger = NULL; static Logging *logger = nullptr;
WallFuel::WallFuel() { WallFuel::WallFuel() {
resetWF(); resetWF();

View File

@ -45,7 +45,7 @@ public:
uint32_t startOfDwell; uint32_t startOfDwell;
event_trigger_position_s dwellPosition; event_trigger_position_s dwellPosition;
event_trigger_position_s sparkPosition; event_trigger_position_s sparkPosition;
IgnitionEvent *next = NULL; IgnitionEvent *next = nullptr;
/** /**
* @see globalSparkIdCoutner * @see globalSparkIdCoutner
*/ */
@ -54,7 +54,7 @@ public:
* [0, specs.cylindersCount) * [0, specs.cylindersCount)
*/ */
int cylinderIndex = 0; int cylinderIndex = 0;
char *name = NULL; char *name = nullptr;
#if EFI_UNIT_TEST #if EFI_UNIT_TEST
Engine *engine; Engine *engine;
#endif #endif

View File

@ -11,9 +11,6 @@
MenuTree::MenuTree(MenuItem *root) { MenuTree::MenuTree(MenuItem *root) {
this->root = root; this->root = root;
current = NULL;
linesCount = 0;
topVisible = NULL;
} }
void MenuTree::init(MenuItem *first, int linesCount) { void MenuTree::init(MenuItem *first, int linesCount) {
@ -74,10 +71,10 @@ void MenuItem::baseConstructor(MenuItem * parent, lcd_line_e lcdLine, const char
this->text = text; this->text = text;
this->callback = callback; this->callback = callback;
firstChild = NULL; firstChild = nullptr;
lastChild = NULL; lastChild = nullptr;
topOfTheList = NULL; topOfTheList = nullptr;
next = NULL; next = nullptr;
index = 0; index = 0;
// root element has NULL parent // root element has NULL parent

View File

@ -69,9 +69,9 @@ public:
void init(MenuItem *first, int linesCount); void init(MenuItem *first, int linesCount);
MenuItem *root; MenuItem *root;
int linesCount; int linesCount = 0;
MenuItem *current; MenuItem *current = nullptr;
MenuItem *topVisible; MenuItem *topVisible = nullptr;
}; };

View File

@ -33,8 +33,6 @@ void SingleWave::setState(int switchIndex, pin_state_t state) {
} }
MultiWave::MultiWave() { MultiWave::MultiWave() {
channels = NULL;
switchTimes = NULL;
reset(); reset();
} }

View File

@ -77,13 +77,13 @@ public:
* Number of signal channels * Number of signal channels
*/ */
int waveCount; int waveCount;
SingleWave *channels; SingleWave *channels = nullptr;
//private: //private:
/** /**
* values in the (0..1] range which refer to points within the period at at which pin state should be changed * values in the (0..1] range which refer to points within the period at at which pin state should be changed
* So, in the simplest case we turn pin off at 0.3 and turn it on at 1 - that would give us a 70% duty cycle PWM * So, in the simplest case we turn pin off at 0.3 and turn it on at 1 - that would give us a 70% duty cycle PWM
*/ */
float *switchTimes; float *switchTimes = nullptr;
}; };
#endif /* EFI_WAVE_H_ */ #endif /* EFI_WAVE_H_ */

View File

@ -31,7 +31,7 @@ static fsio8_Map3D_u8t * fsio8t_tables[] = {NULL, NULL, &fsioTable2, &fsioTable3
EXTERN_ENGINE; EXTERN_ENGINE;
LENameOrdinalPair * LE_FIRST = NULL; LENameOrdinalPair * LE_FIRST = nullptr;
/** /**
* the main point of these static fields is that their constructor would register * the main point of these static fields is that their constructor would register
@ -72,7 +72,7 @@ LEElement::LEElement() {
void LEElement::clear() { void LEElement::clear() {
action = LE_UNDEFINED; action = LE_UNDEFINED;
next = NULL; next = nullptr;
fValue = NAN; fValue = NAN;
iValue = 0; iValue = 0;
} }
@ -91,7 +91,7 @@ LECalculator::LECalculator() {
} }
void LECalculator::reset() { void LECalculator::reset() {
first = NULL; first = nullptr;
stack.reset(); stack.reset();
currentCalculationLogPosition = 0; currentCalculationLogPosition = 0;
memset(calcLogAction, 0, sizeof(calcLogAction)); memset(calcLogAction, 0, sizeof(calcLogAction));
@ -405,8 +405,8 @@ static char parsingBuffer[64];
LEElement *LEElementPool::parseExpression(const char * line) { LEElement *LEElementPool::parseExpression(const char * line) {
LEElement *first = NULL; LEElement *first = nullptr;
LEElement *last = NULL; LEElement *last = nullptr;
while (true) { while (true) {
line = getNextToken(line, parsingBuffer, sizeof(parsingBuffer)); line = getNextToken(line, parsingBuffer, sizeof(parsingBuffer));

View File

@ -255,7 +255,7 @@ void OutputPin::unregisterOutput(brain_pin_e oldPin, brain_pin_e newPin) {
scheduleMsg(logger, "unregistering %s", hwPortname(oldPin)); scheduleMsg(logger, "unregistering %s", hwPortname(oldPin));
#if EFI_GPIO_HARDWARE #if EFI_GPIO_HARDWARE
brain_pin_markUnused(oldPin); brain_pin_markUnused(oldPin);
port = NULL; port = nullptr;
#endif /* EFI_GPIO_HARDWARE */ #endif /* EFI_GPIO_HARDWARE */
} }
} }

View File

@ -64,7 +64,7 @@ void PID_AutoTune::reset() {
memset(lastPeaks, 0, sizeof(lastPeaks)); memset(lastPeaks, 0, sizeof(lastPeaks));
memset(lastInputs, 0, sizeof(lastInputs)); memset(lastInputs, 0, sizeof(lastInputs));
logger = NULL; logger = nullptr;
input = output = 0; input = output = 0;
SetLookbackSec(10); SetLookbackSec(10);

View File

@ -152,7 +152,7 @@ int EventQueue::executeAll(efitime_t now) {
lastInExecutionList->next = current; lastInExecutionList->next = current;
lastInExecutionList = current; lastInExecutionList = current;
} }
current->next = NULL; current->next = nullptr;
} else { } else {
/** /**
* The list is sorted. Once we find one action in the future, all the remaining ones * The list is sorted. Once we find one action in the future, all the remaining ones

View File

@ -27,7 +27,7 @@
EXTERN_ENGINE EXTERN_ENGINE
; ;
static Logging *logger = NULL; static Logging *logger = nullptr;
/** /**
* http://en.wikipedia.org/wiki/Voltage_divider * http://en.wikipedia.org/wiki/Voltage_divider

View File

@ -58,7 +58,7 @@ void TriggerState::setShaftSynchronized(bool value) {
} }
void TriggerState::resetTriggerState() { void TriggerState::resetTriggerState() {
triggerCycleCallback = NULL; triggerCycleCallback = nullptr;
setShaftSynchronized(false); setShaftSynchronized(false);
toothed_previous_time = 0; toothed_previous_time = 0;

View File

@ -143,9 +143,9 @@ static void initWave(const char *name, int index) {
#endif #endif
WaveReader::WaveReader() { WaveReader::WaveReader() {
hw = NULL; hw = nullptr;
last_wave_high_widthUs = 0; last_wave_high_widthUs = 0;
name = NULL; name = nullptr;
fallEventCounter = riseEventCounter = 0; fallEventCounter = riseEventCounter = 0;
currentRevolutionCounter = 0; currentRevolutionCounter = 0;
prevTotalOnTimeUs = 0; prevTotalOnTimeUs = 0;

View File

@ -340,7 +340,7 @@ void initSpiModule(SPIDriver *driver, brain_pin_e sck, brain_pin_e miso,
} }
void initSpiCs(SPIConfig *spiConfig, brain_pin_e csPin) { void initSpiCs(SPIConfig *spiConfig, brain_pin_e csPin) {
spiConfig->end_cb = NULL; spiConfig->end_cb = nullptr;
ioportid_t port = getHwPort("spi", csPin); ioportid_t port = getHwPort("spi", csPin);
ioportmask_t pin = getHwPin("spi", csPin); ioportmask_t pin = getHwPin("spi", csPin);
spiConfig->ssport = port; spiConfig->ssport = port;

View File

@ -296,11 +296,6 @@ void Logging::appendPrintf(const char *fmt, ...) {
#endif /* ! EFI_UNIT_TEST */ #endif /* ! EFI_UNIT_TEST */
Logging::Logging() { Logging::Logging() {
name = NULL;
buffer = NULL;
linePointer = NULL;
bufferSize = 0;
isInitialized = false;
} }
Logging::Logging(char const *name, char *buffer, int bufferSize) : Logging(){ Logging::Logging(char const *name, char *buffer, int bufferSize) : Logging(){

View File

@ -25,21 +25,21 @@ public:
void append(const char *text); void append(const char *text);
void appendFast(const char *text); void appendFast(const char *text);
void appendPrintf(const char *fmt, ...); void appendPrintf(const char *fmt, ...);
const char *name; const char *name = nullptr;
char SMALL_BUFFER[40]; char SMALL_BUFFER[40];
/** /**
* Zero-terminated buffer of pending debug message * Zero-terminated buffer of pending debug message
* *
* Unless a larger external buffer is specified, this is just a pointer to DEFAULT_BUFFER * Unless a larger external buffer is specified, this is just a pointer to DEFAULT_BUFFER
*/ */
char *buffer; char *buffer = nullptr;
/** /**
* This pointer is always pointing at the position within the buffer into which next * This pointer is always pointing at the position within the buffer into which next
* write operation would append additional data * write operation would append additional data
*/ */
char *linePointer; char *linePointer = nullptr;
int bufferSize; int bufferSize = 0;
volatile bool isInitialized; volatile bool isInitialized = false;
}; };
class LoggingWithStorage : public Logging { class LoggingWithStorage : public Logging {

View File

@ -128,7 +128,7 @@ void EngineTestHelper::fireTriggerEvents2(int count, float durationMs) {
void EngineTestHelper::clearQueue() { void EngineTestHelper::clearQueue() {
engine.executor.executeAll(99999999); // this is needed to clear 'isScheduled' flag engine.executor.executeAll(99999999); // this is needed to clear 'isScheduled' flag
ASSERT_EQ( 0, engine.executor.size()) << "Failed to clearQueue"; ASSERT_EQ( 0, engine.executor.size()) << "Failed to clearQueue";
engine.iHead = NULL; // let's drop whatever was scheduled just to start from a clean state engine.ignitionEventsHead = nullptr; // let's drop whatever was scheduled just to start from a clean state
} }
int EngineTestHelper::executeActions() { int EngineTestHelper::executeActions() {