Make init_progfile_dir() take a function pointer [-Wpedantic]

Change-Id: I45f8ea5ee6ccc5a484c60ad6e686aaf30f6b0c98
Reviewed-on: https://code.wireshark.org/review/12557
Petri-Dish: Alexis La Goutte <alexis.lagoutte@gmail.com>
Tested-by: Petri Dish Buildbot <buildbot-no-reply@wireshark.org>
Reviewed-by: Guy Harris <guy@alum.mit.edu>
This commit is contained in:
João Valverde 2015-12-12 02:34:47 +00:00 committed by Guy Harris
parent d835b27167
commit fbf2e3cf8f
12 changed files with 17 additions and 13 deletions

View File

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

View File

@ -161,7 +161,7 @@ main(int argc, char *argv[])
init_open_routines();
#ifdef HAVE_PLUGINS
if ((init_progfile_dir_error = init_progfile_dir(argv[0], (void *)main))) {
if ((init_progfile_dir_error = init_progfile_dir(argv[0], 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], (void *)main);
init_progfile_dir_error = init_progfile_dir(argv[0], 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, (void *)main);
error = init_progfile_dir(argv0, main);
comp_info_str = get_compiled_version_info(NULL, epan_get_compiled_version_info);

View File

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

View File

@ -484,7 +484,7 @@ main(int argc, char *argv[])
/*
* Attempt to get the pathname of the executable file.
*/
init_progfile_dir_error = init_progfile_dir(argv[0], (void *)main);
init_progfile_dir_error = init_progfile_dir(argv[0], 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

@ -835,7 +835,7 @@ main(int argc, char *argv[])
/*
* Attempt to get the pathname of the executable file.
*/
init_progfile_dir_error = init_progfile_dir(argv[0], (void *)main);
init_progfile_dir_error = init_progfile_dir(argv[0], 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

@ -1059,7 +1059,7 @@ main(int argc, char *argv[])
/*
* Attempt to get the pathname of the executable file.
*/
init_progfile_dir_error = init_progfile_dir(argv[0], (void *)main);
init_progfile_dir_error = init_progfile_dir(argv[0], 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

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

View File

@ -518,7 +518,7 @@ int main(int argc, char *argv[])
* Attempt to get the pathname of the executable file.
*/
/* init_progfile_dir_error = */ init_progfile_dir(ws_argv[0],
(void *) get_gui_compiled_info);
(int (*)(int, char **)) get_gui_compiled_info);
g_log(NULL, G_LOG_LEVEL_DEBUG, "progfile_dir: %s", get_progfile_dir());
#ifdef _WIN32

View File

@ -62,6 +62,7 @@
#include <wsutil/report_err.h>
#include <wsutil/privileges.h>
#include <wsutil/file_util.h>
#include <wsutil/ws_diag_control.h>
#include <wiretap/wtap.h> /* for WTAP_ERR_SHORT_WRITE */
@ -454,7 +455,7 @@ init_progfile_dir(const char *arg0
#ifdef _WIN32
_U_
#endif
, void *function_addr
, int (*function_addr)(int, char **)
#if defined(_WIN32) || !defined(HAVE_DLADDR)
_U_
#endif
@ -560,8 +561,11 @@ init_progfile_dir(const char *arg0
* path and obviate the need for us to determine the absolute
* path.
*/
if (dladdr(function_addr, &info))
DIAG_OFF(pedantic)
if (dladdr((void *)function_addr, &info)) {
DIAG_ON(pedantic)
execname = info.dli_fname;
}
}
#endif
if (execname == NULL) {

View File

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