From 92bed0c699441e559e2e239935d15e727392f59c Mon Sep 17 00:00:00 2001 From: rusefillc Date: Thu, 27 Oct 2022 22:17:50 -0400 Subject: [PATCH] less horrible constant name --- firmware/controllers/engine_controller.cpp | 8 ++++---- firmware/controllers/settings.cpp | 2 +- firmware/hw_layer/mmc_card.cpp | 2 +- firmware/util/cli_registry.cpp | 6 +++--- firmware/util/efilib.cpp | 10 +++++----- firmware/util/efilib.h | 2 +- 6 files changed, 15 insertions(+), 15 deletions(-) diff --git a/firmware/controllers/engine_controller.cpp b/firmware/controllers/engine_controller.cpp index 646c76938c..06ffb4204b 100644 --- a/firmware/controllers/engine_controller.cpp +++ b/firmware/controllers/engine_controller.cpp @@ -274,7 +274,7 @@ static void getByte(int offset) { static void setBit(const char *offsetStr, const char *bitStr, const char *valueStr) { int offset = atoi(offsetStr); - if (absI(offset) == absI(ERROR_CODE)) { + if (absI(offset) == absI(ATOI_ERROR_CODE)) { efiPrintf("invalid offset [%s]", offsetStr); return; } @@ -282,12 +282,12 @@ static void setBit(const char *offsetStr, const char *bitStr, const char *valueS return; } int bit = atoi(bitStr); - if (absI(bit) == absI(ERROR_CODE)) { + if (absI(bit) == absI(ATOI_ERROR_CODE)) { efiPrintf("invalid bit [%s]", bitStr); return; } int value = atoi(valueStr); - if (absI(value) == absI(ERROR_CODE)) { + if (absI(value) == absI(ATOI_ERROR_CODE)) { efiPrintf("invalid value [%s]", valueStr); return; } @@ -362,7 +362,7 @@ static void getFloat(int offset) { static void setFloat(const char *offsetStr, const char *valueStr) { int offset = atoi(offsetStr); - if (absI(offset) == absI(ERROR_CODE)) { + if (absI(offset) == absI(ATOI_ERROR_CODE)) { efiPrintf("invalid offset [%s]", offsetStr); return; } diff --git a/firmware/controllers/settings.cpp b/firmware/controllers/settings.cpp index 7cbc8786bb..91966cb4db 100644 --- a/firmware/controllers/settings.cpp +++ b/firmware/controllers/settings.cpp @@ -545,7 +545,7 @@ static void setTriggerSimulatorMode(const char *indexStr, const char *modeCode) return; } int mode = atoi(modeCode); - if (absI(mode) == ERROR_CODE) { + if (absI(mode) == ATOI_ERROR_CODE) { return; } engineConfiguration->triggerSimulatorPinModes[index] = (pin_output_mode_e) mode; diff --git a/firmware/hw_layer/mmc_card.cpp b/firmware/hw_layer/mmc_card.cpp index e87e1cca8f..1ebd5ac1a1 100644 --- a/firmware/hw_layer/mmc_card.cpp +++ b/firmware/hw_layer/mmc_card.cpp @@ -148,7 +148,7 @@ static void incLogFileName() { if (result < 5) { data[result] = 0; logFileIndex = maxI(MIN_FILE_INDEX, atoi(data)); - if (absI(logFileIndex) == ERROR_CODE) { + if (absI(logFileIndex) == ATOI_ERROR_CODE) { logFileIndex = MIN_FILE_INDEX; } else { logFileIndex++; // next file would use next file name diff --git a/firmware/util/cli_registry.cpp b/firmware/util/cli_registry.cpp index 2eaebd2c25..1f2e7e6a30 100644 --- a/firmware/util/cli_registry.cpp +++ b/firmware/util/cli_registry.cpp @@ -338,7 +338,7 @@ int handleActionWithParameter(TokenCallback *current, char *argv[], int argc) { int value[2]; for (int i = 0; i < 2; i++) { value[i] = atoi(argv[i]); - if (absI(value[i]) == ERROR_CODE) { + if (absI(value[i]) == ATOI_ERROR_CODE) { #if EFI_PROD_CODE || EFI_SIMULATOR efiPrintf("not an integer [%s]", argv[0]); #endif @@ -420,7 +420,7 @@ int handleActionWithParameter(TokenCallback *current, char *argv[], int argc) { case INT_FLOAT_PARAMETER: { int value1 = atoi(argv[0]); - if (absI(value1) == ERROR_CODE) { + if (absI(value1) == ATOI_ERROR_CODE) { #if EFI_PROD_CODE || EFI_SIMULATOR efiPrintf("not an integer [%s]", argv[0]); #endif @@ -439,7 +439,7 @@ int handleActionWithParameter(TokenCallback *current, char *argv[], int argc) { case ONE_PARAMETER: { int value = atoi(argv[0]); - if (absI(value) == ERROR_CODE) { + if (absI(value) == ATOI_ERROR_CODE) { #if EFI_PROD_CODE || EFI_SIMULATOR efiPrintf("not an integer [%s]", argv[0]); #endif diff --git a/firmware/util/efilib.cpp b/firmware/util/efilib.cpp index 42c81d2550..9a49334f08 100644 --- a/firmware/util/efilib.cpp +++ b/firmware/util/efilib.cpp @@ -85,7 +85,7 @@ int atoi(const char *string) { // todo: use stdlib '#include ' int len = strlen(string); if (len == 0) { - return -ERROR_CODE; + return -ATOI_ERROR_CODE; } if (string[0] == '-') { return -atoi(string + 1); @@ -95,7 +95,7 @@ int atoi(const char *string) { for (int i = 0; i < len; i++) { char ch = string[i]; if (ch < '0' || ch > '9') { - return ERROR_CODE; + return ATOI_ERROR_CODE; } int c = ch - '0'; result = result * 10 + c; @@ -214,19 +214,19 @@ float atoff(const char *param) { if (dotIndex == -1) { // just an integer int result = atoi(string); - if (absI(result) == ERROR_CODE) + if (absI(result) == ATOI_ERROR_CODE) return (float) NAN; return (float) result; } // todo: this needs to be fixed string[dotIndex] = 0; int integerPart = atoi(string); - if (absI(integerPart) == ERROR_CODE) + if (absI(integerPart) == ATOI_ERROR_CODE) return (float) NAN; string += (dotIndex + 1); int decimalLen = strlen(string); int decimal = atoi(string); - if (absI(decimal) == ERROR_CODE) + if (absI(decimal) == ATOI_ERROR_CODE) return (float) NAN; float divider = 1.0; // todo: reuse 'pow10' function which we have anyway diff --git a/firmware/util/efilib.h b/firmware/util/efilib.h index 2e551534cf..a6b96a6805 100644 --- a/firmware/util/efilib.h +++ b/firmware/util/efilib.h @@ -40,7 +40,7 @@ static inline uint32_t SWAP_UINT32(uint32_t x) // number of microseconds in one period of given frequency (per second) #define frequency2periodUs(freq) ((1000000.0f) / (freq)) -#define ERROR_CODE 311223344 +#define ATOI_ERROR_CODE 311223344 #define Q(x) #x #define QUOTE(x) Q(x)