Include string.h in bfd.h and delete LITMEMCPY, LITSTRCPY
authorAlan Modra <amodra@gmail.com>
Tue, 30 Mar 2021 23:32:08 +0000 (10:02 +1030)
committerAlan Modra <amodra@gmail.com>
Wed, 31 Mar 2021 00:17:59 +0000 (10:47 +1030)
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
anywhere.

bfd/
* bfd-in.h: Include string.h.
(LITMEMCPY, LITSTRCPY): Delete.
* bfd-in2.h: Regenerate.
binutils/
* prdbg.c (pr_function_type): Replace LITSTTCPY with strcpy.

bfd/ChangeLog
bfd/bfd-in.h
bfd/bfd-in2.h
binutils/ChangeLog
binutils/prdbg.c

index a94223d1d99a9b32d2feb02495f9539b17ce47a4..59362799c97aee1f1352b8e41ecee3f1f2a4f408 100644 (file)
@@ -1,3 +1,9 @@
+2021-03-31  Alan Modra  <amodra@gmail.com>
+
+       * bfd-in.h: Include string.h.
+       (LITMEMCPY, LITSTRCPY): Delete.
+       * bfd-in2.h: Regenerate.
+
 2021-03-30  Alan Modra  <amodra@gmail.com>
 
        * elflink.c (elf_link_add_object_symbols): Don't set h->indx
index fda9fe0198ebecf2a294fa9a9ce4b959e443d326..f90f71809116fa21d3df95222cc1a7536152dda1 100644 (file)
@@ -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
index 8874da88afdaf60321d47beedc27fdba3799d11c..426ab86da7ad9214fb9e0abbe5a1ed9564ccd0a2 100644 (file)
@@ -44,6 +44,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)
@@ -64,13 +65,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
index 8928e2319d182ea29fc09b0005a20424f1cbbba5..b62f115443f4c14f4d2e4bbb99d5810e4747a3a5 100644 (file)
@@ -1,3 +1,7 @@
+2021-03-31  Alan Modra  <amodra@gmail.com>
+
+       * prdbg.c (pr_function_type): Replace LITSTTCPY with strcpy.
+
 2021-03-29  Alan Modra  <amodra@gmail.com>
 
        * dlltool.c (main): Don't use "boolean_condition ? TRUE : FALSE".
index 614d7f918f573cecef0f7b52fa300464b11ab724..521dfa008074fd910c8e4c36a46a90a610a4181f 100644 (file)
@@ -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 */");
This page took 0.030003 seconds and 4 git commands to generate.