This is the mail archive of the binutils@sourceware.org mailing list for the binutils project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

[PATCH] binutils: Fix warning on platforms that don't have asprintf()


Hello
I tested out 'master' of binutils on AIX 7.2 and found a couple of warnings. This patch fixes one of them. The warning seems harmless, but since -Werror defaults to being on it does break the build.

This is my first go at submitting a Binutils patch, please let me know if I need to do anything differently!
Thanks
Sam

--
Sam Thursfield, Codethink Ltd.
Office telephone: +44 161 236 5575
commit 79604df7734f711b80e6a1d8f2ffe15bfa5cec7b
Author: Sam Thursfield <sam.thursfield@codethink.co.uk>
Date:   Wed Mar 1 11:16:25 2017 -0600

    binutils: Fix warning on platforms that don't have asprintf()
    
    Fixes the following warning:
    
    	nm.c: In function 'get_elf_symbol_type':
    	nm.c:364:9: error: implicit declaration of function 'asprintf' [-Werror=implicit-function-declaration]
    	     n = asprintf (&bufp, _("<processor specific>: %d"), type);
    		 ^~~~~~~~
    
    binutils/ChangeLog:
        * binutils/configure.ac: Check if host libc has asprintf().
        * binutils/config.in: Add HAVE_DECL_ASPRINTF.
        * binutils/configure: Regenerate.

diff --git a/binutils/config.in b/binutils/config.in
index 5174d3e..6a63e2d 100644
--- a/binutils/config.in
+++ b/binutils/config.in
@@ -35,6 +35,10 @@
    */
 #undef HAVE_ALLOCA_H
 
+/* Define to 1 if you have the declaration of `asprintf', and to 0 if you
+   don't. */
+#undef HAVE_DECL_ASPRINTF
+
 /* Define to 1 if you have the declaration of `environ', and to 0 if you
    don't. */
 #undef HAVE_DECL_ENVIRON
diff --git a/binutils/configure b/binutils/configure
index fc9b976..48fa906 100755
--- a/binutils/configure
+++ b/binutils/configure
@@ -13518,6 +13518,16 @@ $as_echo "#define HAVE_GOOD_UTIME_H 1" >>confdefs.h
 
 fi
 
+ac_fn_c_check_decl "$LINENO" "asprintf" "ac_cv_have_decl_asprintf" "$ac_includes_default"
+if test "x$ac_cv_have_decl_asprintf" = x""yes; then :
+  ac_have_decl=1
+else
+  ac_have_decl=0
+fi
+
+cat >>confdefs.h <<_ACEOF
+#define HAVE_DECL_ASPRINTF $ac_have_decl
+_ACEOF
 ac_fn_c_check_decl "$LINENO" "environ" "ac_cv_have_decl_environ" "$ac_includes_default"
 if test "x$ac_cv_have_decl_environ" = x""yes; then :
   ac_have_decl=1
diff --git a/binutils/configure.ac b/binutils/configure.ac
index 2f3fca9..fbd366a 100644
--- a/binutils/configure.ac
+++ b/binutils/configure.ac
@@ -198,7 +198,7 @@ if test $bu_cv_header_utime_h = yes; then
   AC_DEFINE(HAVE_GOOD_UTIME_H, 1, [Does <utime.h> define struct utimbuf?])
 fi
 
-AC_CHECK_DECLS([environ, fprintf, getc_unlocked, getenv,
+AC_CHECK_DECLS([asprintf, environ, fprintf, getc_unlocked, getenv,
 		sbrk, snprintf, stpcpy, strnlen, strstr, vsnprintf])
 
 # Link in zlib if we can.  This allows us to read compressed debug

Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]