From bab90b216889763f55e0dd155deb7895a507fee2 Mon Sep 17 00:00:00 2001 From: Christophe CURIS Date: Sun, 12 May 2013 00:24:45 +0200 Subject: [PATCH] WINGs: Added explicit parameter list to function prototypes (Complex case) It is dangerous to let the compiler know about a function without letting him know the arguments because he won't be able to report invalid calls. This patch concern the cases where adding the arguments led to problems because the functions were used as call-back. As it is dangerous to have parameter mismatchs in call-back, setup the args as expected by prototype and added explicit conversion inside the concerned function, so the compiler will know and be able to do what may be necessary. --- WINGs/wfilepanel.c | 47 ++++++++++++++++++++++++++--------------------- 1 file changed, 26 insertions(+), 21 deletions(-) diff --git a/WINGs/wfilepanel.c b/WINGs/wfilepanel.c index 3eb04f83..56fdda51 100644 --- a/WINGs/wfilepanel.c +++ b/WINGs/wfilepanel.c @@ -63,24 +63,19 @@ typedef struct W_FilePanel { #define PHEIGHT 360 static void listDirectoryOnColumn(WMFilePanel * panel, int column, const char *path); -static void browserClick(); -static void browserDClick(); +static void browserClick(WMWidget *widget, void *p_panel); +static void browserDClick(WMWidget *widget, void *p_panel); static void fillColumn(WMBrowserDelegate * self, WMBrowser * bPtr, int column, WMList * list); static void normalizePath(char *s); -static void deleteFile(); - -static void createDir(); - -static void goHome(); - -static void goFloppy(); - -static void goUnmount(); - -static void buttonClick(); +static void deleteFile(WMWidget *widget, void *p_panel); +static void createDir(WMWidget *widget, void *p_panel); +static void goHome(WMWidget *widget, void *p_panel); +static void goFloppy(WMWidget *widget, void *p_panel); +static void goUnmount(WMWidget *widget, void *p_panel); +static void buttonClick(WMWidget *widget, void *p_panel); static char *getCurrentFileName(WMFilePanel * panel); @@ -567,13 +562,17 @@ static void fillColumn(WMBrowserDelegate * self, WMBrowser * bPtr, int column, W wfree(path); } -static void browserDClick(WMBrowser * bPtr, WMFilePanel * panel) +static void browserDClick(WMWidget *widget, void *p_panel) { + WMFilePanel *panel = p_panel; + WMPerformButtonClick(panel->okButton); } -static void browserClick(WMBrowser * bPtr, WMFilePanel * panel) +static void browserClick(WMWidget *widget, void *p_panel) { + WMBrowser *bPtr = (WMBrowser *) widget; + WMFilePanel *panel = p_panel; int col = WMGetBrowserSelectedColumn(bPtr); WMListItem *item = WMGetBrowserSelectedItemInColumn(bPtr, col); @@ -598,8 +597,9 @@ static void showError(WMScreen * scr, WMWindow * owner, const char *s, const cha wfree(errStr); } -static void createDir(WMButton * bPre, WMFilePanel * panel) +static void createDir(WMWidget *widget, void *p_panel) { + WMFilePanel *panel = p_panel; char *dirName, *directory, *file; size_t slen; WMScreen *scr = WMWidgetScreen(panel->win); @@ -680,8 +680,9 @@ static void normalizePath(char *s) } -static void deleteFile(WMButton * bPre, WMFilePanel * panel) +static void deleteFile(WMWidget *widget, void *p_panel) { + WMFilePanel *panel = p_panel; char *file, *buffer; struct stat filestat; WMScreen *scr = WMWidgetScreen(panel->win); @@ -722,12 +723,13 @@ out: #undef __msgbufsize__ } -static void goUnmount(WMButton * bPtr, WMFilePanel * panel) +static void goUnmount(WMWidget *widget, void *p_panel) { } -static void goFloppy(WMButton * bPtr, WMFilePanel * panel) +static void goFloppy(WMWidget *widget, void *p_panel) { + WMFilePanel *panel = p_panel; struct stat filestat; WMScreen *scr = WMWidgetScreen(panel->win); @@ -742,8 +744,9 @@ static void goFloppy(WMButton * bPtr, WMFilePanel * panel) WMSetFilePanelDirectory(panel, WINGsConfiguration.floppyPath); } -static void goHome(WMButton * bPtr, WMFilePanel * panel) +static void goHome(WMWidget *widget, void *p_panel) { + WMFilePanel *panel = p_panel; char *home; /* home is statically allocated. Don't free it! */ @@ -854,8 +857,10 @@ static Bool validOpenFile(WMFilePanel * panel) return True; } -static void buttonClick(WMButton * bPtr, WMFilePanel * panel) +static void buttonClick(WMWidget *widget, void *p_panel) { + WMButton *bPtr = (WMButton *) widget; + WMFilePanel *panel = p_panel; WMRange range; if (bPtr == panel->okButton) { -- 2.11.4.GIT