Mirror of the gdb-patches mailing list
 help / color / mirror / Atom feed
* Likely incorrect patch: remove the faulty basename() prototype from libiberty
@ 2016-05-29 14:58 Ed Schouten
  2016-05-29 16:32 ` DJ Delorie
  0 siblings, 1 reply; 8+ messages in thread
From: Ed Schouten @ 2016-05-29 14:58 UTC (permalink / raw)
  To: gdb-patches

Hi there,

Libiberty has the prototype of basename() declared in its libiberty.h.
Unfortunately, it has it declared with a different prototype as
standardized by POSIX. POSIX requires that its argument is of type
"char *', while the one in libiberty.h uses "char *". Normally this
problem is not exposed at all, because none of the GDB code includes
the header file with the actual prototype (libgen.h).

I'm currently working on patching up FreeBSD to also use the prototype
as standardized by POSIX, as opposed to the BSD-specific one that has
"const char *'. In FreeBSD we have some utilities built against GDB
(e.g., our kernel debugger kgdb) that ends up including both
libiberty.h and libgen.h. meaning we get compiler errors due to
different declarations for the same function.

For now I'm solving this by simply patching up libiberty to pull in
the declaration from libgen.h. This seems to make everything build
again.

diff --git a/include/libiberty.h b/include/libiberty.h
index 8e096a0..403e690 100644
--- a/include/libiberty.h
+++ b/include/libiberty.h
@@ -109,7 +109,7 @@ extern int countargv (char**);
  || defined (__FreeBSD__) || defined (__OpenBSD__) || defined (__NetBSD__) \
  || defined (__CYGWIN__) || defined (__CYGWIN32__) || defined (__MINGW32__) \
  || defined (__DragonFly__) || defined (HAVE_DECL_BASENAME)
-extern char *basename (const char *) ATTRIBUTE_RETURNS_NONNULL
ATTRIBUTE_NONNULL(1);
+#include <libgen.h>
 #else
 /* Do not allow basename to be used if there is no prototype seen.  We
    either need to use the above prototype or have one from

I guess that this is not the right way of solving this. I'd guess that
we should just remove all of the basename() specific bits from all of
libiberty and just include libgen.h in the source files that actually
need it.

What do you folks think?

-- 
Ed Schouten <ed@nuxi.nl>
Nuxi, 's-Hertogenbosch, the Netherlands
KvK-nr.: 62051717


^ permalink raw reply	[flat|nested] 8+ messages in thread

end of thread, other threads:[~2016-06-03  9:37 UTC | newest]

Thread overview: 8+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2016-05-29 14:58 Likely incorrect patch: remove the faulty basename() prototype from libiberty Ed Schouten
2016-05-29 16:32 ` DJ Delorie
2016-05-29 16:36   ` Ed Schouten
2016-05-29 17:06     ` DJ Delorie
2016-05-29 17:24       ` Ed Schouten
2016-05-29 17:35         ` DJ Delorie
2016-06-02 21:27       ` Joseph Myers
2016-06-03  9:37         ` Ed Schouten

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox