Skip to content

Commit

Permalink
testsuite: fix variable declarations for planner unit tests
Browse files Browse the repository at this point in the history
Problem: planner_multi_t contexts and ints are declared and initialized
using a comma-separated list that can result in UB.

Correct the declarations and initializations.
  • Loading branch information
milroy committed Feb 26, 2024
1 parent 9bad4b3 commit 6f16387
Showing 1 changed file with 4 additions and 3 deletions.
7 changes: 4 additions & 3 deletions resource/planner/test/planner_test01.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -584,7 +584,8 @@ static int test_resource_service_flow ()
static int test_more_add_remove ()
{
int rc;
int64_t span1, span2, span3, span4, span5, span6;
int64_t span1 = -1, span2 = -1, span3 = -1, span4 = -1, span5 = -1,
span6 = -1;
bool bo = false;
uint64_t resource_total = 100000;
uint64_t resource1 = 36;
Expand Down Expand Up @@ -660,7 +661,7 @@ static int test_constructors_and_overload ()
uint64_t resource5 = 2304;
uint64_t resource6 = 468;
const char resource_type[] = "core";
planner_t *ctx, *ctx2, *ctx3, *ctx4 = NULL;
planner_t *ctx = NULL, *ctx2 = NULL, *ctx3 = NULL, *ctx4 = NULL;

ctx = planner_new (0, INT64_MAX, resource_total, resource_type);

Expand Down Expand Up @@ -742,7 +743,7 @@ static int test_update ()
uint64_t resource6 = 50000;
int64_t avail, avail1 = 0;
const char resource_type[] = "core";
planner_t *ctx, *ctx2 = NULL;
planner_t *ctx = NULL, *ctx2 = NULL;

ctx = planner_new (0, INT64_MAX, resource_total, resource_type);
// Add some spans
Expand Down

0 comments on commit 6f16387

Please sign in to comment.