public inbox for gcc-patches@gcc.gnu.org
 help / color / mirror / Atom feed
* [patch,lto] Fix PR81487
@ 2017-07-20 13:18 Georg-Johann Lay
  2017-07-21 11:41 ` Richard Biener
  0 siblings, 1 reply; 9+ messages in thread
From: Georg-Johann Lay @ 2017-07-20 13:18 UTC (permalink / raw)
  To: gcc-patches; +Cc: Cary Coutant

[-- Attachment #1: Type: text/plain, Size: 1069 bytes --]

Hi, this patch fixes some minor problems in lto-plugin:

Some older mingw32 host environments have broken asprintf.
As far as I can tell, the problem is that the mingw asprintf
implementation calls _vsnprintf (NULL, 0, ...) which always
returns -1 as length on the host.

The patch fixes this by using xasprintf from libiberty with
the additional benefit of easier use and unified error reporting
in the case when there is actually no more memory available, i.e.
it will use the same error massages like xmalloc then.

Moreover, the old implementation calls asprintf as

 > asprintf (&objname, "%s@0x%x%08x", file->name, lo, hi)

for large archives when the high 32 bits (hi) are non-zero.
This looks like a typo: the high part must come first to yiels
a proper 64-bit value.

Bootstrapped & re-tested on x86_64-linux gnu and also on
mingw32 which popped the "ld.exe: asprintf failed".

Ok for trunk?

Johann


lto-plugin/
	PR lto/81487
	* lto-plugin.c (claim_file_handler): Use xasprintf instead of
	asprintf.
	[hi!=0]: Swap hi and lo arguments supplied to xasprintf.

[-- Attachment #2: pr81487-ltoplugin-asprintf.diff --]
[-- Type: text/x-patch, Size: 1146 bytes --]

Index: lto-plugin/lto-plugin.c
===================================================================
--- lto-plugin/lto-plugin.c	(revision 250302)
+++ lto-plugin/lto-plugin.c	(working copy)
@@ -975,17 +975,16 @@ claim_file_handler (const struct ld_plug
 
   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
     {

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

* Re: [patch,lto] Fix PR81487
  2017-07-20 13:18 [patch,lto] Fix PR81487 Georg-Johann Lay
@ 2017-07-21 11:41 ` Richard Biener
  2017-07-21 15:53   ` Georg-Johann Lay
  2017-07-24  8:19   ` [patch] Ad PR81487: More asprintf -> xasprintf replacements Georg-Johann Lay
  0 siblings, 2 replies; 9+ messages in thread
From: Richard Biener @ 2017-07-21 11:41 UTC (permalink / raw)
  To: Georg-Johann Lay; +Cc: gcc-patches, Cary Coutant

On Thu, Jul 20, 2017 at 3:18 PM, Georg-Johann Lay <avr@gjlay.de> wrote:
> Hi, this patch fixes some minor problems in lto-plugin:
>
> Some older mingw32 host environments have broken asprintf.
> As far as I can tell, the problem is that the mingw asprintf
> implementation calls _vsnprintf (NULL, 0, ...) which always
> returns -1 as length on the host.
>
> The patch fixes this by using xasprintf from libiberty with
> the additional benefit of easier use and unified error reporting
> in the case when there is actually no more memory available, i.e.
> it will use the same error massages like xmalloc then.
>
> Moreover, the old implementation calls asprintf as
>
>> asprintf (&objname, "%s@0x%x%08x", file->name, lo, hi)
>
> for large archives when the high 32 bits (hi) are non-zero.
> This looks like a typo: the high part must come first to yiels
> a proper 64-bit value.
>
> Bootstrapped & re-tested on x86_64-linux gnu and also on
> mingw32 which popped the "ld.exe: asprintf failed".
>
> Ok for trunk?

Ok.

I wonder if any of the other plain asprintf calls in GCC are
problematic.  From a quick look they are all inside code
only exercised when dumping/debugging.  But maybe we
should replace those as well.

Richard.

> Johann
>
>
> lto-plugin/
>         PR lto/81487
>         * lto-plugin.c (claim_file_handler): Use xasprintf instead of
>         asprintf.
>         [hi!=0]: Swap hi and lo arguments supplied to xasprintf.

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

* Re: [patch,lto] Fix PR81487
  2017-07-21 11:41 ` Richard Biener
@ 2017-07-21 15:53   ` Georg-Johann Lay
  2017-07-24  8:19   ` [patch] Ad PR81487: More asprintf -> xasprintf replacements Georg-Johann Lay
  1 sibling, 0 replies; 9+ messages in thread
From: Georg-Johann Lay @ 2017-07-21 15:53 UTC (permalink / raw)
  To: Richard Biener; +Cc: gcc-patches, Cary Coutant

On 21.07.2017 13:41, Richard Biener wrote:
> On Thu, Jul 20, 2017 at 3:18 PM, Georg-Johann Lay <avr@gjlay.de> wrote:
>> Hi, this patch fixes some minor problems in lto-plugin:
>>
>> Some older mingw32 host environments have broken asprintf.
>> As far as I can tell, the problem is that the mingw asprintf
>> implementation calls _vsnprintf (NULL, 0, ...) which always
>> returns -1 as length on the host.
>>
>> The patch fixes this by using xasprintf from libiberty with
>> the additional benefit of easier use and unified error reporting
>> in the case when there is actually no more memory available, i.e.
>> it will use the same error massages like xmalloc then.
>>
>> Moreover, the old implementation calls asprintf as
>>
>>> asprintf (&objname, "%s@0x%x%08x", file->name, lo, hi)
>>
>> for large archives when the high 32 bits (hi) are non-zero.
>> This looks like a typo: the high part must come first to yiels
>> a proper 64-bit value.
>>
>> Bootstrapped & re-tested on x86_64-linux gnu and also on
>> mingw32 which popped the "ld.exe: asprintf failed".
>>
>> Ok for trunk?
> 
> Ok.
> 
> I wonder if any of the other plain asprintf calls in GCC are
> problematic.  From a quick look they are all inside code
> only exercised when dumping/debugging.  But maybe we
> should replace those as well.
> 
> Richard.


Maybe I just didn't run into such spots yet.  I just started using
a different cross-toolchain for canadian cross builds. With my old
i386-mingw32 (3.4.5) I never saw such problems, but the new v8
(maybe also v7) no more gave sane build result, i.e. the generated
cross-compiler to run under mingw just hangs.  Must be somewhere
around tree dump no. 62, but I couldn't even find out which pass
actually hangs.  So I used 4.9.3 x64 -> mingw cross compiler in
the hope that it works better than good old 3.4.5 which did a very
good job for a really long time.

Johann

>>
>> lto-plugin/
>>          PR lto/81487
>>          * lto-plugin.c (claim_file_handler): Use xasprintf instead of
>>          asprintf.
>>          [hi!=0]: Swap hi and lo arguments supplied to xasprintf.

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

* [patch] Ad PR81487: More asprintf -> xasprintf replacements
  2017-07-21 11:41 ` Richard Biener
  2017-07-21 15:53   ` Georg-Johann Lay
@ 2017-07-24  8:19   ` Georg-Johann Lay
  2017-07-25  7:25     ` Richard Biener
  1 sibling, 1 reply; 9+ messages in thread
From: Georg-Johann Lay @ 2017-07-24  8:19 UTC (permalink / raw)
  To: gcc-patches; +Cc: Richard Biener

[-- Attachment #1: Type: text/plain, Size: 396 bytes --]

Hi, as proposed in

https://gcc.gnu.org/ml/gcc-patches/2017-07/msg01294.html

this patch does more asprintf -> xasprintf replacements.

Bootstrapped + reg-tested on x86_64-linux.

Ok for trunk?

Johann

gcc/
	PR 81487
	* hsa-brig.c (brig_init): Use xasprintf instead of asprintf.
	* gimple-pretty-print.c (dump_profile, dump_probability): Same.
	* tree-ssa-structalias.c (alias_get_name): Same.


[-- Attachment #2: pr81487-asprintf-gcc.diff --]
[-- Type: text/x-patch, Size: 2912 bytes --]

Index: gimple-pretty-print.c
===================================================================
--- gimple-pretty-print.c	(revision 249982)
+++ gimple-pretty-print.c	(working copy)
@@ -91,10 +91,10 @@ dump_profile (int frequency, profile_cou
 
   char *buf;
   if (count.initialized_p ())
-    asprintf (&buf, "[%.2f%%] [count: %" PRId64 "]", fvalue,
-	      count.to_gcov_type ());
+    buf = xasprintf ("[%.2f%%] [count: %" PRId64 "]", fvalue,
+		     count.to_gcov_type ());
   else
-    asprintf (&buf, "[%.2f%%] [count: INV]", fvalue);
+    buf = xasprintf ("[%.2f%%] [count: INV]", fvalue);
 
   const char *ret = xstrdup_for_dump (buf);
   free (buf);
@@ -121,12 +121,12 @@ dump_probability (profile_probability pr
 
   char *buf;
   if (count.initialized_p ())
-    asprintf (&buf, "[%.2f%%] [count: %" PRId64 "]", fvalue,
-	      count.to_gcov_type ());
+    buf = xasprintf ("[%.2f%%] [count: %" PRId64 "]", fvalue,
+		     count.to_gcov_type ());
   else if (probability.initialized_p ())
-    asprintf (&buf, "[%.2f%%] [count: INV]", fvalue);
+    buf = xasprintf ("[%.2f%%] [count: INV]", fvalue);
   else
-    asprintf (&buf, "[INV] [count: INV]");
+    buf = xasprintf ("[INV] [count: INV]");
 
   const char *ret = xstrdup_for_dump (buf);
   free (buf);
Index: hsa-brig.c
===================================================================
--- hsa-brig.c	(revision 249982)
+++ hsa-brig.c	(working copy)
@@ -500,7 +500,7 @@ brig_init (void)
 	  else
 	    part++;
 	  char *modname2;
-	  asprintf (&modname2, "%s_%s", modname, part);
+	  modname2 = xasprintf ("%s_%s", modname, part);
 	  free (modname);
 	  modname = modname2;
 	}
Index: tree-ssa-structalias.c
===================================================================
--- tree-ssa-structalias.c	(revision 249982)
+++ tree-ssa-structalias.c	(working copy)
@@ -2827,7 +2827,6 @@ alias_get_name (tree decl)
 {
   const char *res = NULL;
   char *temp;
-  int num_printed = 0;
 
   if (!dump_file)
     return "NULL";
@@ -2836,14 +2835,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))
     {
@@ -2854,12 +2850,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);
 	    }
 	}
     }

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

* Re: [patch] Ad PR81487: More asprintf -> xasprintf replacements
  2017-07-24  8:19   ` [patch] Ad PR81487: More asprintf -> xasprintf replacements Georg-Johann Lay
@ 2017-07-25  7:25     ` Richard Biener
  2017-07-25 20:01       ` Georg-Johann Lay
  0 siblings, 1 reply; 9+ messages in thread
From: Richard Biener @ 2017-07-25  7:25 UTC (permalink / raw)
  To: Georg-Johann Lay; +Cc: gcc-patches

On Mon, Jul 24, 2017 at 10:19 AM, Georg-Johann Lay <avr@gjlay.de> wrote:
> Hi, as proposed in
>
> https://gcc.gnu.org/ml/gcc-patches/2017-07/msg01294.html
>
> this patch does more asprintf -> xasprintf replacements.
>
> Bootstrapped + reg-tested on x86_64-linux.
>
> Ok for trunk?

Ok.

Thanks,
Richard.

> Johann
>
> gcc/
>         PR 81487
>         * hsa-brig.c (brig_init): Use xasprintf instead of asprintf.
>         * gimple-pretty-print.c (dump_profile, dump_probability): Same.
>         * tree-ssa-structalias.c (alias_get_name): Same.
>

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

* Re: [patch] Ad PR81487: More asprintf -> xasprintf replacements
  2017-07-25  7:25     ` Richard Biener
@ 2017-07-25 20:01       ` Georg-Johann Lay
  2017-07-26  7:55         ` Richard Biener
  0 siblings, 1 reply; 9+ messages in thread
From: Georg-Johann Lay @ 2017-07-25 20:01 UTC (permalink / raw)
  To: Richard Biener; +Cc: gcc-patches

Richard Biener schrieb:
> On Mon, Jul 24, 2017 at 10:19 AM, Georg-Johann Lay <avr@gjlay.de> wrote:
>> Hi, as proposed in
>>
>> https://gcc.gnu.org/ml/gcc-patches/2017-07/msg01294.html
>>
>> this patch does more asprintf -> xasprintf replacements.
>>
>> Bootstrapped + reg-tested on x86_64-linux.
>>
>> Ok for trunk?
> 
> Ok.
> 
> Thanks,
> Richard.

Is this something we want to backport to v7 ?

>> Johann
>>
>> gcc/
>>         PR 81487
>>         * hsa-brig.c (brig_init): Use xasprintf instead of asprintf.
>>         * gimple-pretty-print.c (dump_profile, dump_probability): Same.
>>         * tree-ssa-structalias.c (alias_get_name): Same.
>>

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

* Re: [patch] Ad PR81487: More asprintf -> xasprintf replacements
  2017-07-25 20:01       ` Georg-Johann Lay
@ 2017-07-26  7:55         ` Richard Biener
  2017-07-26  9:07           ` [patch,v7,committed] Backport PR81487: asprintf -> xasprintf Georg-Johann Lay
  0 siblings, 1 reply; 9+ messages in thread
From: Richard Biener @ 2017-07-26  7:55 UTC (permalink / raw)
  To: Georg-Johann Lay; +Cc: gcc-patches

On Tue, Jul 25, 2017 at 10:01 PM, Georg-Johann Lay <avr@gjlay.de> wrote:
> Richard Biener schrieb:
>>
>> On Mon, Jul 24, 2017 at 10:19 AM, Georg-Johann Lay <avr@gjlay.de> wrote:
>>>
>>> Hi, as proposed in
>>>
>>> https://gcc.gnu.org/ml/gcc-patches/2017-07/msg01294.html
>>>
>>> this patch does more asprintf -> xasprintf replacements.
>>>
>>> Bootstrapped + reg-tested on x86_64-linux.
>>>
>>> Ok for trunk?
>>
>>
>> Ok.
>>
>> Thanks,
>> Richard.
>
>
> Is this something we want to backport to v7 ?

Yes.

Richard.

>
>>> Johann
>>>
>>> gcc/
>>>         PR 81487
>>>         * hsa-brig.c (brig_init): Use xasprintf instead of asprintf.
>>>         * gimple-pretty-print.c (dump_profile, dump_probability): Same.
>>>         * tree-ssa-structalias.c (alias_get_name): Same.
>>>
>

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

* [patch,v7,committed] Backport PR81487: asprintf -> xasprintf
  2017-07-26  7:55         ` Richard Biener
@ 2017-07-26  9:07           ` Georg-Johann Lay
  2017-07-27  7:58             ` [patch,v6,committed] " Georg-Johann Lay
  0 siblings, 1 reply; 9+ messages in thread
From: Georg-Johann Lay @ 2017-07-26  9:07 UTC (permalink / raw)
  To: Richard Biener; +Cc: gcc-patches

[-- Attachment #1: Type: text/plain, Size: 1055 bytes --]

Applied as https://gcc.gnu.org/r250562

Johann

lto-plugin/
	Backport from 2017-07-21 trunk r250428.
	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-25 trunk r250499.
	PR 81487
	* hsa-brig.c (brig_init): Use xasprintf instead of asprintf.
	* gimple-pretty-print.c (dump_probability): Same.
	* tree-ssa-structalias.c (alias_get_name): Same.


On 26.07.2017 09:54, Richard Biener wrote:
> On Tue, Jul 25, 2017 at 10:01 PM, Georg-Johann Lay <avr@gjlay.de> wrote:
>> Richard Biener schrieb:
>>>
>>> On Mon, Jul 24, 2017 at 10:19 AM, Georg-Johann Lay <avr@gjlay.de> wrote:
>>>>
>>>> Hi, as proposed in
>>>>
>>>> https://gcc.gnu.org/ml/gcc-patches/2017-07/msg01294.html
>>>>
>>>> this patch does more asprintf -> xasprintf replacements.
>>>>
>>>> Bootstrapped + reg-tested on x86_64-linux.
>>>>
>>>> Ok for trunk?
>>>
>>> Ok.
>>>
>>> Thanks,
>>> Richard.
>>
>>
>> Is this something we want to backport to v7 ?
> 
> Yes.
> 
> Richard.


[-- Attachment #2: pr81487-v7.diff --]
[-- Type: text/x-patch, Size: 3234 bytes --]

Index: lto-plugin/lto-plugin.c
===================================================================
--- lto-plugin/lto-plugin.c	(revision 250560)
+++ lto-plugin/lto-plugin.c	(working copy)
@@ -975,17 +975,16 @@ claim_file_handler (const struct ld_plug
 
   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
     {
Index: gcc/gimple-pretty-print.c
===================================================================
--- gcc/gimple-pretty-print.c	(revision 250560)
+++ gcc/gimple-pretty-print.c	(working copy)
@@ -89,7 +89,7 @@ dump_probability (int value)
     return "[0.01%]";
 
   char *buf;
-  asprintf (&buf, "[%.2f%%]", fvalue);
+  buf = xasprintf ("[%.2f%%]", fvalue);
   const char *ret = xstrdup_for_dump (buf);
   free (buf);
 
Index: gcc/tree-ssa-structalias.c
===================================================================
--- gcc/tree-ssa-structalias.c	(revision 250560)
+++ gcc/tree-ssa-structalias.c	(working copy)
@@ -2827,7 +2827,6 @@ alias_get_name (tree decl)
 {
   const char *res = NULL;
   char *temp;
-  int num_printed = 0;
 
   if (!dump_file)
     return "NULL";
@@ -2836,14 +2835,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))
     {
@@ -2854,12 +2850,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: gcc/hsa-brig.c
===================================================================
--- gcc/hsa-brig.c	(revision 250560)
+++ gcc/hsa-brig.c	(working copy)
@@ -499,7 +499,7 @@ brig_init (void)
 	  else
 	    part++;
 	  char *modname2;
-	  asprintf (&modname2, "%s_%s", modname, part);
+	  modname2 = xasprintf ("%s_%s", modname, part);
 	  free (modname);
 	  modname = modname2;
 	}

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

* [patch,v6,committed] Backport PR81487: asprintf -> xasprintf
  2017-07-26  9:07           ` [patch,v7,committed] Backport PR81487: asprintf -> xasprintf Georg-Johann Lay
@ 2017-07-27  7:58             ` Georg-Johann Lay
  0 siblings, 0 replies; 9+ messages in thread
From: Georg-Johann Lay @ 2017-07-27  7:58 UTC (permalink / raw)
  To: gcc-patches; +Cc: Richard Biener

[-- Attachment #1: Type: text/plain, Size: 445 bytes --]

...also backported to v6:

https://gcc.gnu.org/r250573

Johann
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
	* hsa-brig.c (brig_init): Use xasprintf instead of asprintf.
	* tree-ssa-structalias.c (alias_get_name): Same.


[-- Attachment #2: pr81487-v6.diff --]
[-- Type: text/x-patch, Size: 2811 bytes --]

Index: gcc/hsa-brig.c
===================================================================
--- gcc/hsa-brig.c	(revision 250572)
+++ gcc/hsa-brig.c	(working copy)
@@ -492,7 +492,7 @@ brig_init (void)
 	  else
 	    part++;
 	  char *modname2;
-	  asprintf (&modname2, "%s_%s", modname, part);
+	  modname2 = xasprintf ("%s_%s", modname, part);
 	  free (modname);
 	  modname = modname2;
 	}
Index: gcc/tree-ssa-structalias.c
===================================================================
--- gcc/tree-ssa-structalias.c	(revision 250572)
+++ gcc/tree-ssa-structalias.c	(working copy)
@@ -2833,7 +2833,6 @@ alias_get_name (tree decl)
 {
   const char *res = NULL;
   char *temp;
-  int num_printed = 0;
 
   if (!dump_file)
     return "NULL";
@@ -2842,14 +2841,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))
     {
@@ -2860,12 +2856,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: lto-plugin/lto-plugin.c
===================================================================
--- lto-plugin/lto-plugin.c	(revision 250572)
+++ lto-plugin/lto-plugin.c	(working copy)
@@ -975,17 +975,16 @@ claim_file_handler (const struct ld_plug
 
   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
     {

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

end of thread, other threads:[~2017-07-27  7:58 UTC | newest]

Thread overview: 9+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2017-07-20 13:18 [patch,lto] Fix PR81487 Georg-Johann Lay
2017-07-21 11:41 ` Richard Biener
2017-07-21 15:53   ` Georg-Johann Lay
2017-07-24  8:19   ` [patch] Ad PR81487: More asprintf -> xasprintf replacements Georg-Johann Lay
2017-07-25  7:25     ` Richard Biener
2017-07-25 20:01       ` Georg-Johann Lay
2017-07-26  7:55         ` Richard Biener
2017-07-26  9:07           ` [patch,v7,committed] Backport PR81487: asprintf -> xasprintf Georg-Johann Lay
2017-07-27  7:58             ` [patch,v6,committed] " Georg-Johann Lay

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).