From 9423a13b2db427d15f6b3d11b73624fffc02608f Mon Sep 17 00:00:00 2001 From: Guy Harris Date: Thu, 19 Feb 2015 16:23:39 -0800 Subject: [PATCH] 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 --- capinfos.c | 2 +- captype.c | 2 +- dftest.c | 2 +- echld/dispatcher.c | 2 +- editcap.c | 2 +- rawshark.c | 2 +- tfshark.c | 2 +- tshark.c | 2 +- ui/gtk/main.c | 2 +- wireshark-qt.cpp | 2 +- wsutil/filesystem.c | 6 +++--- wsutil/filesystem.h | 3 +-- 12 files changed, 14 insertions(+), 15 deletions(-) diff --git a/capinfos.c b/capinfos.c index 083a010a09..555dfff312 100644 --- a/capinfos.c +++ b/capinfos.c @@ -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 { diff --git a/captype.c b/captype.c index 53c8f08e93..1dc853b445 100644 --- a/captype.c +++ b/captype.c @@ -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 { diff --git a/dftest.c b/dftest.c index 9945d3632a..c721afcdd0 100644 --- a/dftest.c +++ b/dftest.c @@ -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); diff --git a/echld/dispatcher.c b/echld/dispatcher.c index b18261b701..21f0957312 100644 --- a/echld/dispatcher.c +++ b/echld/dispatcher.c @@ -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); diff --git a/editcap.c b/editcap.c index cd42dfbf21..bd7a71abe3 100644 --- a/editcap.c +++ b/editcap.c @@ -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 { diff --git a/rawshark.c b/rawshark.c index 41fce66ecf..f75f9abb5b 100644 --- a/rawshark.c +++ b/rawshark.c @@ -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); diff --git a/tfshark.c b/tfshark.c index bbf245a6f1..d87f6e3aba 100644 --- a/tfshark.c +++ b/tfshark.c @@ -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); diff --git a/tshark.c b/tshark.c index 8c3b935663..ffbb30343f 100644 --- a/tshark.c +++ b/tshark.c @@ -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); diff --git a/ui/gtk/main.c b/ui/gtk/main.c index e10150f03a..f404c9d8d3 100644 --- a/ui/gtk/main.c +++ b/ui/gtk/main.c @@ -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(); diff --git a/wireshark-qt.cpp b/wireshark-qt.cpp index 30a1bce60f..e6ee76f54c 100644 --- a/wireshark-qt.cpp +++ b/wireshark-qt.cpp @@ -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 */ diff --git a/wsutil/filesystem.c b/wsutil/filesystem.c index c34b95a02b..85bd7ebfd4 100644 --- a/wsutil/filesystem.c +++ b/wsutil/filesystem.c @@ -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 diff --git a/wsutil/filesystem.h b/wsutil/filesystem.h index b8b1d3f433..03d2877e65 100644 --- a/wsutil/filesystem.h +++ b/wsutil/filesystem.h @@ -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.