1
0
mirror of https://github.com/gryf/wmaker.git synced 2025-12-18 03:50:30 +01:00

WINGs: Removed cast to change function prototype

When a function is used as a call-back, it is dangerous to have
arguments with a type different than what is expected by the
call-back definition.

This patch sets the argument list to match what is expected by
the call-back prototype and inserts an explicit type conversion
at the beginning of the function.
This commit is contained in:
Christophe CURIS
2013-05-12 00:24:46 +02:00
committed by Carlos R. Mafra
parent bab90b2168
commit e2d816c7a2
5 changed files with 26 additions and 21 deletions

View File

@@ -35,8 +35,9 @@ typedef struct W_HashTable {
#define RELKEY(table, key) if ((table)->callbacks.releaseKey) \
(*(table)->callbacks.releaseKey)(key)
static inline unsigned hashString(const char *key)
static inline unsigned hashString(const void *param)
{
const char *key = param;
unsigned ret = 0;
unsigned ctr = 0;
@@ -400,13 +401,14 @@ Bool WMNextHashEnumeratorItemAndKey(WMHashEnumerator * enumerator, void **item,
return False;
}
static Bool compareStrings(const char *key1, const char *key2)
static Bool compareStrings(const void *param1, const void *param2)
{
const char *key1 = param1;
const char *key2 = param2;
return strcmp(key1, key2) == 0;
}
typedef unsigned (*hashFunc) (const void *);
typedef Bool(*isEqualFunc) (const void *, const void *);
typedef void *(*retainFunc) (const void *);
typedef void (*releaseFunc) (const void *);
@@ -418,15 +420,15 @@ const WMHashTableCallbacks WMIntHashCallbacks = {
};
const WMHashTableCallbacks WMStringHashCallbacks = {
(hashFunc) hashString,
(isEqualFunc) compareStrings,
hashString,
compareStrings,
(retainFunc) wstrdup,
(releaseFunc) wfree
};
const WMHashTableCallbacks WMStringPointerHashCallbacks = {
(hashFunc) hashString,
(isEqualFunc) compareStrings,
hashString,
compareStrings,
NULL,
NULL
};

View File

@@ -52,7 +52,7 @@ static void defaultHandler(int bla)
exit(1);
}
static waborthandler *aborthandler = (waborthandler *) defaultHandler;
static waborthandler *aborthandler = defaultHandler;
#define wAbort(a) (*aborthandler)(a)

View File

@@ -47,7 +47,7 @@ typedef struct StringBuffer {
int size;
} StringBuffer;
static unsigned hashPropList(WMPropList * plist);
static unsigned hashPropList(const void *param);
static WMPropList *getPLString(PLData * pldata);
static WMPropList *getPLQString(PLData * pldata);
static WMPropList *getPLData(PLData * pldata);
@@ -55,16 +55,13 @@ static WMPropList *getPLArray(PLData * pldata);
static WMPropList *getPLDictionary(PLData * pldata);
static WMPropList *getPropList(PLData * pldata);
typedef unsigned (*hashFunc) (const void *);
typedef Bool(*isEqualFunc) (const void *, const void *);
typedef void *(*retainFunc) (const void *);
typedef void (*releaseFunc) (const void *);
static const WMHashTableCallbacks WMPropListHashCallbacks = {
(hashFunc) hashPropList,
hashPropList,
(isEqualFunc) WMIsPropListEqualTo,
(retainFunc) NULL,
(releaseFunc) NULL
NULL,
NULL
};
static Bool caseSensitive = True;
@@ -102,8 +99,9 @@ static Bool caseSensitive = True;
#define MaxHashLength 64
static unsigned hashPropList(WMPropList * plist)
static unsigned hashPropList(const void *param)
{
WMPropList *plist= (WMPropList *) param;
unsigned ret = 0;
unsigned ctr = 0;
const char *key;

View File

@@ -80,10 +80,12 @@ void WMCreateEventHandler(WMView * view, unsigned long mask, WMEventProc * event
static int matchHandler(const void *item, const void *cdata)
{
#define H1 ((W_EventHandler*)item)
#define H2 ((W_EventHandler*)cdata)
const W_EventHandler *h1 = item;
const W_EventHandler *h2 = cdata;
return (H1->eventMask == H2->eventMask && H1->proc == H2->proc && H1->clientData == H2->clientData);
return ((h1->eventMask == h2->eventMask) &&
(h1->proc == h2->proc) &&
(h1->clientData == h2->clientData));
}
/*

View File

@@ -635,7 +635,10 @@ static void handleEvents(XEvent * event, void *data)
static int matchTitle(const void *item, const void *title)
{
return (strcmp(((WMListItem *) item)->text, (const char *)title) == 0 ? 1 : 0);
const WMListItem *wl_item = item;
const char *s_title = title;
return (strcmp(wl_item->text, s_title) == 0 ? 1 : 0);
}
int WMFindRowOfListItemWithTitle(WMList * lPtr, const char *title)