NULL pointer check for memcpy
stub structure default initialization for pointer check
This commit is contained in:
@@ -183,10 +183,10 @@ STATIC void createParameterSpecificCheck(FILE *aFile, cfunction_t *aFunction, cf
|
|||||||
aFunction->name, aParameterIndex);
|
aFunction->name, aParameterIndex);
|
||||||
fprintf(aFile, ", strlen("STUBINIT_PARAM_PARAMETER_S1"));"NEWLINES, aParameterIndex);
|
fprintf(aFile, ", strlen("STUBINIT_PARAM_PARAMETER_S1"));"NEWLINES, aParameterIndex);
|
||||||
fprintf(aFile, "\t}" NEWLINES);
|
fprintf(aFile, "\t}" NEWLINES);
|
||||||
// injection only for non constant parameter
|
// injection only for non constant and non NULL parameter
|
||||||
if (NULL == strstr(aParameter->dataType, "const"))
|
if (NULL == strstr(aParameter->dataType, "const"))
|
||||||
{
|
{
|
||||||
fprintf(aFile, "\telse" NEWLINES "\t{" NEWLINES);
|
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", " //
|
fprintf(aFile, "\t\tmemcpy(" STUBINIT_PARAM_PARAMETER_S1 ", "STUBPARAMETER_STRUCT_S1"["STUBINSTANCE_S1"]."STUBPARAMETER_PARAM_S1", " //
|
||||||
STUBPARAMETER_STRUCT_S1"["STUBINSTANCE_S1"]."STUBPARAMETER_PARAM_S1"_size",//
|
STUBPARAMETER_STRUCT_S1"["STUBINSTANCE_S1"]."STUBPARAMETER_PARAM_S1"_size",//
|
||||||
aParameterIndex, aFunction->name, aFunction->name, aParameterIndex, aFunction->name, aFunction->name, aParameterIndex);
|
aParameterIndex, aFunction->name, aFunction->name, aParameterIndex, aFunction->name, aFunction->name, aParameterIndex);
|
||||||
@@ -208,10 +208,10 @@ STATIC void createParameterSpecificCheck(FILE *aFile, cfunction_t *aFunction, cf
|
|||||||
aFunction->name, aParameterIndex);
|
aFunction->name, aParameterIndex);
|
||||||
fprintf(aFile, ");" NEWLINES);
|
fprintf(aFile, ");" NEWLINES);
|
||||||
fprintf(aFile, "\t}" NEWLINES);
|
fprintf(aFile, "\t}" NEWLINES);
|
||||||
// injection only for non constant parameter
|
// injection only for non constant and non NULL parameter
|
||||||
if (NULL == strstr(aParameter->dataType, "const"))
|
if (NULL == strstr(aParameter->dataType, "const"))
|
||||||
{
|
{
|
||||||
fprintf(aFile, "\telse" NEWLINES "\t{" NEWLINES);
|
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", " //
|
fprintf(aFile, "\t\tmemcpy(" STUBINIT_PARAM_PARAMETER_S1 ", "STUBPARAMETER_STRUCT_S1"["STUBINSTANCE_S1"]."STUBPARAMETER_PARAM_S1", " //
|
||||||
STUBPARAMETER_STRUCT_S1"["STUBINSTANCE_S1"]."STUBPARAMETER_PARAM_S1"_size",//
|
STUBPARAMETER_STRUCT_S1"["STUBINSTANCE_S1"]."STUBPARAMETER_PARAM_S1"_size",//
|
||||||
aParameterIndex, aFunction->name, aFunction->name, aParameterIndex, aFunction->name, aFunction->name, aParameterIndex);
|
aParameterIndex, aFunction->name, aFunction->name, aParameterIndex, aFunction->name, aFunction->name, aParameterIndex);
|
||||||
@@ -420,24 +420,25 @@ STATIC int8_t createStubFunctionBlock(FILE *aFile, FILE *aHeader, cfunction_t *a
|
|||||||
{
|
{
|
||||||
if (CPARAMETER_TYPE_FUNCPTR == parameter->type)
|
if (CPARAMETER_TYPE_FUNCPTR == parameter->type)
|
||||||
{
|
{
|
||||||
fprintf(aFile, "\t%s (*"STUBPARAMETER_PARAM_S1")%s; /*!< @brief %s */" NEWLINES, NCHECK(parameter->dataType), parameterIndex++,
|
fprintf(aFile, "\t%s (*"STUBPARAMETER_PARAM_S1")%s; /*!< @brief \"%s\" */" NEWLINES, NCHECK(parameter->dataType), parameterIndex++,
|
||||||
NCHECK(parameter->array), NCHECK(parameter->name));
|
NCHECK(parameter->array), NCHECK(parameter->name));
|
||||||
}
|
}
|
||||||
else if (parameter->array)
|
else if (parameter->array)
|
||||||
{
|
{
|
||||||
fprintf(aFile, "\t%s *"STUBPARAMETER_PARAM_S1"; /*!< @brief %s */" NEWLINES, NCHECK(parameter->dataType), parameterIndex, NCHECK(parameter->name));
|
fprintf(aFile, "\t%s *"STUBPARAMETER_PARAM_S1"; /*!< @brief \"%s\" */" NEWLINES, NCHECK(parameter->dataType), parameterIndex, NCHECK(parameter->name));
|
||||||
fprintf(aFile, "\tuint32_t "STUBPARAMETER_PARAM_S1"_size; /*!< @brief %s size to copy in case of parameter injection */" NEWLINES, parameterIndex++,
|
fprintf(aFile, "\tuint32_t "STUBPARAMETER_PARAM_S1"_size; /*!< @brief \"%s\" size to copy in case of parameter injection */" NEWLINES,
|
||||||
NCHECK(parameter->name));
|
parameterIndex++, NCHECK(parameter->name));
|
||||||
}
|
}
|
||||||
else if (NULL != strstr(parameter->dataType, "*"))
|
else if (NULL != strstr(parameter->dataType, "*"))
|
||||||
{
|
{
|
||||||
fprintf(aFile, "\t%s "STUBPARAMETER_PARAM_S1"; /*!< @brief %s */" NEWLINES, NCHECK(parameter->dataType), parameterIndex, NCHECK(parameter->name));
|
fprintf(aFile, "\t%s "STUBPARAMETER_PARAM_S1"; /*!< @brief \"%s\" */" NEWLINES, NCHECK(parameter->dataType), parameterIndex, NCHECK(parameter->name));
|
||||||
fprintf(aFile, "\tuint32_t "STUBPARAMETER_PARAM_S1"_size; /*!< @brief %s size to copy in case of parameter injection */" NEWLINES, parameterIndex++,
|
fprintf(aFile, "\tuint32_t "STUBPARAMETER_PARAM_S1"_size; /*!< @brief \"%s\" size to copy in case of parameter injection */" NEWLINES,
|
||||||
NCHECK(parameter->name));
|
parameterIndex++, NCHECK(parameter->name));
|
||||||
}
|
}
|
||||||
else if (CPARAMETER_TYPE_REGULAR == parameter->type)
|
else if (CPARAMETER_TYPE_REGULAR == parameter->type)
|
||||||
{
|
{
|
||||||
fprintf(aFile, "\t%s "STUBPARAMETER_PARAM_S1"; /*!< @brief %s */" NEWLINES, NCHECK(parameter->dataType), parameterIndex++, NCHECK(parameter->name));
|
fprintf(aFile, "\t%s "STUBPARAMETER_PARAM_S1"; /*!< @brief \"%s\" */" NEWLINES, NCHECK(parameter->dataType), parameterIndex++,
|
||||||
|
NCHECK(parameter->name));
|
||||||
}
|
}
|
||||||
parameter = parameter->next;
|
parameter = parameter->next;
|
||||||
}
|
}
|
||||||
@@ -452,8 +453,31 @@ STATIC int8_t createStubFunctionBlock(FILE *aFile, FILE *aHeader, cfunction_t *a
|
|||||||
|
|
||||||
// expected parameter
|
// expected parameter
|
||||||
fprintf(aFile, "// Expected parameter and return value arrays for in-stub tests" NEWLINES);
|
fprintf(aFile, "// Expected parameter and return value arrays for in-stub tests" NEWLINES);
|
||||||
fprintf(aFile, STUBPARAMETER_TYPEDEF_S1 " " STUBPARAMETER_STRUCT_S1"["STUBINSTANCE_AMOUNT_S1"];" NEWLINES, aFunction->name, aFunction->name,
|
fprintf(aFile, STUBPARAMETER_TYPEDEF_S1 " " STUBPARAMETER_STRUCT_S1"["STUBINSTANCE_AMOUNT_S1"]", aFunction->name, aFunction->name, aFunction->name);
|
||||||
aFunction->name);
|
if (pointerAvailable)
|
||||||
|
{
|
||||||
|
fprintf(aFile, " = {" NEWLINES);
|
||||||
|
// pointer address check by default
|
||||||
|
|
||||||
|
parameter = aFunction->parameter.head;
|
||||||
|
parameterIndex = 'a';
|
||||||
|
while (parameter)
|
||||||
|
{
|
||||||
|
// initialize _size parameter to 1 (default to check addresses)
|
||||||
|
if (CPARAMETER_TYPE_FUNCPTR != parameter->type && (parameter->array || NULL != strstr(parameter->dataType, "*")))
|
||||||
|
{
|
||||||
|
fprintf(aFile, "\t[0 ... %u]."STUBPARAMETER_PARAM_S1" = (%s) 0x55," NEWLINES, STUB_INSTANCES_AMOUNT - 1, parameterIndex, parameter->dataType);
|
||||||
|
fprintf(aFile, "\t[0 ... %u]."STUBPARAMETER_PARAM_S1"_size = 1," NEWLINES, STUB_INSTANCES_AMOUNT - 1, parameterIndex);
|
||||||
|
}
|
||||||
|
++parameterIndex;
|
||||||
|
parameter = parameter->next;
|
||||||
|
}
|
||||||
|
fprintf(aFile, "};" NEWLINES);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
fprintf(aFile, ";" NEWLINES);
|
||||||
|
}
|
||||||
NEWLINE(aFile);
|
NEWLINE(aFile);
|
||||||
|
|
||||||
// stub function init header; function comment
|
// stub function init header; function comment
|
||||||
|
Reference in New Issue
Block a user