From ebf093d8fd88dff7f0cf0ee4b9dd557bd5e47bba Mon Sep 17 00:00:00 2001 From: Martin Winkler Date: Thu, 16 Dec 2021 16:58:07 +0100 Subject: [PATCH] Remove multiple definitions of const --- src/stubser/cfile_if.h | 2 +- src/stubser/stubser.c | 16 ++++++++-------- src/stubser/stubser_loc.h | 1 - 3 files changed, 9 insertions(+), 10 deletions(-) diff --git a/src/stubser/cfile_if.h b/src/stubser/cfile_if.h index 676a565..6a34fe1 100644 --- a/src/stubser/cfile_if.h +++ b/src/stubser/cfile_if.h @@ -22,7 +22,7 @@ var |= type; \ } while(0) -/*! @brief Type of function definition for bit field usage */ +/*! @brief Type of variable definition for bit field usage */ typedef enum _CFILE_VARIABLE_TYPE_T { CVARIABLE_TYPE_UNDEF = 0, /*!< @brief undefined */ diff --git a/src/stubser/stubser.c b/src/stubser/stubser.c index 5a52076..c443f40 100644 --- a/src/stubser/stubser.c +++ b/src/stubser/stubser.c @@ -136,7 +136,7 @@ STATIC void createVariableSpecificCheck(FILE *aFile, cfile_variable_t *aVariable { char *tempChar = NULL; - if (NULL != strstr(aVariable->dataType, STUB_DATATYPE_CONST)) + if (NULL != strstr(aVariable->dataType, CPARS_ELEMENT_CONST)) { return; } @@ -215,7 +215,7 @@ STATIC void createParameterSpecificCheck(FILE *aFile, cfunction_t *aFunction, cf fprintf(aFile, ", strlen("STUBINIT_PARAM_PARAMETER_S1"));"NEWLINES, aParameterIndex); fprintf(aFile, "\t}" NEWLINES); // injection only for non constant and non NULL parameter - if (NULL == strstr(aParameter->dataType, STUB_DATATYPE_CONST)) + if (NULL == strstr(aParameter->dataType, CPARS_ELEMENT_CONST)) { fprintf(aFile, "\telse if (NULL != " STUBINIT_PARAM_PARAMETER_S1 ")" NEWLINES "\t{" NEWLINES, aParameterIndex); fprintf(aFile, "\t\tmemcpy(" STUBINIT_PARAM_PARAMETER_S1 ", "STUBPARAMETER_STRUCT_S1"["STUBINSTANCE_S1"]."STUBPARAMETER_PARAM_S1", " // @@ -244,7 +244,7 @@ STATIC void createParameterSpecificCheck(FILE *aFile, cfunction_t *aFunction, cf fprintf(aFile, ");" NEWLINES); fprintf(aFile, "\t}" NEWLINES); // injection only for non constant and non NULL parameter - if (NULL == strstr(aParameter->dataType, STUB_DATATYPE_CONST)) + if (NULL == strstr(aParameter->dataType, CPARS_ELEMENT_CONST)) { fprintf(aFile, "\telse if (NULL != " STUBINIT_PARAM_PARAMETER_S1 ")" NEWLINES "\t{" NEWLINES, aParameterIndex); fprintf(aFile, "\t\tmemcpy(" STUBINIT_PARAM_PARAMETER_S1 ", "STUBPARAMETER_STRUCT_S1"["STUBINSTANCE_S1"]."STUBPARAMETER_PARAM_S1", " // @@ -293,7 +293,7 @@ STATIC int8_t createStubExpected(char *aNoSuffix, FILE *aFile, FILE *aHeader, cf work = aList->head; while (work) { - if (!CVARIABLE_CHECK_TYPE(work->type, CVARIABLE_TYPE_REGULAR) || NULL != strstr(work->dataType, STUB_DATATYPE_CONST)) + if (!CVARIABLE_CHECK_TYPE(work->type, CVARIABLE_TYPE_REGULAR) || NULL != strstr(work->dataType, CPARS_ELEMENT_CONST)) { work = work->next; continue; @@ -491,21 +491,21 @@ STATIC int8_t createStubFunctionBlock(FILE *aFile, FILE *aHeader, cfunction_t *a (void) xmallocStrlcpy(&dataTypeTemp, parameter->dataType, strlen(parameter->dataType)); // remove trailing "const" for pointer and leading "const" for regular variables from expected structure - while (NULL != (constPos = strstr(dataTypeTemp + constOffset, STUB_DATATYPE_CONST))) + while (NULL != (constPos = strstr(dataTypeTemp + constOffset, CPARS_ELEMENT_CONST))) { if (NULL == parameter->array && NULL == strstr(parameter->dataType, "*")) { // remove all const - memset(constPos, ' ', strlen(STUB_DATATYPE_CONST)); + memset(constPos, ' ', strlen(CPARS_ELEMENT_CONST)); } else if (constPos == dataTypeTemp) { - constOffset = strlen(STUB_DATATYPE_CONST); + constOffset = strlen(CPARS_ELEMENT_CONST); } else { // remove trailing const - memset(constPos, ' ', strlen(STUB_DATATYPE_CONST)); + memset(constPos, ' ', strlen(CPARS_ELEMENT_CONST)); } } xStringTrim(dataTypeTemp, strlen(dataTypeTemp)); diff --git a/src/stubser/stubser_loc.h b/src/stubser/stubser_loc.h index 36a5fbe..9b8cae5 100644 --- a/src/stubser/stubser_loc.h +++ b/src/stubser/stubser_loc.h @@ -71,6 +71,5 @@ #define STUB_CONSOLE_CREATE_ERROR_S2 "...stub creation failed\n"STUB_CONSOLE_FAIL " %s creation failed (%d)\n" #define STUB_CONSOLE_CREATE_OK_S1 "...stub created > %s\n" -#define STUB_DATATYPE_CONST "const" #define STUB_REGEX_STD_DATATYPE "(^|[^_[:alnum:]])([ui]+nt[0-9]{1,2}_t|char|uchar|word[12346]{2}|int[12346]{0,2}|byte)([^_[:alnum:]]|$)" #endif /* STUBSER_STUBSER_LOC_H_ */