public inbox for gcc-patches@gcc.gnu.org
 help / color / mirror / Atom feed
* [PATCH v2] MIPS: Put the ret to the end of args of reconcat [PR112759]
@ 2023-12-19  1:30 YunQiang Su
  2023-12-19  8:40 ` Jakub Jelinek
  0 siblings, 1 reply; 3+ messages in thread
From: YunQiang Su @ 2023-12-19  1:30 UTC (permalink / raw)
  To: gcc-patches
  Cc: ian, pinskia, matoro_mailinglist_gcc-patches, jakub, YunQiang Su

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


^ permalink raw reply	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2023-12-23  8:26 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2023-12-19  1:30 [PATCH v2] MIPS: Put the ret to the end of args of reconcat [PR112759] YunQiang Su
2023-12-19  8:40 ` Jakub Jelinek
2023-12-23  8:25   ` YunQiang Su

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).