Hello!

This patch uses x{v,}asprintf where the result of the function is unused.

2014-12-26  Uros Bizjak  <ubiz...@gmail.com>

    * diagnostic.c (build_message_string): Use xvasprintf.
    * final.c (output_operand_lossage): Use xvasprintf and xasprintf.
    * lto-wrapper.c (merge_and_complain): Use xasprintf.
    * targhooks.c (pch_option_mismatch): Ditto.
    * tree-ssa-structalias.c (create_function_info_for): Ditto.
    (create_variable_info_for_1): Ditto.

Bootstrapped and regression tested on x86_64-linux-gnu {,-m32}.

OK for mainline?

Uros.
Index: diagnostic.c
===================================================================
--- diagnostic.c        (revision 219070)
+++ diagnostic.c        (working copy)
@@ -70,7 +70,7 @@ build_message_string (const char *msg, ...)
   va_list ap;
 
   va_start (ap, msg);
-  vasprintf (&str, msg, ap);
+  str = xvasprintf (msg, ap);
   va_end (ap);
 
   return str;
Index: final.c
===================================================================
--- final.c     (revision 219070)
+++ final.c     (working copy)
@@ -3420,8 +3420,8 @@ output_operand_lossage (const char *cmsgid, ...)
   va_start (ap, cmsgid);
 
   pfx_str = this_is_asm_operands ? _("invalid 'asm': ") : "output_operand: ";
-  asprintf (&fmt_string, "%s%s", pfx_str, _(cmsgid));
-  vasprintf (&new_message, fmt_string, ap);
+  fmt_string = xasprintf ("%s%s", pfx_str, _(cmsgid));
+  new_message = xvasprintf (fmt_string, ap);
 
   if (this_is_asm_operands)
     error_for_asm (this_is_asm_operands, "%s", new_message);
Index: lto-wrapper.c
===================================================================
--- lto-wrapper.c       (revision 219070)
+++ lto-wrapper.c       (working copy)
@@ -371,7 +371,7 @@ merge_and_complain (struct cl_decoded_option **dec
                }
              (*decoded_options)[j].opt_index = OPT_O;
              char *tem;
-             asprintf (&tem, "-O%d", level);
+             tem = xasprintf ("-O%d", level);
              (*decoded_options)[j].arg = &tem[2];
              (*decoded_options)[j].canonical_option[0] = tem;
              (*decoded_options)[j].value = 1;
Index: targhooks.c
===================================================================
--- targhooks.c (revision 219070)
+++ targhooks.c (working copy)
@@ -1639,12 +1639,8 @@ default_get_pch_validity (size_t *sz)
 static const char *
 pch_option_mismatch (const char *option)
 {
-  char *r;
-
-  asprintf (&r, _("created and used with differing settings of '%s'"), option);
-  if (r == NULL)
-    return _("out of memory");
-  return r;
+  return xasprintf (_("created and used with differing settings of '%s'"),
+                   option);
 }
 
 /* Default version of pch_valid_p.  */
Index: tree-ssa-structalias.c
===================================================================
--- tree-ssa-structalias.c      (revision 219070)
+++ tree-ssa-structalias.c      (working copy)
@@ -5457,7 +5457,7 @@ create_function_info_for (tree decl, const char *n
       const char *newname;
       char *tempname;
 
-      asprintf (&tempname, "%s.clobber", name);
+      tempname = xasprintf ("%s.clobber", name);
       newname = ggc_strdup (tempname);
       free (tempname);
 
@@ -5471,7 +5471,7 @@ create_function_info_for (tree decl, const char *n
       prev_vi->next = clobbervi->id;
       prev_vi = clobbervi;
 
-      asprintf (&tempname, "%s.use", name);
+      tempname = xasprintf ("%s.use", name);
       newname = ggc_strdup (tempname);
       free (tempname);
 
@@ -5493,7 +5493,7 @@ create_function_info_for (tree decl, const char *n
       const char *newname;
       char *tempname;
 
-      asprintf (&tempname, "%s.chain", name);
+      tempname = xasprintf ("%s.chain", name);
       newname = ggc_strdup (tempname);
       free (tempname);
 
@@ -5521,7 +5521,7 @@ create_function_info_for (tree decl, const char *n
       if (DECL_RESULT (decl))
        resultdecl = DECL_RESULT (decl);
 
-      asprintf (&tempname, "%s.result", name);
+      tempname = xasprintf ("%s.result", name);
       newname = ggc_strdup (tempname);
       free (tempname);
 
@@ -5551,7 +5551,7 @@ create_function_info_for (tree decl, const char *n
       if (arg)
        argdecl = arg;
 
-      asprintf (&tempname, "%s.arg%d", name, i);
+      tempname = xasprintf ("%s.arg%d", name, i);
       newname = ggc_strdup (tempname);
       free (tempname);
 
@@ -5580,7 +5580,7 @@ create_function_info_for (tree decl, const char *n
       char *tempname;
       tree decl;
 
-      asprintf (&tempname, "%s.varargs", name);
+      tempname = xasprintf ("%s.varargs", name);
       newname = ggc_strdup (tempname);
       free (tempname);
 
@@ -5717,8 +5717,10 @@ create_variable_info_for_1 (tree decl, const char
 
       if (dump_file)
        {
-         asprintf (&tempname, "%s." HOST_WIDE_INT_PRINT_DEC
-                   "+" HOST_WIDE_INT_PRINT_DEC, name, fo->offset, fo->size);
+         tempname
+           = xasprintf ("%s." HOST_WIDE_INT_PRINT_DEC
+                        "+" HOST_WIDE_INT_PRINT_DEC, name,
+                        fo->offset, fo->size);
          newname = ggc_strdup (tempname);
          free (tempname);
        }

Reply via email to