Skip to content

Commit

Permalink
Fix nasa#55, resolve uninitialized pointer warning
Browse files Browse the repository at this point in the history
Initialize the variables at the beginning of the function.  They
will be set again in the loop, but this avoids the compiler warning.
  • Loading branch information
jphickey committed Dec 2, 2021
1 parent 7b99b91 commit 0ea1212
Showing 1 changed file with 27 additions and 1 deletion.
28 changes: 27 additions & 1 deletion unit-test/cf_clist_tests.c
Original file line number Diff line number Diff line change
Expand Up @@ -212,6 +212,9 @@ void Test_CF_CList_InsertFront_WhenNodeListIsGreaterThanTwoNodesAndTheyPointToCo
uint8 num_extraneous_nodes = Any_uint8_LessThan(18) + 1; // 1 to 18
int i = 0;

dummy_second_node = NULL;
dummy_next_to_last_node = NULL;

for (i = 0; i < num_extraneous_nodes; ++i)
{
clist_node dummy_clist_node = malloc(sizeof(*dummy_clist_node));
Expand Down Expand Up @@ -396,6 +399,9 @@ void Test_CF_CList_InsertBack_WhenNodeListIsGreaterThanTwoNodesAndTheyPointToCor
uint8 num_extraneous_nodes = Any_uint8_LessThan(18) + 1; // 1 to 18
int i = 0;

dummy_second_node = NULL;
dummy_next_to_last_node = NULL;

for (i = 0; i < num_extraneous_nodes; ++i)
{
clist_node dummy_clist_node = malloc(sizeof(*dummy_clist_node));
Expand Down Expand Up @@ -659,6 +665,9 @@ void Test_CF_ClistRemove_RemovingHeadSetSecondNodeToHeadAndUpdateLastNode(void)
uint8 num_extraneous_nodes = Any_uint8_LessThan(18) + 1; // 1 to 18
int i = 0;

dummy_second_node = NULL;
dummy_next_to_last_node = NULL;

for (i = 0; i < num_extraneous_nodes; ++i)
{
clist_node dummy_clist_node = malloc(sizeof(*dummy_clist_node));
Expand Down Expand Up @@ -721,6 +730,9 @@ void Test_CF_ClistRemove_RemovingLastPointHeadAndNextToLastToEachOther(void)
uint8 num_extraneous_nodes = Any_uint8_LessThan(18) + 1; // 1 to 18
int i = 0;

dummy_second_node = NULL;
dummy_next_to_last_node = NULL;

for (i = 0; i < num_extraneous_nodes; ++i)
{
clist_node dummy_clist_node = malloc(sizeof(*dummy_clist_node));
Expand Down Expand Up @@ -786,6 +798,11 @@ void Test_CF_ClistRemove_RemovingAnyNodeHasNodesPrevAndNextPointToEachOther(void
uint8 num_of_removed_node = Any_uint8_LessThan(num_extraneous_nodes);
int i = 0;

dummy_removed_node = NULL;
arg_node = NULL;
dummy_second_node = NULL;
dummy_next_to_last_node = NULL;

for (i = 0; i < num_extraneous_nodes; ++i)
{
clist_node dummy_clist_node = malloc(sizeof(*dummy_clist_node));
Expand Down Expand Up @@ -991,6 +1008,9 @@ void Test_CF_CList_InsertAfter_WhenAnyNodeSuccess_after_IsInsertedAfter_start(vo
uint8 insertion_point = Any_uint8_LessThan(num_extraneous_nodes);
int i = 0;

dummy_second_node = NULL;
dummy_next_to_last_node = NULL;

for (i = 0; i < num_extraneous_nodes; ++i)
{
clist_node dummy_clist_node = malloc(sizeof(*dummy_clist_node));
Expand Down Expand Up @@ -1163,6 +1183,9 @@ void Test_CF_CList_Traverse_WhenListIsManyNodesErrorIn_fn_Call(void)
int i = 0;
Dummy_clist_fn_t_context_t context_Dummy_clist_fn_t[list_size];

arg_start = NULL;
adder_node = NULL;

/* set up list */
for (i = 0; i < list_size; ++i)
{
Expand Down Expand Up @@ -1238,6 +1261,9 @@ void Test_CF_CList_Traverse_WhenListIsManyNodesSuccess(void)
int i = 0;
Dummy_clist_fn_t_context_t context_Dummy_clist_fn_t[list_size + 1];

arg_start = NULL;
adder_node = NULL;

/* set up list */
for (i = 0; i < list_size; ++i)
{
Expand Down Expand Up @@ -1615,4 +1641,4 @@ void UtTest_Setup(void)
add_CF_CList_Traverse_R_tests();
} /* end UtTest_Setup for cf_clist_tests.c */

/* end cf_clist_tests.c */
/* end cf_clist_tests.c */

0 comments on commit 0ea1212

Please sign in to comment.