From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mail-il1-f174.google.com (mail-il1-f174.google.com [209.85.166.174]) by sourceware.org (Postfix) with ESMTPS id 26A4D3858417; Tue, 19 Dec 2023 01:31:15 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org 26A4D3858417 Authentication-Results: sourceware.org; dmarc=none (p=none dis=none) header.from=gcc.gnu.org Authentication-Results: sourceware.org; spf=pass smtp.mailfrom=gmail.com ARC-Filter: OpenARC Filter v1.0.0 sourceware.org 26A4D3858417 Authentication-Results: server2.sourceware.org; arc=none smtp.remote-ip=209.85.166.174 ARC-Seal: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1702949476; cv=none; b=mqzEKbpMmrH1sgXO8hXhF95wG5Ac5DuiOye04dJz6wQY5d9z0wMYMcZMKqJJCh2LkvH5OYRAXD9cXNgKLKOR8OvbUMcAXpEqh/COPPzOYBkUOPhGc9cPRjbP3WQliEeOJWbwZ2haHXCsT1s2O2VZF0bsNPvX3YUtbCcPNhBIHag= ARC-Message-Signature: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1702949476; c=relaxed/simple; bh=iaJhDoZrjd1IzMN1xB0dL3eAhB1/JSvUKroG/uo5DqE=; h=From:To:Subject:Date:Message-Id:MIME-Version; b=uY0aXxott40PQdIvpfD/MfN/c+luT8D8UezslYVPAl22NYSARvngzbM3vrfDD0pJ3RN8uuqnzz/s+gLxMR2lonGCNWTD6/pNeoSBRHftFRxhcF0Zz/yy03g68KyMo06o3/7uY3Z/CILDLp1Y89mdFGtJqlBSSyR6CNi60D/hxhs= ARC-Authentication-Results: i=1; server2.sourceware.org Received: by mail-il1-f174.google.com with SMTP id e9e14a558f8ab-35f3e4ce411so32370775ab.0; Mon, 18 Dec 2023 17:31:15 -0800 (PST) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1702949474; x=1703554274; h=content-transfer-encoding:mime-version:message-id:date:subject:cc :to:from:x-gm-message-state:from:to:cc:subject:date:message-id :reply-to; bh=uZmI22jL95E4ioVtQFRxOWt9tKG4Hlk7JnZgdWlbmz4=; b=vM9zB69ei+9jDO+cQtNC7tJ3FxWd1p1X1sXBxWgVP7BsMIhSuZqS9HwqEvPNJw5l3J Sf5//dAmL1uvya/LzP4fTgWnRwmxZBRaSS3t1/o9+e/O7xTfflPJQNvqoS+hnvPOP5ce S1pGNzR5ax1V64CGQ0OBI8QTd0RXVejVCR3qrKQP7PLoONnoII86qIH0lwexUyHutd4N cyl0herJEphFB5RqQuJCUu8OfTEmu7ycIwne9Wz6PWECEiHRmq3+vFMC5mS/QKANW8S2 ey6f/WV97HzGEnUBb0WiY6iqzgLdDwnUdE9lN6IGK9VyHo5PXdEr7OChL7C05J/u/SHd LE/A== X-Gm-Message-State: AOJu0YwR0y5xBup2uenZ4tKOvGsz1YGXucoNY2/pv7Q4pA5s16CzOYKO iq/y8srMyoQeujYR/BXUDF+UmO4herOXujMf X-Google-Smtp-Source: AGHT+IEXTJc7SUEymrcYDo3bTUUwsczxLgB+apTuvZJOC7QW+l9lKfHLViSMdtPbTGqJ2bILLHlNNQ== X-Received: by 2002:a05:6e02:15c7:b0:35d:763a:926c with SMTP id q7-20020a056e0215c700b0035d763a926cmr31373838ilu.114.1702949473812; Mon, 18 Dec 2023 17:31:13 -0800 (PST) Received: from localhost.localdomain ([149.248.38.156]) by smtp.gmail.com with ESMTPSA id u2-20020a17090282c200b001d2e958e34bsm10720557plz.159.2023.12.18.17.31.09 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 18 Dec 2023 17:31:13 -0800 (PST) From: YunQiang Su To: gcc-patches@gcc.gnu.org Cc: ian@airs.com, pinskia@gmail.com, matoro_mailinglist_gcc-patches@matoro.tk, jakub@redhat.com, YunQiang Su Subject: [PATCH v2] MIPS: Put the ret to the end of args of reconcat [PR112759] Date: Tue, 19 Dec 2023 09:30:49 +0800 Message-Id: <20231219013049.3165982-1-syq@gcc.gnu.org> X-Mailer: git-send-email 2.39.2 MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Spam-Status: No, score=-12.0 required=5.0 tests=BAYES_00,FREEMAIL_FORGED_FROMDOMAIN,FREEMAIL_FROM,GIT_PATCH_0,HEADER_FROM_DIFFERENT_DOMAINS,KAM_DMARC_STATUS,RCVD_IN_DNSWL_NONE,RCVD_IN_MSPIKE_H2,SPF_HELO_NONE,SPF_PASS,TXREP,T_SCC_BODY_TEXT_LINE 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: The function `reconcat` cannot append string(s) to NULL, as the concat process will stop at the first NULL. Let's always put the `ret` to the end, as it may be NULL. We keep use reconcat here, due to that reconcat can make it easier if we add more hardware features detecting, for example by hwcap. gcc/ PR target/112759 * config/mips/driver-native.cc (host_detect_local_cpu): Put the ret to the end of args of reconcat. --- gcc/config/mips/driver-native.cc | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/gcc/config/mips/driver-native.cc b/gcc/config/mips/driver-native.cc index afc276f5278..9a224b3f401 100644 --- a/gcc/config/mips/driver-native.cc +++ b/gcc/config/mips/driver-native.cc @@ -44,6 +44,8 @@ const char * host_detect_local_cpu (int argc, const char **argv) { const char *cpu = NULL; + /* Don't assigne any static string to ret. If you need to do so, + use concat. */ char *ret = NULL; char buf[128]; FILE *f; @@ -90,7 +92,8 @@ host_detect_local_cpu (int argc, const char **argv) fallback_cpu: #if defined (__mips_nan2008) - ret = reconcat (ret, " -mnan=2008 ", NULL); + /* Put the ret to the end of list, since it maybe NULL. */ + ret = reconcat (ret, "-mnan=2008", ret, NULL); #endif #ifdef HAVE_GETAUXVAL @@ -104,7 +107,7 @@ fallback_cpu: #endif if (cpu) - ret = reconcat (ret, ret, "-m", argv[0], "=", cpu, NULL); + ret = reconcat (ret, "-m", argv[0], "=", cpu, ret, NULL); return ret; } -- 2.39.2