aboutsummaryrefslogtreecommitdiff
path: root/bfd/bfd.c
diff options
context:
space:
mode:
authorAlan Modra <amodra@gmail.com>2016-09-30 11:03:52 +0930
committerAlan Modra <amodra@gmail.com>2016-09-30 11:38:39 +0930
commit52d45da3f275b5d1c8ef2e96a7760585c736133b (patch)
tree2ead3ed78b4f3488034512473db1b9e3a965a629 /bfd/bfd.c
parent1fcf3da985a9f4436674816046cf5a308eae74f3 (diff)
downloadgdb-52d45da3f275b5d1c8ef2e96a7760585c736133b.zip
gdb-52d45da3f275b5d1c8ef2e96a7760585c736133b.tar.gz
gdb-52d45da3f275b5d1c8ef2e96a7760585c736133b.tar.bz2
Make bfd_error_handler_type like vprintf
It was like printf, which means you can't use bfd_set_error_handler to hook in a function to do something and then call the original handler. The patch also deletes some unused functions and makes pointers local. bfd/ * bfd-in.h: Include stdarg.h. * bfd.c (bfd_error_handler_type): Make like vprintf. (_bfd_error_internal): Rename from _bfd_error_handler. Make static. (error_handler_internal): New function, split out from.. (_bfd_default_error_handler): ..here. Rename to _bfd_error_handler. (bfd_set_error_handler): Update. (bfd_get_error_handler, bfd_get_assert_handler): Delete. (_bfd_assert_handler): Make static. * coffgen.c (null_error_handler): Update params. * elf-bfd.h (struct elf_backend_data <link_order_error_handler>): Don't use bfd_error_handler_type. * elf64-mmix.c (mmix_dump_bpo_gregs): Likewise. * elfxx-target.h (elf_backend_link_order_error_handler): Default to _bfd_error_handler. * libbfd-in.h (_bfd_default_error_handler): Don't declare. (bfd_assert_handler_type): Likewise. (_bfd_error_handler): Update. * bfd-in2.h: Regenerate. * libbfd.h: Regenerate. ld/ * ldlang.c (ignore_bfd_errors): Update params.
Diffstat (limited to 'bfd/bfd.c')
-rw-r--r--bfd/bfd.c63
1 files changed, 18 insertions, 45 deletions
diff --git a/bfd/bfd.c b/bfd/bfd.c
index 806b9fb..4130d2d 100644
--- a/bfd/bfd.c
+++ b/bfd/bfd.c
@@ -598,11 +598,11 @@ SUBSECTION
problem. They call a BFD error handler function. This
function may be overridden by the program.
- The BFD error handler acts like printf.
+ The BFD error handler acts like vprintf.
CODE_FRAGMENT
.
-.typedef void (*bfd_error_handler_type) (const char *, ...);
+.typedef void (*bfd_error_handler_type) (const char *, va_list);
.
*/
@@ -634,10 +634,9 @@ static const char *_bfd_error_program_name;
integer_for_the_%d);
*/
-void
-_bfd_default_error_handler (const char *fmt, ...)
+static void
+error_handler_internal (const char *fmt, va_list ap)
{
- va_list ap;
char *bufp;
const char *new_fmt, *p;
size_t avail = 1000;
@@ -651,7 +650,6 @@ _bfd_default_error_handler (const char *fmt, ...)
else
fprintf (stderr, "BFD: ");
- va_start (ap, fmt);
new_fmt = fmt;
bufp = buf;
@@ -782,7 +780,6 @@ _bfd_default_error_handler (const char *fmt, ...)
}
vfprintf (stderr, new_fmt, ap);
- va_end (ap);
/* On AIX, putc is implemented as a macro that triggers a -Wunused-value
warning, so use the fputc function to avoid it. */
@@ -796,7 +793,17 @@ _bfd_default_error_handler (const char *fmt, ...)
function pointer permits a program linked against BFD to intercept
the messages and deal with them itself. */
-bfd_error_handler_type _bfd_error_handler = _bfd_default_error_handler;
+static bfd_error_handler_type _bfd_error_internal = error_handler_internal;
+
+void
+_bfd_error_handler (const char *fmt, ...)
+{
+ va_list ap;
+
+ va_start (ap, fmt);
+ _bfd_error_internal (fmt, ap);
+ va_end (ap);
+}
/*
FUNCTION
@@ -815,8 +822,8 @@ bfd_set_error_handler (bfd_error_handler_type pnew)
{
bfd_error_handler_type pold;
- pold = _bfd_error_handler;
- _bfd_error_handler = pnew;
+ pold = _bfd_error_internal;
+ _bfd_error_internal = pnew;
return pold;
}
@@ -841,23 +848,6 @@ bfd_set_error_program_name (const char *name)
}
/*
-FUNCTION
- bfd_get_error_handler
-
-SYNOPSIS
- bfd_error_handler_type bfd_get_error_handler (void);
-
-DESCRIPTION
- Return the BFD error handler function.
-*/
-
-bfd_error_handler_type
-bfd_get_error_handler (void)
-{
- return _bfd_error_handler;
-}
-
-/*
SUBSECTION
BFD assert handler
@@ -898,7 +888,7 @@ _bfd_default_assert_handler (const char *bfd_formatmsg,
internal BFD error. We use a non-variadic type to simplify passing
on parameters to other functions, e.g. _bfd_error_handler. */
-bfd_assert_handler_type _bfd_assert_handler = _bfd_default_assert_handler;
+static bfd_assert_handler_type _bfd_assert_handler = _bfd_default_assert_handler;
/*
FUNCTION
@@ -921,23 +911,6 @@ bfd_set_assert_handler (bfd_assert_handler_type pnew)
_bfd_assert_handler = pnew;
return pold;
}
-
-/*
-FUNCTION
- bfd_get_assert_handler
-
-SYNOPSIS
- bfd_assert_handler_type bfd_get_assert_handler (void);
-
-DESCRIPTION
- Return the BFD assert handler function.
-*/
-
-bfd_assert_handler_type
-bfd_get_assert_handler (void)
-{
- return _bfd_assert_handler;
-}
/*
INODE