diff mbox

Ad PR81487: More asprintf -> xasprintf replacements

Message ID 19a49ade-38ac-4c5e-3ca7-1ee46e3c2386@gjlay.de
State New
Headers show

Commit Message

Georg-Johann Lay July 24, 2017, 8:19 a.m. UTC
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.

Comments

Richard Biener July 25, 2017, 7:24 a.m. UTC | #1
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.
>
Georg-Johann Lay July 25, 2017, 8:01 p.m. UTC | #2
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.
>>
Richard Biener July 26, 2017, 7:54 a.m. UTC | #3
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.
>>>
>
diff mbox

Patch

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);
 	    }
 	}
     }