aboutsummaryrefslogtreecommitdiff
path: root/core
diff options
context:
space:
mode:
authorStewart Smith <stewart@linux.ibm.com>2018-11-29 15:28:26 +1100
committerStewart Smith <stewart@linux.ibm.com>2018-12-10 22:21:12 -0600
commit5ebb15d265bdd95ce2f151d05ee7ed84caefa647 (patch)
tree22ac2d77ecf6c7d48af94faaa22154cc7f624913 /core
parentb2e120fa5b0e5c9b03752d416b183a0361b31cfd (diff)
downloadskiboot-5ebb15d265bdd95ce2f151d05ee7ed84caefa647.zip
skiboot-5ebb15d265bdd95ce2f151d05ee7ed84caefa647.tar.gz
skiboot-5ebb15d265bdd95ce2f151d05ee7ed84caefa647.tar.bz2
core/cpu.c: avoid container_of(NULL) in next_cpu()
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>
Diffstat (limited to 'core')
-rw-r--r--core/cpu.c10
1 files changed, 5 insertions, 5 deletions
diff --git a/core/cpu.c b/core/cpu.c
index 4f518a4..a83f8ba 100644
--- a/core/cpu.c
+++ b/core/cpu.c
@@ -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)