Skip to content

Commit

Permalink
core/cpu.c: avoid container_of(NULL) in next_cpu()
Browse files Browse the repository at this point in the history
A certain finicky static analysis tool did point out that we were
operating on a value that could be null (and since first_cpu() calls
next_cpu(NULL) to get the first one, it also gets to be complained about
as next_cpu() could act on that NULL pointer).

So, rework things to shut the static analysis tool up, when in fact this
was never a problem.

Signed-off-by: Stewart Smith <stewart@linux.ibm.com>
  • Loading branch information
stewartsmith committed Dec 11, 2018
1 parent b2e120f commit 5ebb15d
Showing 1 changed file with 5 additions and 5 deletions.
10 changes: 5 additions & 5 deletions core/cpu.c
Original file line number Diff line number Diff line change
Expand Up @@ -739,13 +739,13 @@ struct cpu_thread *find_cpu_by_server(u32 server_no)

struct cpu_thread *next_cpu(struct cpu_thread *cpu)
{
struct cpu_stack *s = container_of(cpu, struct cpu_stack, cpu);
unsigned int index;
struct cpu_stack *s;
unsigned int index = 0;

if (cpu == NULL)
index = 0;
else
if (cpu != NULL) {
s = container_of(cpu, struct cpu_stack, cpu);
index = s - cpu_stacks + 1;
}
for (; index <= cpu_max_pir; index++) {
cpu = &cpu_stacks[index].cpu;
if (cpu->state != cpu_state_no_cpu)
Expand Down

0 comments on commit 5ebb15d

Please sign in to comment.