From: Christophe CURIS <[email protected]>

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 <[email protected]>
---
 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 f500e82..a6fb974 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 ab738ab..ae89eff 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);
        }
-- 
1.8.4.rc3


-- 
To unsubscribe, send mail to [email protected].

Reply via email to