From 8a88c90f3b50f63c6412d033fc50a11b3a02ea73 Mon Sep 17 00:00:00 2001 From: rusefi Date: Wed, 22 Jan 2020 00:45:09 -0500 Subject: [PATCH] code style: trying to get used to this syntax --- firmware/controllers/algo/accel_enrichment.cpp | 3 ++- firmware/controllers/algo/nmea.c | 3 ++- firmware/controllers/core/fsio_impl.cpp | 2 +- firmware/controllers/gauges/lcd_menu_tree.cpp | 4 ++-- firmware/hw_layer/drivers/gpio/core.c | 3 ++- firmware/hw_layer/drivers/gpio/mc33972.c | 3 ++- 6 files changed, 11 insertions(+), 7 deletions(-) diff --git a/firmware/controllers/algo/accel_enrichment.cpp b/firmware/controllers/algo/accel_enrichment.cpp index 1588dbc707..157f5c202c 100644 --- a/firmware/controllers/algo/accel_enrichment.cpp +++ b/firmware/controllers/algo/accel_enrichment.cpp @@ -328,8 +328,9 @@ AccelEnrichment::AccelEnrichment() { #if ! EFI_UNIT_TEST static void accelInfo() { - if (logger == NULL) + if (!logger) { return; + } // scheduleMsg(logger, "EL accel length=%d", mapInstance.cb.getSize()); scheduleMsg(logger, "EL accel th=%.2f/mult=%.2f", engineConfiguration->engineLoadAccelEnrichmentThreshold, engineConfiguration->engineLoadAccelEnrichmentMultiplier); scheduleMsg(logger, "EL decel th=%.2f/mult=%.2f", engineConfiguration->engineLoadDecelEnleanmentThreshold, engineConfiguration->engineLoadDecelEnleanmentMultiplier); diff --git a/firmware/controllers/algo/nmea.c b/firmware/controllers/algo/nmea.c index d78b358de8..bb3fc9f02d 100644 --- a/firmware/controllers/algo/nmea.c +++ b/firmware/controllers/algo/nmea.c @@ -284,8 +284,9 @@ int nmea_valid_checksum(const char *message) { char p; int sum = 0; char *starPtr = strrchr(message, '*'); - if (starPtr == NULL) + if (!starPtr) { return NMEA_CHECKSUM_ERR; + } char *int_message = starPtr + 1; long checksum = hex2int(int_message, 2); diff --git a/firmware/controllers/core/fsio_impl.cpp b/firmware/controllers/core/fsio_impl.cpp index 16a2ba741a..94098df728 100644 --- a/firmware/controllers/core/fsio_impl.cpp +++ b/firmware/controllers/core/fsio_impl.cpp @@ -386,7 +386,7 @@ static void setPinState(const char * msg, OutputPin *pin, LEElement *element DEC } #endif /* EFI_PROD_CODE */ - if (element == NULL) { + if (!element) { warning(CUSTOM_FSIO_INVALID_EXPRESSION, "invalid expression for %s", msg); } else { int value = (int)calc.getValue2(pin->getLogicValue(), element PASS_ENGINE_PARAMETER_SUFFIX); diff --git a/firmware/controllers/gauges/lcd_menu_tree.cpp b/firmware/controllers/gauges/lcd_menu_tree.cpp index 97e0c358d7..2f6c10ace1 100644 --- a/firmware/controllers/gauges/lcd_menu_tree.cpp +++ b/firmware/controllers/gauges/lcd_menu_tree.cpp @@ -35,7 +35,7 @@ void MenuTree::back(void) { } void MenuTree::nextItem(void) { - if (current->next == NULL) { + if (!current->next) { current = topVisible = current->topOfTheList; return; } @@ -79,7 +79,7 @@ void MenuItem::baseConstructor(MenuItem * parent, lcd_line_e lcdLine, const char // root element has NULL parent if (parent != NULL) { - if (parent->firstChild == NULL) { + if (!parent->firstChild) { topOfTheList = this; parent->firstChild = this; } diff --git a/firmware/hw_layer/drivers/gpio/core.c b/firmware/hw_layer/drivers/gpio/core.c index 355712d43a..2dbbcefe8e 100644 --- a/firmware/hw_layer/drivers/gpio/core.c +++ b/firmware/hw_layer/drivers/gpio/core.c @@ -153,8 +153,9 @@ int gpiochip_register(const char *name, struct gpiochip_ops *ops, size_t size, v } /* no free chips left */ - if (chip == NULL) + if (!chip) { return -1; + } /* register chip */ chip->name = name; diff --git a/firmware/hw_layer/drivers/gpio/mc33972.c b/firmware/hw_layer/drivers/gpio/mc33972.c index a1ba74f41d..5f53f69454 100644 --- a/firmware/hw_layer/drivers/gpio/mc33972.c +++ b/firmware/hw_layer/drivers/gpio/mc33972.c @@ -342,8 +342,9 @@ int mc33972_add(unsigned int index, const struct mc33972_config *cfg) /* check for valid cs. * DOTO: remove this check? CS can be driven by SPI */ - if (cfg->spi_config.ssport == NULL) + if (!cfg->spi_config.ssport) { return -1; + } chip = &chips[index];