Just have init_progfile_dir() take a void pointer.

dladdr() takes a void * as a code pointer; have init_progfile_dir() do
so, and do the casting in the calls.  We don't care about the signature
of the function whose address we're passing, we just want to pass a
pointer to *something* in the main program.

Change-Id: I9372620a97b0eb53c2bb3c0c41a238b4408f3709
Reviewed-on: https://code.wireshark.org/review/7270
Reviewed-by: Guy Harris <guy@alum.mit.edu>
This commit is contained in:
Guy Harris 2015-02-19 16:23:39 -08:00
parent ec6ec49941
commit 9423a13b2d
12 changed files with 14 additions and 15 deletions

View File

@ -1164,7 +1164,7 @@ main(int argc, char *argv[])
init_open_routines();
#ifdef HAVE_PLUGINS
if ((init_progfile_dir_error = init_progfile_dir(argv[0], main))) {
if ((init_progfile_dir_error = init_progfile_dir(argv[0], (void *)main))) {
g_warning("capinfos: init_progfile_dir(): %s", init_progfile_dir_error);
g_free(init_progfile_dir_error);
} else {

View File

@ -168,7 +168,7 @@ main(int argc, char *argv[])
init_open_routines();
#ifdef HAVE_PLUGINS
if ((init_progfile_dir_error = init_progfile_dir(argv[0], main))) {
if ((init_progfile_dir_error = init_progfile_dir(argv[0], (void *)main))) {
g_warning("captype: init_progfile_dir(): %s", init_progfile_dir_error);
g_free(init_progfile_dir_error);
} else {

View File

@ -70,7 +70,7 @@ main(int argc, char **argv)
/*
* Attempt to get the pathname of the executable file.
*/
init_progfile_dir_error = init_progfile_dir(argv[0], main);
init_progfile_dir_error = init_progfile_dir(argv[0], (void *)main);
if (init_progfile_dir_error != NULL) {
fprintf(stderr, "dftest: Can't get pathname of dftest program: %s.\n",
init_progfile_dir_error);

View File

@ -474,7 +474,7 @@ static void preinit_epan(char* argv0, int (*main)(int, char **)) {
int dp_open_errno, dp_read_errno;
char* error;
error = init_progfile_dir(argv0, main);
error = init_progfile_dir(argv0, (void *)main);
comp_info_str = get_compiled_version_info(NULL, epan_get_compiled_version_info);

View File

@ -944,7 +944,7 @@ main(int argc, char *argv[])
#ifdef HAVE_PLUGINS
/* Register wiretap plugins */
if ((init_progfile_dir_error = init_progfile_dir(argv[0], main))) {
if ((init_progfile_dir_error = init_progfile_dir(argv[0], (void *)main))) {
g_warning("editcap: init_progfile_dir(): %s", init_progfile_dir_error);
g_free(init_progfile_dir_error);
} else {

View File

@ -495,7 +495,7 @@ main(int argc, char *argv[])
/*
* Attempt to get the pathname of the executable file.
*/
init_progfile_dir_error = init_progfile_dir(argv[0], main);
init_progfile_dir_error = init_progfile_dir(argv[0], (void *)main);
if (init_progfile_dir_error != NULL) {
fprintf(stderr, "rawshark: Can't get pathname of rawshark program: %s.\n",
init_progfile_dir_error);

View File

@ -846,7 +846,7 @@ main(int argc, char *argv[])
/*
* Attempt to get the pathname of the executable file.
*/
init_progfile_dir_error = init_progfile_dir(argv[0], main);
init_progfile_dir_error = init_progfile_dir(argv[0], (void *)main);
if (init_progfile_dir_error != NULL) {
fprintf(stderr, "tfshark: Can't get pathname of tfshark program: %s.\n",
init_progfile_dir_error);

View File

@ -1047,7 +1047,7 @@ main(int argc, char *argv[])
/*
* Attempt to get the pathname of the executable file.
*/
init_progfile_dir_error = init_progfile_dir(argv[0], main);
init_progfile_dir_error = init_progfile_dir(argv[0], (void *)main);
if (init_progfile_dir_error != NULL) {
fprintf(stderr, "tshark: Can't get pathname of tshark program: %s.\n",
init_progfile_dir_error);

View File

@ -2207,7 +2207,7 @@ main(int argc, char *argv[])
/*
* Attempt to get the pathname of the executable file.
*/
init_progfile_dir_error = init_progfile_dir(argv[0], main);
init_progfile_dir_error = init_progfile_dir(argv[0], (void *)main);
/* initialize the funnel mini-api */
initialize_funnel_ops();

View File

@ -483,7 +483,7 @@ int main(int argc, char *argv[])
* Attempt to get the pathname of the executable file.
*/
/* init_progfile_dir_error = */ init_progfile_dir(argv[0],
(progfile_main_t) get_gui_compiled_info);
(void *) get_gui_compiled_info);
g_log(NULL, G_LOG_LEVEL_DEBUG, "progfile_dir: %s", get_progfile_dir());
/* Get the compile-time version information string */

View File

@ -479,7 +479,7 @@ init_progfile_dir(const char *arg0
#ifdef _WIN32
_U_
#endif
, progfile_main_t main_addr
, void *function_addr
#if defined(_WIN32) || !defined(HAVE_DLADDR)
_U_
#endif
@ -575,7 +575,7 @@ init_progfile_dir(const char *arg0
execname = get_executable_path();
#ifdef HAVE_DLADDR
if (main_addr != NULL && execname == NULL) {
if (function_addr != NULL && execname == NULL) {
/*
* Try to use dladdr() to find the pathname of the executable.
* dladdr() is not guaranteed to give you anything better than
@ -585,7 +585,7 @@ init_progfile_dir(const char *arg0
* path and obviate the need for us to determine the absolute
* path.
*/
if (dladdr((void *)main_addr, &info))
if (dladdr(function_addr, &info))
execname = info.dli_fname;
}
#endif

View File

@ -40,8 +40,7 @@ extern "C" {
* and save it for future use. Returns NULL on success, and a
* g_mallocated string containing an error on failure.
*/
typedef int (*progfile_main_t)(int, char **);
WS_DLL_PUBLIC char *init_progfile_dir(const char *arg0, progfile_main_t main_addr);
WS_DLL_PUBLIC char *init_progfile_dir(const char *arg0, void *function_addr);
/*
* Get the directory in which the program resides.