Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix some GCC fanalyzer warnings #337

Merged
merged 1 commit into from
Dec 26, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion placement.c
Original file line number Diff line number Diff line change
Expand Up @@ -67,7 +67,7 @@ static void find_best_object(struct topo_obj *d, void *data)
best->best = d;
best->best_cost = newload;
} else if (newload == best->best_cost) {
if (g_list_length(d->interrupts) < g_list_length(best->best->interrupts)) {
if (!best->best || g_list_length(d->interrupts) < g_list_length(best->best->interrupts)) {
best->best = d;
}
}
Expand Down
15 changes: 8 additions & 7 deletions ui/irqbalance-ui.c
Original file line number Diff line number Diff line change
Expand Up @@ -214,17 +214,18 @@ out: {
GList * concat_child_lists(cpu_node_t *node)
{
GList *new = NULL;
GList *cpu_entry;
GList *child_entry = g_list_first(node->children);
do {
while (child_entry) {
cpu_node_t *child = (cpu_node_t *)child_entry->data;
GList *cpu_entry = g_list_first(child->cpu_list);
do {
cpu_entry = g_list_first(child->cpu_list);
while (cpu_entry) {
uint64_t *cpu = (uint64_t *)cpu_entry->data;
new = g_list_append(new, cpu);
cpu_entry = g_list_next(cpu_entry);
} while(cpu_entry != NULL);
};
child_entry = g_list_next(child_entry);
} while(child_entry != NULL);
}

return new;
}
Expand Down Expand Up @@ -253,11 +254,11 @@ void assign_cpu_mask(cpu_node_t *node, void *data __attribute__((unused)))
mask[0] = '\0';
unsigned int sum = 0;
GList *list_entry = g_list_first(node->cpu_list);
do {
while (list_entry) {
int *cpu = list_entry->data;
sum += 1 << (*cpu);
list_entry = g_list_next(list_entry);
} while(list_entry != NULL);
};
snprintf(mask, 15, "0x%x", sum);
node->cpu_mask = mask;

Expand Down
17 changes: 13 additions & 4 deletions ui/ui.c
Original file line number Diff line number Diff line change
Expand Up @@ -210,12 +210,16 @@ void display_banned_cpus(void)

int toggle_cpu(GList *cpu_list, int cpu_number)
{
cpu_ban_t *entry_data;

GList *entry = g_list_first(cpu_list);
cpu_ban_t *entry_data = (cpu_ban_t *)(entry->data);
while(entry_data->number != cpu_number) {
entry = g_list_next(entry);
while (entry) {
entry_data = (cpu_ban_t *)(entry->data);
if (entry_data && entry_data->number == cpu_number)
break;
entry = g_list_next(entry);
}

if(((cpu_ban_t *)(entry->data))->is_banned) {
((cpu_ban_t *)(entry->data))->is_banned = 0;
} else {
Expand Down Expand Up @@ -522,10 +526,15 @@ int toggle_irq(GList *irq_list, int position)
{
GList *entry = g_list_first(irq_list);
int irq_node = 0;
while(irq_node != position) {

while(entry && irq_node != position) {
entry = g_list_next(entry);
irq_node++;
}

if (!entry)
return -1;

if(((irq_t *)(entry->data))->is_banned) {
((irq_t *)(entry->data))->is_banned = 0;
} else {
Expand Down