Blame SOURCES/binutils-warnings.patch

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