Include string.h in bfd.h and delete LITMEMCPY, LITSTRCPY

Message ID
State New
Headers show
  • Include string.h in bfd.h and delete LITMEMCPY, LITSTRCPY
Related show

Commit Message

H.J. Lu via Binutils March 31, 2021, 12:20 a.m.
This fixes the issue that startswith depends on strncpy being
declared, and not all projects using bfd.h include string.h before
bfd.h.  I've also deleted some macros that don't find much use

	* bfd-in.h: Include string.h.
	* bfd-in2.h: Regenerate.
	* prdbg.c (pr_function_type): Replace LITSTTCPY with strcpy.

Alan Modra
Australia Development Lab, IBM


diff --git a/bfd/bfd-in.h b/bfd/bfd-in.h
index fda9fe0198e..f90f7180911 100644
--- a/bfd/bfd-in.h
+++ b/bfd/bfd-in.h
@@ -37,6 +37,7 @@  extern "C" {
 #include "bfd_stdint.h"
 #include "diagnostics.h"
 #include <stdarg.h>
+#include <string.h>
 #include <sys/stat.h>
 #if defined (__STDC__) || defined (ALMOST_STDC) || defined (HAVE_STRINGIZE)
@@ -57,13 +58,6 @@  extern "C" {
    is error prone, so using this macro is safer.  */
 #define STRING_COMMA_LEN(STR) (STR), (sizeof (STR) - 1)
-  /* strcpy() can have a similar problem, but since we know we are
-     copying a constant string, we can use memcpy which will be faster
-     since there is no need to check for a NUL byte inside STR.  We
-     can also save time if we do not need to copy the terminating NUL.  */
-#define LITMEMCPY(DEST,STR2) memcpy ((DEST), (STR2), sizeof (STR2) - 1)
-#define LITSTRCPY(DEST,STR2) memcpy ((DEST), (STR2), sizeof (STR2))
 #define BFD_SUPPORTS_PLUGINS @supports_plugins@
 /* The word size used by BFD on the host.  This may be 64 with a 32
diff --git a/binutils/prdbg.c b/binutils/prdbg.c
index 614d7f918f5..521dfa00807 100644
--- a/binutils/prdbg.c
+++ b/binutils/prdbg.c
@@ -752,7 +752,7 @@  pr_function_type (void *p, int argcount, bfd_boolean varargs)
   /* Now the return type is on the top of the stack.  */
   s = (char *) xmalloc (len);
-  LITSTRCPY (s, "(|) (");
+  strcpy (s, "(|) (");
   if (argcount < 0)
     strcat (s, "/* unknown */");