Blame SOURCES/binutils-warnings.patch

3dad3f
diff --git a/binutils/dwarf.c b/binutils/dwarf.c
3dad3f
index 6ecfab5d..f8698213 100644
3dad3f
--- a/binutils/dwarf.c
3dad3f
+++ b/binutils/dwarf.c
3dad3f
@@ -4914,7 +4914,7 @@ display_debug_lines_decoded (struct dwarf_section *  section,
3dad3f
 	      else
3dad3f
 		{
3dad3f
 		  newFileName = (char *) xmalloc (fileNameLength + 1);
3dad3f
-		  strncpy (newFileName, fileName, fileNameLength + 1);
3dad3f
+		  strcpy (newFileName, fileName);
3dad3f
 		}
3dad3f
 
3dad3f
 	      if (!do_wide || (fileNameLength <= MAX_FILENAME_LENGTH))
3dad3f
diff --git a/libiberty/cp-demangle.c b/libiberty/cp-demangle.c
3dad3f
index 3639bfbf..ed080a1a 100644
3dad3f
--- a/libiberty/cp-demangle.c
3dad3f
+++ b/libiberty/cp-demangle.c
3dad3f
@@ -185,20 +185,6 @@ static void d_init_info (const char *, int, size_t, struct d_info *);
3dad3f
 #define CP_STATIC_IF_GLIBCPP_V3
3dad3f
 #endif /* ! defined(IN_GLIBCPP_V3) */
3dad3f
 
3dad3f
-/* See if the compiler supports dynamic arrays.  */
3dad3f
-
3dad3f
-#ifdef __GNUC__
3dad3f
-#define CP_DYNAMIC_ARRAYS
3dad3f
-#else
3dad3f
-#ifdef __STDC__
3dad3f
-#ifdef __STDC_VERSION__
3dad3f
-#if __STDC_VERSION__ >= 199901L && !__STDC_NO_VLA__
3dad3f
-#define CP_DYNAMIC_ARRAYS
3dad3f
-#endif /* __STDC_VERSION__ >= 199901L && !__STDC_NO_VLA__ */
3dad3f
-#endif /* defined (__STDC_VERSION__) */
3dad3f
-#endif /* defined (__STDC__) */
3dad3f
-#endif /* ! defined (__GNUC__) */
3dad3f
-
3dad3f
 /* We avoid pulling in the ctype tables, to prevent pulling in
3dad3f
    additional unresolved symbols when this code is used in a library.
3dad3f
    FIXME: Is this really a valid reason?  This comes from the original
3dad3f
@@ -4343,29 +4329,21 @@ cplus_demangle_print_callback (int options,
3dad3f
   d_print_init (&dpi, callback, opaque, dc);
3dad3f
 
3dad3f
   {
3dad3f
-#ifdef CP_DYNAMIC_ARRAYS
3dad3f
-    /* Avoid zero-length VLAs, which are prohibited by the C99 standard
3dad3f
-       and flagged as errors by Address Sanitizer.  */
3dad3f
-    __extension__ struct d_saved_scope scopes[(dpi.num_saved_scopes > 0)
3dad3f
-                                              ? dpi.num_saved_scopes : 1];
3dad3f
-    __extension__ struct d_print_template temps[(dpi.num_copy_templates > 0)
3dad3f
-                                                ? dpi.num_copy_templates : 1];
3dad3f
-
3dad3f
-    dpi.saved_scopes = scopes;
3dad3f
-    dpi.copy_templates = temps;
3dad3f
-#else
3dad3f
-    dpi.saved_scopes = alloca (dpi.num_saved_scopes
3dad3f
-			       * sizeof (*dpi.saved_scopes));
3dad3f
-    dpi.copy_templates = alloca (dpi.num_copy_templates
3dad3f
-				 * sizeof (*dpi.copy_templates));
3dad3f
-#endif
3dad3f
-
3dad3f
+    dpi.saved_scopes
3dad3f
+      = (struct d_saved_scope *) xmalloc (dpi.num_saved_scopes
3dad3f
+					  * sizeof (*dpi.saved_scopes));
3dad3f
+    dpi.copy_templates
3dad3f
+      = (struct d_print_template *) xmalloc (dpi.num_copy_templates
3dad3f
+					     * sizeof (*dpi.copy_templates));
3dad3f
     d_print_comp (&dpi, options, dc);
3dad3f
   }
3dad3f
 
3dad3f
   d_print_flush (&dpi);
3dad3f
 
3dad3f
-  return ! d_print_saw_error (&dpi);
3dad3f
+  int retval = ! d_print_saw_error (&dpi);
3dad3f
+  free (dpi.saved_scopes);
3dad3f
+  free (dpi.copy_templates);
3dad3f
+  return retval;
3dad3f
 }
3dad3f
 
3dad3f
 /* Turn components into a human readable string.  OPTIONS is the
3dad3f
@@ -6307,16 +6285,12 @@ d_demangle_callback (const char *mangled, int options,
3dad3f
     }
3dad3f
 
3dad3f
   {
3dad3f
-#ifdef CP_DYNAMIC_ARRAYS
3dad3f
-    __extension__ struct demangle_component comps[di.num_comps];
3dad3f
-    __extension__ struct demangle_component *subs[di.num_subs];
3dad3f
-
3dad3f
-    di.comps = comps;
3dad3f
-    di.subs = subs;
3dad3f
-#else
3dad3f
-    di.comps = alloca (di.num_comps * sizeof (*di.comps));
3dad3f
-    di.subs = alloca (di.num_subs * sizeof (*di.subs));
3dad3f
-#endif
3dad3f
+    di.comps
3dad3f
+      = (struct demangle_component *) xmalloc (di.num_comps
3dad3f
+					       * sizeof (*di.comps));
3dad3f
+    di.subs
3dad3f
+      = (struct demangle_component **) xmalloc (di.num_subs
3dad3f
+						* sizeof (*di.subs));
3dad3f
 
3dad3f
     switch (type)
3dad3f
       {
3dad3f
@@ -6357,6 +6331,8 @@ d_demangle_callback (const char *mangled, int options,
3dad3f
              : 0;
3dad3f
   }
3dad3f
 
3dad3f
+  free (di.comps);
3dad3f
+  free (di.subs);
3dad3f
   return status;
3dad3f
 }
3dad3f
 
3dad3f
@@ -6588,16 +6564,12 @@ is_ctor_or_dtor (const char *mangled,
3dad3f
   cplus_demangle_init_info (mangled, DMGL_GNU_V3, strlen (mangled), &di);
3dad3f
 
3dad3f
   {
3dad3f
-#ifdef CP_DYNAMIC_ARRAYS
3dad3f
-    __extension__ struct demangle_component comps[di.num_comps];
3dad3f
-    __extension__ struct demangle_component *subs[di.num_subs];
3dad3f
-
3dad3f
-    di.comps = comps;
3dad3f
-    di.subs = subs;
3dad3f
-#else
3dad3f
-    di.comps = alloca (di.num_comps * sizeof (*di.comps));
3dad3f
-    di.subs = alloca (di.num_subs * sizeof (*di.subs));
3dad3f
-#endif
3dad3f
+    di.comps
3dad3f
+      = (struct demangle_component *) xmalloc (di.num_comps
3dad3f
+					       * sizeof (*di.comps));
3dad3f
+    di.subs
3dad3f
+      = (struct demangle_component **) xmalloc (di.num_subs
3dad3f
+						* sizeof (*di.subs));
3dad3f
 
3dad3f
     dc = cplus_demangle_mangled_name (&di, 1);
3dad3f
 
3dad3f
@@ -6640,6 +6612,8 @@ is_ctor_or_dtor (const char *mangled,
3dad3f
       }
3dad3f
   }
3dad3f
 
3dad3f
+  free (di.comps);
3dad3f
+  free (di.subs);
3dad3f
   return ret;
3dad3f
 }
3dad3f
 
3dad3f
diff --git a/libiberty/make-relative-prefix.c b/libiberty/make-relative-prefix.c
3dad3f
index e3f9f920..5dbe6f89 100644
3dad3f
--- a/libiberty/make-relative-prefix.c
3dad3f
+++ b/libiberty/make-relative-prefix.c
3dad3f
@@ -259,10 +259,7 @@ make_relative_prefix_1 (const char *progname, const char *bin_prefix,
3dad3f
 #ifdef HAVE_HOST_EXECUTABLE_SUFFIX
3dad3f
 	  len += strlen (HOST_EXECUTABLE_SUFFIX);
3dad3f
 #endif
3dad3f
-	  if (len < MAX_ALLOCA_SIZE)
3dad3f
-	    nstore = (char *) alloca (len);
3dad3f
-	  else
3dad3f
-	    alloc_ptr = nstore = (char *) malloc (len);
3dad3f
+	  alloc_ptr = nstore = (char *) malloc (len);
3dad3f
 
3dad3f
 	  startp = endp = temp;
3dad3f
 	  while (1)