mirror of
https://github.com/gryf/wmaker.git
synced 2025-12-19 20:38:08 +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:
committed by
Carlos R. Mafra
parent
bab90b2168
commit
e2d816c7a2
@@ -35,8 +35,9 @@ typedef struct W_HashTable {
|
|||||||
#define RELKEY(table, key) if ((table)->callbacks.releaseKey) \
|
#define RELKEY(table, key) if ((table)->callbacks.releaseKey) \
|
||||||
(*(table)->callbacks.releaseKey)(key)
|
(*(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 ret = 0;
|
||||||
unsigned ctr = 0;
|
unsigned ctr = 0;
|
||||||
|
|
||||||
@@ -400,13 +401,14 @@ Bool WMNextHashEnumeratorItemAndKey(WMHashEnumerator * enumerator, void **item,
|
|||||||
return False;
|
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;
|
return strcmp(key1, key2) == 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
typedef unsigned (*hashFunc) (const void *);
|
|
||||||
typedef Bool(*isEqualFunc) (const void *, const void *);
|
|
||||||
typedef void *(*retainFunc) (const void *);
|
typedef void *(*retainFunc) (const void *);
|
||||||
typedef void (*releaseFunc) (const void *);
|
typedef void (*releaseFunc) (const void *);
|
||||||
|
|
||||||
@@ -418,15 +420,15 @@ const WMHashTableCallbacks WMIntHashCallbacks = {
|
|||||||
};
|
};
|
||||||
|
|
||||||
const WMHashTableCallbacks WMStringHashCallbacks = {
|
const WMHashTableCallbacks WMStringHashCallbacks = {
|
||||||
(hashFunc) hashString,
|
hashString,
|
||||||
(isEqualFunc) compareStrings,
|
compareStrings,
|
||||||
(retainFunc) wstrdup,
|
(retainFunc) wstrdup,
|
||||||
(releaseFunc) wfree
|
(releaseFunc) wfree
|
||||||
};
|
};
|
||||||
|
|
||||||
const WMHashTableCallbacks WMStringPointerHashCallbacks = {
|
const WMHashTableCallbacks WMStringPointerHashCallbacks = {
|
||||||
(hashFunc) hashString,
|
hashString,
|
||||||
(isEqualFunc) compareStrings,
|
compareStrings,
|
||||||
NULL,
|
NULL,
|
||||||
NULL
|
NULL
|
||||||
};
|
};
|
||||||
|
|||||||
@@ -52,7 +52,7 @@ static void defaultHandler(int bla)
|
|||||||
exit(1);
|
exit(1);
|
||||||
}
|
}
|
||||||
|
|
||||||
static waborthandler *aborthandler = (waborthandler *) defaultHandler;
|
static waborthandler *aborthandler = defaultHandler;
|
||||||
|
|
||||||
#define wAbort(a) (*aborthandler)(a)
|
#define wAbort(a) (*aborthandler)(a)
|
||||||
|
|
||||||
|
|||||||
@@ -47,7 +47,7 @@ typedef struct StringBuffer {
|
|||||||
int size;
|
int size;
|
||||||
} StringBuffer;
|
} StringBuffer;
|
||||||
|
|
||||||
static unsigned hashPropList(WMPropList * plist);
|
static unsigned hashPropList(const void *param);
|
||||||
static WMPropList *getPLString(PLData * pldata);
|
static WMPropList *getPLString(PLData * pldata);
|
||||||
static WMPropList *getPLQString(PLData * pldata);
|
static WMPropList *getPLQString(PLData * pldata);
|
||||||
static WMPropList *getPLData(PLData * pldata);
|
static WMPropList *getPLData(PLData * pldata);
|
||||||
@@ -55,16 +55,13 @@ static WMPropList *getPLArray(PLData * pldata);
|
|||||||
static WMPropList *getPLDictionary(PLData * pldata);
|
static WMPropList *getPLDictionary(PLData * pldata);
|
||||||
static WMPropList *getPropList(PLData * pldata);
|
static WMPropList *getPropList(PLData * pldata);
|
||||||
|
|
||||||
typedef unsigned (*hashFunc) (const void *);
|
|
||||||
typedef Bool(*isEqualFunc) (const void *, const void *);
|
typedef Bool(*isEqualFunc) (const void *, const void *);
|
||||||
typedef void *(*retainFunc) (const void *);
|
|
||||||
typedef void (*releaseFunc) (const void *);
|
|
||||||
|
|
||||||
static const WMHashTableCallbacks WMPropListHashCallbacks = {
|
static const WMHashTableCallbacks WMPropListHashCallbacks = {
|
||||||
(hashFunc) hashPropList,
|
hashPropList,
|
||||||
(isEqualFunc) WMIsPropListEqualTo,
|
(isEqualFunc) WMIsPropListEqualTo,
|
||||||
(retainFunc) NULL,
|
NULL,
|
||||||
(releaseFunc) NULL
|
NULL
|
||||||
};
|
};
|
||||||
|
|
||||||
static Bool caseSensitive = True;
|
static Bool caseSensitive = True;
|
||||||
@@ -102,8 +99,9 @@ static Bool caseSensitive = True;
|
|||||||
|
|
||||||
#define MaxHashLength 64
|
#define MaxHashLength 64
|
||||||
|
|
||||||
static unsigned hashPropList(WMPropList * plist)
|
static unsigned hashPropList(const void *param)
|
||||||
{
|
{
|
||||||
|
WMPropList *plist= (WMPropList *) param;
|
||||||
unsigned ret = 0;
|
unsigned ret = 0;
|
||||||
unsigned ctr = 0;
|
unsigned ctr = 0;
|
||||||
const char *key;
|
const char *key;
|
||||||
|
|||||||
@@ -80,10 +80,12 @@ void WMCreateEventHandler(WMView * view, unsigned long mask, WMEventProc * event
|
|||||||
|
|
||||||
static int matchHandler(const void *item, const void *cdata)
|
static int matchHandler(const void *item, const void *cdata)
|
||||||
{
|
{
|
||||||
#define H1 ((W_EventHandler*)item)
|
const W_EventHandler *h1 = item;
|
||||||
#define H2 ((W_EventHandler*)cdata)
|
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));
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
|
|||||||
@@ -635,7 +635,10 @@ static void handleEvents(XEvent * event, void *data)
|
|||||||
|
|
||||||
static int matchTitle(const void *item, const void *title)
|
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)
|
int WMFindRowOfListItemWithTitle(WMList * lPtr, const char *title)
|
||||||
|
|||||||
Reference in New Issue
Block a user