From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from smtp.gentoo.org (smtp.gentoo.org [IPv6:2001:470:ea4a:1:5054:ff:fec7:86e4]) by sourceware.org (Postfix) with ESMTP id 97E7B3858D1E for ; Sun, 25 Dec 2022 07:14:40 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.1 sourceware.org 97E7B3858D1E Authentication-Results: sourceware.org; dmarc=pass (p=none dis=none) header.from=gentoo.org Authentication-Results: sourceware.org; spf=pass smtp.mailfrom=gentoo.org Received: by smtp.gentoo.org (Postfix, from userid 559) id 4B1E3340F8F; Sun, 25 Dec 2022 07:14:39 +0000 (UTC) From: Mike Frysinger To: gdb-patches@sourceware.org Subject: [PATCH 1/9] sim: cpu: fix SMP msg prefix helper Date: Sun, 25 Dec 2022 02:14:26 -0500 Message-Id: <20221225071434.30014-1-vapier@gentoo.org> X-Mailer: git-send-email 2.39.0 MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Spam-Status: No, score=-11.2 required=5.0 tests=BAYES_00,GIT_PATCH_0,JMQ_SPF_NEUTRAL,KAM_DMARC_STATUS,SPF_HELO_PASS,SPF_PASS,TXREP autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on server2.sourceware.org List-Id: This code fails to compile when SMP is enabled due to some obvious errors. Fix those and change the logic to avoid CPP to prevent any future rot from creeping back in. --- sim/common/sim-utils.c | 11 +++++++---- 1 file changed, 7 insertions(+), 4 deletions(-) diff --git a/sim/common/sim-utils.c b/sim/common/sim-utils.c index 259b14cce295..d4a624c3b6ff 100644 --- a/sim/common/sim-utils.c +++ b/sim/common/sim-utils.c @@ -123,14 +123,17 @@ sim_cpu_lookup (SIM_DESC sd, const char *cpu_name) const char * sim_cpu_msg_prefix (sim_cpu *cpu) { -#if MAX_NR_PROCESSORS == 1 - return ""; -#else static char *prefix; + if (MAX_NR_PROCESSORS == 1) + return ""; + if (prefix == NULL) { + SIM_DESC sd = CPU_STATE (cpu); int maxlen = 0; + int i; + for (i = 0; i < MAX_NR_PROCESSORS; ++i) { int len = strlen (CPU_NAME (STATE_CPU (sd, i))); @@ -140,8 +143,8 @@ sim_cpu_msg_prefix (sim_cpu *cpu) prefix = (char *) xmalloc (maxlen + 5); } sprintf (prefix, "%s: ", CPU_NAME (cpu)); + return prefix; -#endif } /* Cover fn to sim_io_eprintf. */ -- 2.39.0