From: jsg Date: Fri, 26 Nov 2021 14:45:13 +0000 (+0000) Subject: avoid clang -Wsometimes-uninitialized warning when MULTIPROCESSOR is not X-Git-Url: http://artulab.com/gitweb/?a=commitdiff_plain;h=bc1aed8178838cdf7656ae9b767eec9cccb2bfbe;p=openbsd avoid clang -Wsometimes-uninitialized warning when MULTIPROCESSOR is not defined feedback from millert@, ok kettenis@, mips64 diff from and ok visa@ --- diff --git a/sys/arch/arm/arm/cpu.c b/sys/arch/arm/arm/cpu.c index f62b2a62fd5..8c0125cf94d 100644 --- a/sys/arch/arm/arm/cpu.c +++ b/sys/arch/arm/arm/cpu.c @@ -1,4 +1,4 @@ -/* $OpenBSD: cpu.c,v 1.55 2021/03/25 04:12:00 jsg Exp $ */ +/* $OpenBSD: cpu.c,v 1.56 2021/11/26 14:45:13 jsg Exp $ */ /* $NetBSD: cpu.c,v 1.56 2004/04/14 04:01:49 bsh Exp $ */ @@ -349,14 +349,11 @@ cpu_attach(struct device *parent, struct device *dev, void *aux) __asm volatile("mrc p15, 0, %0, c0, c0, 5" : "=r"(mpidr)); KASSERT(faa->fa_nreg > 0); +#ifdef MULTIPROCESSOR if (faa->fa_reg[0].addr == (mpidr & MPIDR_AFF)) { ci = &cpu_info_primary; -#ifdef MULTIPROCESSOR ci->ci_flags |= CPUF_RUNNING | CPUF_PRESENT | CPUF_PRIMARY; -#endif - } -#ifdef MULTIPROCESSOR - else { + } else { ci = malloc(sizeof(*ci), M_DEVBUF, M_WAITOK | M_ZERO); cpu_info[dev->dv_unit] = ci; ci->ci_next = cpu_info_list->ci_next; @@ -364,6 +361,8 @@ cpu_attach(struct device *parent, struct device *dev, void *aux) ci->ci_flags |= CPUF_AP; ncpus++; } +#else + ci = &cpu_info_primary; #endif ci->ci_dev = dev; diff --git a/sys/arch/arm64/arm64/cpu.c b/sys/arch/arm64/arm64/cpu.c index 4f7df211c2b..e1771226794 100644 --- a/sys/arch/arm64/arm64/cpu.c +++ b/sys/arch/arm64/arm64/cpu.c @@ -1,4 +1,4 @@ -/* $OpenBSD: cpu.c,v 1.58 2021/11/23 01:03:35 deraadt Exp $ */ +/* $OpenBSD: cpu.c,v 1.59 2021/11/26 14:45:13 jsg Exp $ */ /* * Copyright (c) 2016 Dale Rahn @@ -604,20 +604,19 @@ cpu_attach(struct device *parent, struct device *dev, void *aux) { struct fdt_attach_args *faa = aux; struct cpu_info *ci; +#ifdef MULTIPROCESSOR uint64_t mpidr = READ_SPECIALREG(mpidr_el1); +#endif uint64_t id_aa64mmfr1, sctlr; uint32_t opp; KASSERT(faa->fa_nreg > 0); +#ifdef MULTIPROCESSOR if (faa->fa_reg[0].addr == (mpidr & MPIDR_AFF)) { ci = &cpu_info_primary; -#ifdef MULTIPROCESSOR ci->ci_flags |= CPUF_RUNNING | CPUF_PRESENT | CPUF_PRIMARY; -#endif - } -#ifdef MULTIPROCESSOR - else { + } else { ci = malloc(sizeof(*ci), M_DEVBUF, M_WAITOK | M_ZERO); cpu_info[dev->dv_unit] = ci; ci->ci_next = cpu_info_list->ci_next; @@ -625,6 +624,8 @@ cpu_attach(struct device *parent, struct device *dev, void *aux) ci->ci_flags |= CPUF_AP; ncpus++; } +#else + ci = &cpu_info_primary; #endif ci->ci_dev = dev; diff --git a/sys/arch/mips64/mips64/cpu.c b/sys/arch/mips64/mips64/cpu.c index 9b818c040c3..60387228fa9 100644 --- a/sys/arch/mips64/mips64/cpu.c +++ b/sys/arch/mips64/mips64/cpu.c @@ -1,4 +1,4 @@ -/* $OpenBSD: cpu.c,v 1.80 2021/07/24 08:21:13 visa Exp $ */ +/* $OpenBSD: cpu.c,v 1.81 2021/11/26 14:45:13 jsg Exp $ */ /* * Copyright (c) 1997-2004 Opsycon AB (www.opsycon.se) @@ -83,9 +83,9 @@ cpuattach(struct device *parent, struct device *dev, void *aux) int fptype, vers_maj, vers_min; int displayver; +#ifdef MULTIPROCESSOR if (cpuno == 0) { ci = &cpu_info_primary; -#ifdef MULTIPROCESSOR ci->ci_flags |= CPUF_RUNNING | CPUF_PRESENT | CPUF_PRIMARY; if (ncpusfound > 1) { cpu_info_secondaries = (struct cpu_info *) @@ -94,15 +94,14 @@ cpuattach(struct device *parent, struct device *dev, void *aux) if (cpu_info_secondaries == NULL) panic("unable to allocate cpu_info"); } -#endif - } -#ifdef MULTIPROCESSOR - else { + } else { ci = &cpu_info_secondaries[cpuno - 1]; ci->ci_next = cpu_info_list->ci_next; cpu_info_list->ci_next = ci; ci->ci_flags |= CPUF_PRESENT; } +#else + ci = &cpu_info_primary; #endif ci->ci_self = ci; ci->ci_cpuid = cpuno; diff --git a/sys/arch/riscv64/riscv64/cpu.c b/sys/arch/riscv64/riscv64/cpu.c index fc9ef087023..ba29139cdc0 100644 --- a/sys/arch/riscv64/riscv64/cpu.c +++ b/sys/arch/riscv64/riscv64/cpu.c @@ -1,4 +1,4 @@ -/* $OpenBSD: cpu.c,v 1.11 2021/07/24 18:15:13 kettenis Exp $ */ +/* $OpenBSD: cpu.c,v 1.12 2021/11/26 14:45:13 jsg Exp $ */ /* * Copyright (c) 2016 Dale Rahn @@ -166,15 +166,12 @@ cpu_attach(struct device *parent, struct device *dev, void *aux) KASSERT(faa->fa_nreg > 0); +#ifdef MULTIPROCESSOR if (faa->fa_reg[0].addr == boot_hart) { ci = &cpu_info_primary; -#ifdef MULTIPROCESSOR ci->ci_flags |= CPUF_RUNNING | CPUF_PRESENT | CPUF_PRIMARY; csr_set(sie, SIE_SSIE); -#endif - } -#ifdef MULTIPROCESSOR - else { + } else { ci = malloc(sizeof(*ci), M_DEVBUF, M_WAITOK | M_ZERO); cpu_info[dev->dv_unit] = ci; ci->ci_next = cpu_info_list->ci_next; @@ -182,6 +179,8 @@ cpu_attach(struct device *parent, struct device *dev, void *aux) ci->ci_flags |= CPUF_AP; ncpus++; } +#else + ci = &cpu_info_primary; #endif ci->ci_dev = dev;