Skip to content

Commit

Permalink
Minor update to os_allocation.c & rdt.c to fix clang static analysis …
Browse files Browse the repository at this point in the history
…warnings.

Change-Id: I1e15cc094a51c751ace4d35f401675cd05dc93f9
  • Loading branch information
jbizimun authored and mdcornu committed Jul 20, 2017
1 parent 4e16eae commit c8ac180
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 7 deletions.
24 changes: 17 additions & 7 deletions lib/os_allocation.c
Original file line number Diff line number Diff line change
Expand Up @@ -1042,7 +1042,11 @@ os_pid_get_pid_assoc(const unsigned class_id, unsigned *count)
idx++;
}

tasks = (unsigned *) malloc(idx * sizeof(tasks[0]));
/* if no pids found then allocate empty buffer to be returned */
if (idx == 0)
tasks = (unsigned *) calloc(1, sizeof(tasks[0]));
else
tasks = (unsigned *) malloc(idx * sizeof(tasks[0]));
if (tasks == NULL)
goto exit_clean;

Expand Down Expand Up @@ -1160,7 +1164,7 @@ os_alloc_assign(const unsigned technology,
const unsigned core_num,
unsigned *class_id)
{
unsigned i, hi_cos_id;
unsigned i, num_rctl_grps = 0;
int ret;

ASSERT(core_num > 0);
Expand All @@ -1170,12 +1174,15 @@ os_alloc_assign(const unsigned technology,
UNUSED_PARAM(technology);

/* obtain highest class id for all requested technologies */
ret = os_get_max_rctl_grps(m_cap, &hi_cos_id);
ret = os_get_max_rctl_grps(m_cap, &num_rctl_grps);
if (ret != PQOS_RETVAL_OK)
return ret;

if (num_rctl_grps == 0)
return PQOS_RETVAL_ERROR;

/* find an unused class from highest down */
ret = get_unused_cos(hi_cos_id - 1, class_id);
ret = get_unused_cos(num_rctl_grps - 1, class_id);
if (ret != PQOS_RETVAL_OK)
return ret;

Expand Down Expand Up @@ -1760,7 +1767,7 @@ os_alloc_assign_pid(const unsigned technology,
const unsigned task_num,
unsigned *class_id)
{
unsigned i, hi_cos_id;
unsigned i, num_rctl_grps = 0;
int ret;

ASSERT(task_num > 0);
Expand All @@ -1770,12 +1777,15 @@ os_alloc_assign_pid(const unsigned technology,
UNUSED_PARAM(technology);

/* obtain highest class id for all requested technologies */
ret = os_get_max_rctl_grps(m_cap, &hi_cos_id);
ret = os_get_max_rctl_grps(m_cap, &num_rctl_grps);
if (ret != PQOS_RETVAL_OK)
return ret;

if (num_rctl_grps == 0)
return PQOS_RETVAL_ERROR;

/* find an unused class from highest down */
ret = get_unused_cos(hi_cos_id - 1, class_id);
ret = get_unused_cos(num_rctl_grps - 1, class_id);
if (ret != PQOS_RETVAL_OK)
return ret;

Expand Down
2 changes: 2 additions & 0 deletions rdtset/rdt.c
Original file line number Diff line number Diff line change
Expand Up @@ -1412,6 +1412,8 @@ alloc_configure(void)
unsigned i = 0;
int ret = 0;

memset(pid_cfg, 0, g_cfg.config_count * sizeof(pid_cfg[0]));

/* Validate cmd line configuration */
ret = alloc_validate();
if (ret != 0) {
Expand Down

0 comments on commit c8ac180

Please sign in to comment.