From bd6590a86bac1c8ee4be4eb8d7c23e54a2716bf0 Mon Sep 17 00:00:00 2001 From: Michael Stefaniuc Date: Sat, 19 Oct 2002 00:51:00 +0000 Subject: [PATCH] Fix warnings when converting between an ATOM and a HSZ. --- dlls/user/dde/misc.c | 20 ++++++++++++-------- 1 file changed, 12 insertions(+), 8 deletions(-) diff --git a/dlls/user/dde/misc.c b/dlls/user/dde/misc.c index 57915999c8a..59f14319669 100644 --- a/dlls/user/dde/misc.c +++ b/dlls/user/dde/misc.c @@ -42,6 +42,10 @@ WINE_DEFAULT_DEBUG_CHANNEL(ddeml); +/* convert between ATOM and HSZ avoiding compiler warnings */ +#define ATOM2HSZ(atom) ((HSZ) (ULONG_PTR)(atom)) +#define HSZ2ATOM(hsz) ((ATOM) (ULONG_PTR)(hsz)) + static WDML_INSTANCE* WDML_InstanceList = NULL; static DWORD WDML_MaxInstanceID = 0; /* OK for present, have to worry about wrap-around later */ const char WDML_szEventClass[] = "DdeEventClass"; @@ -836,7 +840,7 @@ ATOM WDML_MakeAtomFromHsz(HSZ hsz) { WCHAR nameBuffer[MAX_BUFFER_LEN]; - if (GetAtomNameW((ATOM)hsz, nameBuffer, MAX_BUFFER_LEN)) + if (GetAtomNameW(HSZ2ATOM(hsz), nameBuffer, MAX_BUFFER_LEN)) return GlobalAddAtomW(nameBuffer); WARN("HSZ 0x%x not found\n", hsz); return 0; @@ -910,7 +914,7 @@ BOOL WDML_DecHSZ(WDML_INSTANCE* pInstance, HSZ hsz) pPrev->next = pCurrent->next; } HeapFree(GetProcessHeap(), 0, pCurrent); - DeleteAtom((ATOM)hsz); + DeleteAtom(HSZ2ATOM(hsz)); } return TRUE; } @@ -985,10 +989,10 @@ static int WDML_QueryString(WDML_INSTANCE* pInstance, HSZ hsz, LPVOID ptr, DWORD switch (codepage) { case CP_WINANSI: - ret = GetAtomNameA((ATOM)hsz, ptr, cchMax); + ret = GetAtomNameA(HSZ2ATOM(hsz), ptr, cchMax); break; case CP_WINUNICODE: - ret = GetAtomNameW((ATOM)hsz, ptr, cchMax); + ret = GetAtomNameW(HSZ2ATOM(hsz), ptr, cchMax); default: ERR("Unknown code page %d\n", codepage); ret = 0; @@ -1061,11 +1065,11 @@ static HSZ WDML_CreateString(WDML_INSTANCE* pInstance, LPCVOID ptr, int codepage switch (codepage) { case CP_WINANSI: - hsz = (HSZ)AddAtomA(ptr); + hsz = ATOM2HSZ(AddAtomA(ptr)); TRACE("added atom %s with HSZ 0x%x, \n", debugstr_a(ptr), hsz); break; case CP_WINUNICODE: - hsz = (HSZ)AddAtomW(ptr); + hsz = ATOM2HSZ(AddAtomW(ptr)); TRACE("added atom %s with HSZ 0x%x, \n", debugstr_w(ptr), hsz); break; default: @@ -1203,8 +1207,8 @@ INT WINAPI DdeCmpStringHandles(HSZ hsz1, HSZ hsz2) int ret = 0; int ret1, ret2; - ret1 = GetAtomNameW((ATOM)hsz1, psz1, MAX_BUFFER_LEN); - ret2 = GetAtomNameW((ATOM)hsz2, psz2, MAX_BUFFER_LEN); + ret1 = GetAtomNameW(HSZ2ATOM(hsz1), psz1, MAX_BUFFER_LEN); + ret2 = GetAtomNameW(HSZ2ATOM(hsz2), psz2, MAX_BUFFER_LEN); TRACE("(%x<%s> %x<%s>);\n", hsz1, debugstr_w(psz1), hsz2, debugstr_w(psz2));