From bd77216edfa6e36cc332554c01d778c022caae8c Mon Sep 17 00:00:00 2001 From: Christophe CURIS Date: Sun, 13 Oct 2013 22:44:12 +0200 Subject: [PATCH] wmaker: Removed explicit callback type conversion It is dangerous to use a function that does not use the same prototype as expected by the callback, because that mean there is conversion performed for the arguments, on which the compiler has no possibility to report problems. It is safer to create the function with the strict argument list, and insert an explicit type conversion for which the compiler will be able to perform compatibility checks, and include optional code when needed. Signed-off-by: Christophe CURIS --- src/defaults.c | 6 ++++-- src/main.c | 8 +++++--- 2 files changed, 9 insertions(+), 5 deletions(-) diff --git a/src/defaults.c b/src/defaults.c index 13679745..9b490ecb 100644 --- a/src/defaults.c +++ b/src/defaults.c @@ -2899,8 +2899,10 @@ static int setFrameSelectedBorderColor(WScreen * scr, WDefaultEntry * entry, voi return REFRESH_FRAME_BORDER; } -static void trackDeadProcess(pid_t pid, unsigned char status, WScreen * scr) +static void trackDeadProcess(pid_t pid, unsigned int status, void *client_data) { + WScreen *scr = (WScreen *) client_data; + close(scr->helper_fd); scr->helper_fd = 0; scr->helper_pid = 0; @@ -2978,7 +2980,7 @@ static int setWorkspaceSpecificBack(WScreen * scr, WDefaultEntry * entry, void * scr->helper_pid = pid; scr->flags.backimage_helper_launched = 1; - wAddDeathHandler(pid, (WDeathHandler *) trackDeadProcess, scr); + wAddDeathHandler(pid, trackDeadProcess, scr); SendHelperMessage(scr, 'P', -1, wPreferences.pixmap_path); } diff --git a/src/main.c b/src/main.c index ab738abe..ae89eff4 100644 --- a/src/main.c +++ b/src/main.c @@ -261,8 +261,10 @@ typedef struct { char *command; } _tuple; -static void shellCommandHandler(pid_t pid, unsigned char status, _tuple * data) +static void shellCommandHandler(pid_t pid, unsigned int status, void *client_data) { + _tuple *data = (_tuple *) client_data; + if (status == 127) { char *buffer; @@ -317,7 +319,7 @@ void ExecuteShellCommand(WScreen *scr, const char *command) data->scr = scr; data->command = wstrdup(command); - wAddDeathHandler(pid, (WDeathHandler *) shellCommandHandler, data); + wAddDeathHandler(pid, shellCommandHandler, data); } } @@ -376,7 +378,7 @@ Bool RelaunchWindow(WWindow *wwin) data->command = wtokenjoin(argv, argc); /* not actually a shell command */ - wAddDeathHandler(pid, (WDeathHandler *) shellCommandHandler, data); + wAddDeathHandler(pid, shellCommandHandler, data); XFreeStringList(argv); }