[RFC,01/11] libdwfl: Fix debuginfod_client redefinition
Commit Message
clang complains:
In file included from debuginfod-client.c:38:
./../debuginfod/debuginfod.h:47:34: error: redefinition of typedef 'debuginfod_client' is a C11 feature [-Werror,-Wtypedef-redefinition]
typedef struct debuginfod_client debuginfod_client;
^
./libdwfl.h:53:34: note: previous definition is here
typedef struct debuginfod_client debuginfod_client;
^
config/eu.am specifies -std=gnu99, and upgrading just for this is an
overkill. So is #including "debuginfod.h", since we don't know if users
even have it. So fix by using "struct debuginfod_client" instead. This
may break the clients that use dwfl_get_debuginfod_client() without
#including "debuginfod.h", but such cases should be rare.
Signed-off-by: Ilya Leoshkevich <iii@linux.ibm.com>
---
libdwfl/debuginfod-client.c | 2 +-
libdwfl/libdwfl.h | 5 +----
libdwfl/libdwflP.h | 4 ++--
3 files changed, 4 insertions(+), 7 deletions(-)
Comments
Hi Ilyam
On Mon, Feb 06, 2023 at 11:25:03PM +0100, Ilya Leoshkevich via Elfutils-devel wrote:
> clang complains:
>
> In file included from debuginfod-client.c:38:
> ./../debuginfod/debuginfod.h:47:34: error: redefinition of typedef 'debuginfod_client' is a C11 feature [-Werror,-Wtypedef-redefinition]
> typedef struct debuginfod_client debuginfod_client;
> ^
> ./libdwfl.h:53:34: note: previous definition is here
> typedef struct debuginfod_client debuginfod_client;
> ^
>
> config/eu.am specifies -std=gnu99, and upgrading just for this is an
> overkill. So is #including "debuginfod.h", since we don't know if users
> even have it. So fix by using "struct debuginfod_client" instead. This
> may break the clients that use dwfl_get_debuginfod_client() without
> #including "debuginfod.h", but such cases should be rare.
This was recently reported by someone else and fixed differently:
commit 45576ab5f24cd39669a418fa8e005b4d04f8e9ca
Author: Mark Wielaard <mark@klomp.org>
Date: Mon Feb 6 10:21:58 2023 +0100
debuginfod: Make sure there is only one typedef for debuginfod_client
Both debuginfod.h and libdwfl.h have a simple typedef for struct
debuginfod_client. Some compilers pedantically warn when including
both headers that such typedefs are only officially supported in
C11. So guard them with _ELFUTILS_DEBUGINFOD_CLIENT_TYPEDEF to
make them happy.
https://sourceware.org/bugzilla/show_bug.cgi?id=30077
Signed-off-by: Mark Wielaard <mark@klomp.org>
Does that work for you?
Thanks,
Mark
On Tue, 2023-02-07 at 20:22 +0100, Mark Wielaard wrote:
> Hi Ilyam
>
> On Mon, Feb 06, 2023 at 11:25:03PM +0100, Ilya Leoshkevich via
> Elfutils-devel wrote:
> > clang complains:
> >
> > In file included from debuginfod-client.c:38:
> > ./../debuginfod/debuginfod.h:47:34: error: redefinition of
> > typedef 'debuginfod_client' is a C11 feature [-Werror,-Wtypedef-
> > redefinition]
> > typedef struct debuginfod_client debuginfod_client;
> > ^
> > ./libdwfl.h:53:34: note: previous definition is here
> > typedef struct debuginfod_client debuginfod_client;
> > ^
> >
> > config/eu.am specifies -std=gnu99, and upgrading just for this is
> > an
> > overkill. So is #including "debuginfod.h", since we don't know if
> > users
> > even have it. So fix by using "struct debuginfod_client" instead.
> > This
> > may break the clients that use dwfl_get_debuginfod_client() without
> > #including "debuginfod.h", but such cases should be rare.
>
> This was recently reported by someone else and fixed differently:
>
> commit 45576ab5f24cd39669a418fa8e005b4d04f8e9ca
> Author: Mark Wielaard <mark@klomp.org>
> Date: Mon Feb 6 10:21:58 2023 +0100
>
> debuginfod: Make sure there is only one typedef for
> debuginfod_client
>
> Both debuginfod.h and libdwfl.h have a simple typedef for struct
> debuginfod_client. Some compilers pedantically warn when
> including
> both headers that such typedefs are only officially supported in
> C11. So guard them with _ELFUTILS_DEBUGINFOD_CLIENT_TYPEDEF to
> make them happy.
>
> https://sourceware.org/bugzilla/show_bug.cgi?id=30077
>
> Signed-off-by: Mark Wielaard <mark@klomp.org>
>
> Does that work for you?
>
> Thanks,
>
> Mark
Thanks, this works. This patch can be dropped.
@@ -143,7 +143,7 @@ __libdwfl_debuginfod_init (void)
#else // ENABLE_LIBDEBUGINFOD
-debuginfod_client *
+struct debuginfod_client *
dwfl_get_debuginfod_client (Dwfl *dummy __attribute__ ((unused)))
{
return NULL;
@@ -49,9 +49,6 @@ typedef struct Dwfl_Thread Dwfl_Thread;
PC location described by an FDE belonging to Dwfl_Thread. */
typedef struct Dwfl_Frame Dwfl_Frame;
-/* Handle for debuginfod-client connection. */
-typedef struct debuginfod_client debuginfod_client;
-
/* Callbacks. */
typedef struct
{
@@ -813,7 +810,7 @@ int dwfl_frame_reg (Dwfl_Frame *state, unsigned regno, Dwarf_Word *val)
first call to this function. If elfutils is compiled without support for debuginfod,
NULL will be returned.
*/
-extern debuginfod_client *dwfl_get_debuginfod_client (Dwfl *dwfl);
+extern struct debuginfod_client *dwfl_get_debuginfod_client (Dwfl *dwfl);
#ifdef __cplusplus
}
@@ -114,7 +114,7 @@ struct Dwfl
{
const Dwfl_Callbacks *callbacks;
#ifdef ENABLE_LIBDEBUGINFOD
- debuginfod_client *debuginfod;
+ struct debuginfod_client *debuginfod;
#endif
Dwfl_Module *modulelist; /* List in order used by full traversals. */
@@ -652,7 +652,7 @@ __libdwfl_debuginfod_find_debuginfo (Dwfl *dwfl,
const unsigned char *build_id_bits,
size_t build_id_len);
void
-__libdwfl_debuginfod_end (debuginfod_client *c);
+__libdwfl_debuginfod_end (struct debuginfod_client *c);
#endif