]> git.ipfire.org Git - thirdparty/gcc.git/commitdiff
backport: re PR lto/81487 ([mingw32] ld.exe: error: asprintf failed)
authorGeorg-Johann Lay <avr@gjlay.de>
Tue, 22 Aug 2017 10:32:36 +0000 (10:32 +0000)
committerGeorg-Johann Lay <gjl@gcc.gnu.org>
Tue, 22 Aug 2017 10:32:36 +0000 (10:32 +0000)
lto-plugin/
Backport from 2017-07-26 gcc-7-branch r250562.
PR lto/81487
* lto-plugin.c (claim_file_handler): Use xasprintf instead of
asprintf.
[hi!=0]: Swap hi and lo arguments supplied to xasprintf.
gcc/
Backport from 2017-07-26 gcc-7-branch r250562.
PR 81487
* tree-ssa-structalias.c (alias_get_name): Use xasprintf instead
of asprintf.

From-SVN: r251272

gcc/ChangeLog
gcc/tree-ssa-structalias.c
lto-plugin/ChangeLog
lto-plugin/lto-plugin.c

index fc3d5a57e5e878bb1e946f9937a0fadc745a610a..bf70833293617fba075e7e97b4a147861de22eae 100644 (file)
@@ -1,3 +1,11 @@
+2017-08-22  Georg-Johann Lay  <avr@gjlay.de>
+
+       Backport from 2017-07-26 gcc-7-branch r250562.
+
+       PR 81487
+       * tree-ssa-structalias.c (alias_get_name): Use xasprintf instead
+       of asprintf.
+
 2017-08-22  Georg-Johann Lay  <avr@gjlay.de>
 
        Backport from trunk r247719.
index d1eaae2f5c42aeadb3f0d2b1f9e82494e69fef88..10231933b2a6dc39f845982e04c7540cf314f8ec 100644 (file)
@@ -2864,7 +2864,6 @@ alias_get_name (tree decl)
 {
   const char *res = NULL;
   char *temp;
-  int num_printed = 0;
 
   if (!dump_file)
     return "NULL";
@@ -2873,14 +2872,11 @@ alias_get_name (tree decl)
     {
       res = get_name (decl);
       if (res)
-       num_printed = asprintf (&temp, "%s_%u", res, SSA_NAME_VERSION (decl));
+       temp = xasprintf ("%s_%u", res, SSA_NAME_VERSION (decl));
       else
-       num_printed = asprintf (&temp, "_%u", SSA_NAME_VERSION (decl));
-      if (num_printed > 0)
-       {
-         res = ggc_strdup (temp);
-         free (temp);
-       }
+       temp = xasprintf ("_%u", SSA_NAME_VERSION (decl));
+      res = ggc_strdup (temp);
+      free (temp);
     }
   else if (DECL_P (decl))
     {
@@ -2891,12 +2887,9 @@ alias_get_name (tree decl)
          res = get_name (decl);
          if (!res)
            {
-             num_printed = asprintf (&temp, "D.%u", DECL_UID (decl));
-             if (num_printed > 0)
-               {
-                 res = ggc_strdup (temp);
-                 free (temp);
-               }
+             temp = xasprintf ("D.%u", DECL_UID (decl));
+             res = ggc_strdup (temp);
+             free (temp);
            }
        }
     }
index 39788af6c8b4b70c4b1840219fa9769acd4b9e39..7a65539d7f8c15220f28564976d4ca00c71e6e57 100644 (file)
@@ -1,3 +1,12 @@
+2017-08-22  Georg-Johann Lay  <avr@gjlay.de>
+
+       Backport from 2017-07-26 gcc-7-branch r250562.
+
+       PR lto/81487
+       * lto-plugin.c (claim_file_handler): Use xasprintf instead of
+       asprintf.
+       [hi!=0]: Swap hi and lo arguments supplied to xasprintf.
+
 2016-06-03  Release Manager
 
        * GCC 5.4.0 released.
index 8d957402ba666922c466679c53af2f4b3d46eff7..03ebb00aa23f7ad75f4ffa03e5f745ad046fe8dd 100644 (file)
@@ -920,17 +920,16 @@ claim_file_handler (const struct ld_plugin_input_file *file, int *claimed)
 
   if (file->offset != 0)
     {
-      char *objname;
       /* We pass the offset of the actual file, not the archive header.
          Can't use PRIx64, because that's C99, so we have to print the
-        64-bit hex int as two 32-bit ones. */
-      int lo, hi, t;
+        64-bit hex int as two 32-bit ones.  Use xasprintf instead of
+        asprintf because asprintf doesn't work as expected on some older
+        mingw32 hosts.  */
+      int lo, hi;
       lo = file->offset & 0xffffffff;
       hi = ((int64_t)file->offset >> 32) & 0xffffffff;
-      t = hi ? asprintf (&objname, "%s@0x%x%08x", file->name, lo, hi)
-            : asprintf (&objname, "%s@0x%x", file->name, lo);
-      check (t >= 0, LDPL_FATAL, "asprintf failed");
-      lto_file.name = objname;
+      lto_file.name = hi ? xasprintf ("%s@0x%x%08x", file->name, hi, lo)
+                        : xasprintf ("%s@0x%x", file->name, lo);
     }
   else
     {