[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: less mixing of object and function pointers
From: |
Ralf Wildenhues |
Subject: |
Re: less mixing of object and function pointers |
Date: |
Wed, 30 Aug 2006 06:14:26 +0200 |
User-agent: |
Mutt/1.5.13 (2006-08-11) |
Hello Peter, Eric,
* Peter O'Gorman wrote on Wed, Aug 30, 2006 at 12:17:20AM CEST:
> >From: Ralf Wildenhues
> >>
> >>OK to apply? Tested on GNU/Linux, where libltdl now passes
> >> make CFLAGS='-W -Wall -Werror'
> I think it is okay also, however, doesn't it require a documentation
> update too? (not that I've checked, it just seems likely). :-)
Ouch, I didn't intend to break a public interface. Thanks for the
reminder. I think I want to redo this part of the change to not break
the interface (the new one seems less generic than the old one with the
signature of callback_helper_func being rather arbitrary).
For now I've just applied the less problematic parts to add LT__UNUSED,
as follows. Thanks for the reviews!
Cheers,
Ralf
* libltdl/libltdl/lt__private.h (__attribute__, LT__UNUSED):
New macros.
* libltdl/loaders/dld_link.c: Use LT__UNUSED where
appropriate.
* libltdl/loaders/dlopen.c, libltdl/loaders/load_add_on.c,
libltdl/loaders/loadlibrary.c, libltdl/loaders/preopen.c,
libltdl/loaders/shl_load.c: Likewise.
* libltdl/ltdl.c: Likewise.
(find_file_callback): Fix declaration names to match definition.
(load_deplibs) [!LTDL_DLOPEN_DEPLIBS]: Use separate definition
for less preprocessor clutter.
Index: libltdl/ltdl.c
===================================================================
RCS file: /cvsroot/libtool/libtool/libltdl/ltdl.c,v
retrieving revision 1.240
diff -u -r1.240 ltdl.c
--- libltdl/ltdl.c 22 Jul 2006 20:34:06 -0000 1.240
+++ libltdl/ltdl.c 30 Aug 2006 04:08:44 -0000
@@ -92,8 +92,8 @@
foreach_callback_func *func,
void *data1, void *data2);
-static int find_file_callback (char *filename, void *data,
- void *ignored);
+static int find_file_callback (char *filename, void *data1,
+ void *data2);
static int find_handle_callback (char *filename, void *data,
void *ignored);
static int foreachfile_callback (char *filename, void *data1,
@@ -684,7 +684,7 @@
}
static int
-find_handle_callback (char *filename, void *data, void *ignored)
+find_handle_callback (char *filename, void *data, void *ignored LT__UNUSED)
{
lt_dlhandle *handle = (lt_dlhandle *) data;
int notfound = access (filename, R_OK);
@@ -717,20 +717,26 @@
return handle;
}
+#if !defined(LTDL_DLOPEN_DEPLIBS)
+static int
+load_deplibs (lt_dlhandle handle, char *deplibs LT__UNUSED)
+{
+ ((lt__handle *) handle)->depcount = 0;
+ return 0;
+}
+
+#else /* defined(LTDL_DLOPEN_DEPLIBS) */
static int
load_deplibs (lt_dlhandle handle, char *deplibs)
{
-#if defined(LTDL_DLOPEN_DEPLIBS)
char *p, *save_search_path = 0;
int depcount = 0;
int i;
char **names = 0;
-#endif
int errors = 0;
((lt__handle *) handle)->depcount = 0;
-#if defined(LTDL_DLOPEN_DEPLIBS)
if (!deplibs)
{
return errors;
@@ -871,10 +877,10 @@
if (save_search_path) {
MEMREASSIGN (user_search_path, save_search_path);
}
-#endif
return errors;
}
+#endif /* defined(LTDL_DLOPEN_DEPLIBS) */
static int
unload_deplibs (lt_dlhandle handle)
Index: libltdl/libltdl/lt__private.h
===================================================================
RCS file: /cvsroot/libtool/libtool/libltdl/libltdl/lt__private.h,v
retrieving revision 1.8
diff -u -r1.8 lt__private.h
--- libltdl/libltdl/lt__private.h 28 Aug 2006 16:02:14 -0000 1.8
+++ libltdl/libltdl/lt__private.h 30 Aug 2006 04:08:46 -0000
@@ -77,6 +77,16 @@
# define LT_GLOBAL_DATA
#endif
+#ifndef __attribute__
+# if __GNUC__ < 2 || (__GNUC__ == 2 && __GNUC_MINOR__ < 8) || __STRICT_ANSI__
+# define __attribute__(x)
+# endif
+#endif
+
+#ifndef LT__UNUSED
+# define LT__UNUSED __attribute__ ((__unused__))
+#endif
+
LT_BEGIN_C_DECLS
cvs diff: Diffing libltdl/loaders
Index: libltdl/loaders/dld_link.c
===================================================================
RCS file: /cvsroot/libtool/libtool/libltdl/loaders/dld_link.c,v
retrieving revision 1.4
diff -u -r1.4 dld_link.c
--- libltdl/loaders/dld_link.c 22 Apr 2005 10:10:30 -0000 1.4
+++ libltdl/loaders/dld_link.c 30 Aug 2006 04:08:47 -0000
@@ -1,5 +1,5 @@
/* loader-dld_link.c -- dynamic linking with dld
- Copyright (C) 1998, 1999, 2000, 2004 Free Software Foundation, Inc.
+ Copyright (C) 1998, 1999, 2000, 2004, 2006 Free Software Foundation, Inc.
Originally by Thomas Tanner <address@hidden>
NOTE: The canonical source of this file is maintained with the
@@ -91,7 +91,7 @@
loader. Returns an opaque representation of the newly opened
module for processing with this loader's other vtable functions. */
static lt_module
-vm_open (lt_user_data loader_data, const char *filename)
+vm_open (lt_user_data loader_data LT__UNUSED, const char *filename)
{
lt_module module = lt__strdup (filename);
@@ -107,7 +107,7 @@
/* A function called through the vtable when a particular module
should be unloaded. */
static int
-vm_close (lt_user_data loader_data, lt_module module)
+vm_close (lt_user_data loader_data LT__UNUSED, lt_module module)
{
int errors = 0;
@@ -127,7 +127,8 @@
/* A function called through the vtable to get the address of
a symbol loaded from a particular module. */
static void *
-vm_sym (lt_user_data loader_data, lt_module module, const char *name)
+vm_sym (lt_user_data loader_data LT__UNUSED, lt_module module LT__UNUSED,
+ const char *name)
{
void *address = dld_get_func (name);
Index: libltdl/loaders/dlopen.c
===================================================================
RCS file: /cvsroot/libtool/libtool/libltdl/loaders/dlopen.c,v
retrieving revision 1.5
diff -u -r1.5 dlopen.c
--- libltdl/loaders/dlopen.c 22 Apr 2005 10:10:30 -0000 1.5
+++ libltdl/loaders/dlopen.c 30 Aug 2006 04:08:47 -0000
@@ -1,5 +1,5 @@
/* loader-dlopen.c -- dynamic linking with dlopen/dlsym
- Copyright (C) 1998, 1999, 2000, 2004 Free Software Foundation, Inc.
+ Copyright (C) 1998, 1999, 2000, 2004, 2006 Free Software Foundation, Inc.
Originally by Thomas Tanner <address@hidden>
NOTE: The canonical source of this file is maintained with the
@@ -132,7 +132,7 @@
loader. Returns an opaque representation of the newly opened
module for processing with this loader's other vtable functions. */
static lt_module
-vm_open (lt_user_data loader_data, const char *filename)
+vm_open (lt_user_data loader_data LT__UNUSED, const char *filename)
{
lt_module module = dlopen (filename, LT_LAZY_OR_NOW);
@@ -148,7 +148,7 @@
/* A function called through the vtable when a particular module
should be unloaded. */
static int
-vm_close (lt_user_data loader_data, lt_module module)
+vm_close (lt_user_data loader_data LT__UNUSED, lt_module module)
{
int errors = 0;
@@ -165,7 +165,7 @@
/* A function called through the vtable to get the address of
a symbol loaded from a particular module. */
static void *
-vm_sym (lt_user_data loader_data, lt_module module, const char *name)
+vm_sym (lt_user_data loader_data LT__UNUSED, lt_module module, const char
*name)
{
void *address = dlsym (module, name);
Index: libltdl/loaders/load_add_on.c
===================================================================
RCS file: /cvsroot/libtool/libtool/libltdl/loaders/load_add_on.c,v
retrieving revision 1.4
diff -u -r1.4 load_add_on.c
--- libltdl/loaders/load_add_on.c 22 Apr 2005 10:10:30 -0000 1.4
+++ libltdl/loaders/load_add_on.c 30 Aug 2006 04:08:47 -0000
@@ -1,5 +1,5 @@
/* loader-load_add_on.c -- dynamic linking for BeOS
- Copyright (C) 1998, 1999, 2000, 2004 Free Software Foundation, Inc.
+ Copyright (C) 1998, 1999, 2000, 2004, 2006 Free Software Foundation, Inc.
Originally by Thomas Tanner <address@hidden>
NOTE: The canonical source of this file is maintained with the
@@ -89,7 +89,7 @@
loader. Returns an opaque representation of the newly opened
module for processing with this loader's other vtable functions. */
static lt_module
-vm_open (lt_user_data loader_data, const char *filename)
+vm_open (lt_user_data loader_data LT__UNUSED, const char *filename)
{
image_id image = 0;
@@ -118,7 +118,7 @@
/* A function called through the vtable when a particular module
should be unloaded. */
static int
-vm_close (lt_user_data loader_data, lt_module module)
+vm_close (lt_user_data loader_data LT__UNUSED, lt_module module)
{
int errors = 0;
@@ -135,7 +135,7 @@
/* A function called through the vtable to get the address of
a symbol loaded from a particular module. */
static void *
-vm_sym (lt_user_data loader_data, lt_module module, const char *name)
+vm_sym (lt_user_data loader_data LT__UNUSED, lt_module module, const char
*name)
{
void *address = 0;
image_id image = (image_id) module;
Index: libltdl/loaders/loadlibrary.c
===================================================================
RCS file: /cvsroot/libtool/libtool/libltdl/loaders/loadlibrary.c,v
retrieving revision 1.10
diff -u -r1.10 loadlibrary.c
--- libltdl/loaders/loadlibrary.c 25 Nov 2005 18:44:43 -0000 1.10
+++ libltdl/loaders/loadlibrary.c 30 Aug 2006 04:08:47 -0000
@@ -96,7 +96,7 @@
loader. Returns an opaque representation of the newly opened
module for processing with this loader's other vtable functions. */
static lt_module
-vm_open (lt_user_data loader_data, const char *filename)
+vm_open (lt_user_data loader_data LT__UNUSED, const char *filename)
{
lt_module module = 0;
char *ext;
@@ -198,7 +198,7 @@
/* A function called through the vtable when a particular module
should be unloaded. */
static int
-vm_close (lt_user_data loader_data, lt_module module)
+vm_close (lt_user_data loader_data LT__UNUSED, lt_module module)
{
int errors = 0;
@@ -215,7 +215,7 @@
/* A function called through the vtable to get the address of
a symbol loaded from a particular module. */
static void *
-vm_sym (lt_user_data loader_data, lt_module module, const char *name)
+vm_sym (lt_user_data loader_data LT__UNUSED, lt_module module, const char
*name)
{
void *address = GetProcAddress (module, name);
Index: libltdl/loaders/preopen.c
===================================================================
RCS file: /cvsroot/libtool/libtool/libltdl/loaders/preopen.c,v
retrieving revision 1.8
diff -u -r1.8 preopen.c
--- libltdl/loaders/preopen.c 3 Apr 2006 13:54:35 -0000 1.8
+++ libltdl/loaders/preopen.c 30 Aug 2006 04:08:47 -0000
@@ -1,5 +1,5 @@
/* loader-preopen.c -- emulate dynamic linking using preloaded_symbols
- Copyright (C) 1998, 1999, 2000, 2004 Free Software Foundation, Inc.
+ Copyright (C) 1998, 1999, 2000, 2004, 2006 Free Software Foundation, Inc.
Originally by Thomas Tanner <address@hidden>
NOTE: The canonical source of this file is maintained with the
@@ -108,7 +108,7 @@
/* A function called through the vtable to initialise this loader. */
static int
-vl_init (lt_user_data loader_data)
+vl_init (lt_user_data loader_data LT__UNUSED)
{
int errors = 0;
@@ -125,7 +125,7 @@
/* A function called through the vtable when this loader is no
longer needed by the application. */
static int
-vl_exit (lt_user_data loader_data)
+vl_exit (lt_user_data loader_data LT__UNUSED)
{
free_symlists ();
return 0;
@@ -136,7 +136,7 @@
loader. Returns an opaque representation of the newly opened
module for processing with this loader's other vtable functions. */
static lt_module
-vm_open (lt_user_data loader_data, const char *filename)
+vm_open (lt_user_data loader_data LT__UNUSED, const char *filename)
{
symlist_chain *lists;
lt_module module = 0;
@@ -188,7 +188,7 @@
/* A function called through the vtable when a particular module
should be unloaded. */
static int
-vm_close (lt_user_data loader_data, lt_module module)
+vm_close (lt_user_data loader_data LT__UNUSED, lt_module module)
{
/* Just to silence gcc -Wall */
module = 0;
@@ -199,7 +199,7 @@
/* A function called through the vtable to get the address of
a symbol loaded from a particular module. */
static void *
-vm_sym (lt_user_data loader_data, lt_module module, const char *name)
+vm_sym (lt_user_data loader_data LT__UNUSED, lt_module module, const char
*name)
{
lt_dlsymlist *symbol = (lt_dlsymlist*) module;
Index: libltdl/loaders/shl_load.c
===================================================================
RCS file: /cvsroot/libtool/libtool/libltdl/loaders/shl_load.c,v
retrieving revision 1.5
diff -u -r1.5 shl_load.c
--- libltdl/loaders/shl_load.c 22 Apr 2005 10:10:30 -0000 1.5
+++ libltdl/loaders/shl_load.c 30 Aug 2006 04:08:47 -0000
@@ -1,5 +1,5 @@
/* loader-shl_load.c -- dynamic linking with shl_load (HP-UX)
- Copyright (C) 1998, 1999, 2000, 2004 Free Software Foundation, Inc.
+ Copyright (C) 1998, 1999, 2000, 2004, 2006 Free Software Foundation, Inc.
Originally by Thomas Tanner <address@hidden>
NOTE: The canonical source of this file is maintained with the
@@ -132,7 +132,7 @@
loader. Returns an opaque representation of the newly opened
module for processing with this loader's other vtable functions. */
static lt_module
-vm_open (lt_user_data loader_data, const char *filename)
+vm_open (lt_user_data loader_data LT__UNUSED, const char *filename)
{
static shl_t self = (shl_t) 0;
lt_module module = shl_load (filename, LT_BIND_FLAGS, 0L);
@@ -167,7 +167,7 @@
/* A function called through the vtable when a particular module
should be unloaded. */
static int
-vm_close (lt_user_data loader_data, lt_module module)
+vm_close (lt_user_data loader_data LT__UNUSED, lt_module module)
{
int errors = 0;
@@ -184,7 +184,7 @@
/* A function called through the vtable to get the address of
a symbol loaded from a particular module. */
static void *
-vm_sym (lt_user_data loader_data, lt_module module, const char *name)
+vm_sym (lt_user_data loader_data LT__UNUSED, lt_module module, const char
*name)
{
void *address = 0;