winhelp: Fix Win64 warnings

Dmitry Timoshkov dmitry at codeweavers.com
Wed Apr 9 07:24:07 CDT 2008


Hello,

Changelog:
    winhelp: Fix Win64 warnings.
---
 programs/winhelp/callback.c  |    8 +++---
 programs/winhelp/hlpfile.c   |   26 +++++++++++-----------
 programs/winhelp/macro.lex.l |    2 +-
 programs/winhelp/winhelp.c   |   48 +++++++++++++++++++++---------------------
 4 files changed, 42 insertions(+), 42 deletions(-)

diff --git a/programs/winhelp/callback.c b/programs/winhelp/callback.c
index 461e043..0b3e62e 100644
--- a/programs/winhelp/callback.c
+++ b/programs/winhelp/callback.c
@@ -127,16 +127,16 @@ static void CALLBACK WHD_ErrorString(LPSTR err)
     WINE_FIXME("()\n");
 }
 
-static LONG CALLBACK WHD_GetInfo(WORD what, HWND hnd)
+static ULONG_PTR CALLBACK WHD_GetInfo(WORD what, HWND hnd)
 {
-    LONG        ret = 0;
+    ULONG_PTR ret = 0;
 
     WINE_TRACE("(%x %p)\n", what, hnd);
     switch (what)
     {
     case 0: break;
-    case 1: /* instance */ ret = (LONG)Globals.hInstance; break;
-    case 3: /* current window */ ret = (LONG)Globals.active_win->hMainWnd; break;
+    case 1: /* instance */ ret = (ULONG_PTR)Globals.hInstance; break;
+    case 3: /* current window */ ret = (ULONG_PTR)Globals.active_win->hMainWnd; break;
     case 2: /* main window */
     case 4: /* handle to opened file */
     case 5: /* foreground color */
diff --git a/programs/winhelp/hlpfile.c b/programs/winhelp/hlpfile.c
index 39b3081..942d50e 100644
--- a/programs/winhelp/hlpfile.c
+++ b/programs/winhelp/hlpfile.c
@@ -158,11 +158,11 @@ HLPFILE_PAGE *HLPFILE_PageByOffset(HLPFILE* hlpfile, LONG offset)
 static int comp_PageByHash(void *p, const void *key,
                            int leaf, void** next)
 {
-    LONG lKey = (LONG)key;
-    LONG lTest = GET_UINT(p, 0);
+    ULONG_PTR lKey = (LONG_PTR)key;
+    ULONG_PTR lTest = GET_UINT(p, 0);
 
     *next = (char *)p+(leaf?8:6);
-    WINE_TRACE("Comparing '%u' with '%u'\n", lKey, lTest);
+    WINE_TRACE("Comparing '%lu' with '%lu'\n", lKey, lTest);
     if (lTest < lKey) return -1;
     if (lTest > lKey) return 1;
     return 0;
@@ -184,7 +184,7 @@ HLPFILE_PAGE *HLPFILE_PageByHash(HLPFILE* hlpfile, LONG lHash)
     if (hlpfile->version <= 16)
         return HLPFILE_PageByNumber(hlpfile, lHash);
 
-    ptr = HLPFILE_BPTreeSearch(hlpfile->Context, (void*)lHash, comp_PageByHash);
+    ptr = HLPFILE_BPTreeSearch(hlpfile->Context, ULongToPtr(lHash), comp_PageByHash);
     if (!ptr)
     {
         WINE_ERR("Page of hash %x not found in file %s\n", lHash, hlpfile->lpszPath);
@@ -587,7 +587,7 @@ static BYTE*    HLPFILE_DecompressGfx(BYTE* src, unsigned csz, unsigned sz, BYTE
         if (!dst) return NULL;
         HLPFILE_UncompressRLE(src, src + csz, &tmp, sz);
         if (tmp - dst != sz)
-            WINE_WARN("Bogus gfx sizes (RunLen): %u/%u\n", tmp - dst, sz);
+            WINE_WARN("Bogus gfx sizes (RunLen): %lu/%u\n", (SIZE_T)(tmp - dst), sz);
         break;
     case 2: /* LZ77 */
         sz77 = HLPFILE_UncompressedLZ77_Size(src, src + csz);
@@ -610,7 +610,7 @@ static BYTE*    HLPFILE_DecompressGfx(BYTE* src, unsigned csz, unsigned sz, BYTE
         }
         HLPFILE_UncompressRLE(tmp, tmp + sz77, &tmp2, sz);
         if (tmp2 - dst != sz)
-            WINE_WARN("Bogus gfx sizes (LZ77+RunLen): %u / %u\n", tmp2 - dst, sz);
+            WINE_WARN("Bogus gfx sizes (LZ77+RunLen): %lu / %u\n", (SIZE_T)(tmp2 - dst), sz);
         HeapFree(GetProcessHeap(), 0, tmp);
         break;
     default:
@@ -729,8 +729,8 @@ static BOOL     HLPFILE_LoadMetaFile(BYTE* beg, BYTE pack, HLPFILE_PARAGRAPH* pa
     hsoff = GET_UINT(ptr, 4);
     ptr += 8;
 
-    WINE_TRACE("sz=%lu csz=%lu (%d,%d) offs=%lu/%u,%lu\n",
-               size, csize, lpmfp->xExt, lpmfp->yExt, off, ptr - beg, hsoff);
+    WINE_TRACE("sz=%lu csz=%lu (%d,%d) offs=%lu/%lu,%lu\n",
+               size, csize, lpmfp->xExt, lpmfp->yExt, off, (SIZE_T)(ptr - beg), hsoff);
 
     bits = HLPFILE_DecompressGfx(beg + off, csize, size, pack);
     if (!bits) return FALSE;
@@ -944,7 +944,7 @@ static BOOL HLPFILE_AddParagraph(HLPFILE *hlpfile, BYTE *buf, BYTE *end, unsigne
 
     for (nc = 0; nc < ncol; nc++)
     {
-        WINE_TRACE("looking for format at offset %u for column %d\n", format - (buf + 0x15), nc);
+        WINE_TRACE("looking for format at offset %lu for column %d\n", (SIZE_T)(format - (buf + 0x15)), nc);
         if (buf[0x14] == 0x23)
             format += 5;
         if (buf[0x14] == 0x01)
@@ -1796,8 +1796,8 @@ static void HLPFILE_Uncompress2(const BYTE *ptr, const BYTE *end, BYTE *newptr,
 
             if (newptr + (phend - phptr) > newend)
             {
-                WINE_FIXME("buffer overflow %p > %p for %d bytes\n", 
-                           newptr, newend, phend - phptr);
+                WINE_FIXME("buffer overflow %p > %p for %lu bytes\n", 
+                           newptr, newend, (SIZE_T)(phend - phptr));
                 return;
             }
             memcpy(newptr, phptr, phend - phptr);
@@ -1902,8 +1902,8 @@ static void HLPFILE_UncompressRLE(const BYTE* src, const BYTE* end, BYTE** dst,
         *dst += ch;
     }
     if (*dst != sdst)
-        WINE_WARN("Buffer X-flow: d(%u) instead of d(%u)\n",
-                  *dst - (sdst - dstsz), dstsz);
+        WINE_WARN("Buffer X-flow: d(%lu) instead of d(%u)\n",
+                  (SIZE_T)(*dst - (sdst - dstsz)), dstsz);
 }
 
 /**************************************************************************
diff --git a/programs/winhelp/macro.lex.l b/programs/winhelp/macro.lex.l
index 97640b4..17e70ed 100644
--- a/programs/winhelp/macro.lex.l
+++ b/programs/winhelp/macro.lex.l
@@ -175,7 +175,7 @@ static int MACRO_CheckArgs(void* pa[], unsigned max, const char* args)
             case 'I':
                 if (t != INTEGER)
                 {WINE_WARN("missing U\n");return -1;}   
-                pa[idx] = (void*)yylval.integer; 
+                pa[idx] = LongToPtr(yylval.integer);
                 break;
             case 'B':
                 if (t != BOOL_FUNCTION) 
diff --git a/programs/winhelp/winhelp.c b/programs/winhelp/winhelp.c
index 840fb8a..b9c435f 100644
--- a/programs/winhelp/winhelp.c
+++ b/programs/winhelp/winhelp.c
@@ -466,10 +466,10 @@ static BOOL     WINHELP_ReuseWindow(WINHELP_WINDOW* win, WINHELP_WINDOW* oldwin,
     oldwin->hMainWnd   = oldwin->hButtonBoxWnd = oldwin->hTextWnd = oldwin->hHistoryWnd = 0;
     win->hBrush        = CreateSolidBrush(win->info->sr_color);
 
-    SetWindowLong(win->hMainWnd,      0, (LONG)win);
-    SetWindowLong(win->hButtonBoxWnd, 0, (LONG)win);
-    SetWindowLong(win->hTextWnd,      0, (LONG)win);
-    SetWindowLong(win->hHistoryWnd,   0, (LONG)win);
+    SetWindowLongPtr(win->hMainWnd,      0, (ULONG_PTR)win);
+    SetWindowLongPtr(win->hButtonBoxWnd, 0, (ULONG_PTR)win);
+    SetWindowLongPtr(win->hTextWnd,      0, (ULONG_PTR)win);
+    SetWindowLongPtr(win->hHistoryWnd,   0, (ULONG_PTR)win);
 
     WINHELP_InitFonts(win->hMainWnd);
 
@@ -701,12 +701,12 @@ static LRESULT CALLBACK WINHELP_MainWndProc(HWND hWnd, UINT msg, WPARAM wParam,
     {
     case WM_NCCREATE:
         win = (WINHELP_WINDOW*) ((LPCREATESTRUCT) lParam)->lpCreateParams;
-        SetWindowLong(hWnd, 0, (LONG) win);
+        SetWindowLongPtr(hWnd, 0, (ULONG_PTR) win);
         win->hMainWnd = hWnd;
         break;
 
     case WM_CREATE:
-        win = (WINHELP_WINDOW*) GetWindowLong(hWnd, 0);
+        win = (WINHELP_WINDOW*) GetWindowLongPtr(hWnd, 0);
 
         /* Create button box and text Window */
         CreateWindow(BUTTON_BOX_WIN_CLASS_NAME, "", WS_CHILD | WS_VISIBLE,
@@ -718,7 +718,7 @@ static LRESULT CALLBACK WINHELP_MainWndProc(HWND hWnd, UINT msg, WPARAM wParam,
         /* Fall through */
     case WM_USER:
     case WM_WINDOWPOSCHANGED:
-        win = (WINHELP_WINDOW*) GetWindowLong(hWnd, 0);
+        win = (WINHELP_WINDOW*) GetWindowLongPtr(hWnd, 0);
         GetClientRect(hWnd, &rect);
 
         /* Update button box and text Window */
@@ -738,7 +738,7 @@ static LRESULT CALLBACK WINHELP_MainWndProc(HWND hWnd, UINT msg, WPARAM wParam,
         break;
 
     case WM_COMMAND:
-        Globals.active_win = win = (WINHELP_WINDOW*) GetWindowLong(hWnd, 0);
+        Globals.active_win = win = (WINHELP_WINDOW*) GetWindowLongPtr(hWnd, 0);
         switch (wParam)
 	{
             /* Menu FILE */
@@ -790,7 +790,7 @@ static LRESULT CALLBACK WINHELP_MainWndProc(HWND hWnd, UINT msg, WPARAM wParam,
 
         case VK_PRIOR:
         case VK_NEXT:
-            win = (WINHELP_WINDOW*) GetWindowLong(hWnd, 0);
+            win = (WINHELP_WINDOW*) GetWindowLongPtr(hWnd, 0);
             curPos = GetScrollPos(win->hTextWnd, SB_VERT);
             GetScrollRange(win->hTextWnd, SB_VERT, &min, &max);
 
@@ -841,13 +841,13 @@ static LRESULT CALLBACK WINHELP_ButtonBoxWndProc(HWND hWnd, UINT msg, WPARAM wPa
     {
     case WM_NCCREATE:
         win = (WINHELP_WINDOW*) ((LPCREATESTRUCT) lParam)->lpCreateParams;
-        SetWindowLong(hWnd, 0, (LONG) win);
+        SetWindowLongPtr(hWnd, 0, (ULONG_PTR) win);
         win->hButtonBoxWnd = hWnd;
         break;
 
     case WM_WINDOWPOSCHANGING:
         winpos = (WINDOWPOS*) lParam;
-        win = (WINHELP_WINDOW*) GetWindowLong(hWnd, 0);
+        win = (WINHELP_WINDOW*) GetWindowLongPtr(hWnd, 0);
 
         /* Update buttons */
         button_size.cx = 0;
@@ -958,7 +958,7 @@ static LRESULT CALLBACK WINHELP_TextWndProc(HWND hWnd, UINT msg, WPARAM wParam,
     {
     case WM_NCCREATE:
         win = (WINHELP_WINDOW*) ((LPCREATESTRUCT) lParam)->lpCreateParams;
-        SetWindowLong(hWnd, 0, (LONG) win);
+        SetWindowLongPtr(hWnd, 0, (ULONG_PTR) win);
         win->hTextWnd = hWnd;
         win->hBrush = CreateSolidBrush(win->info->sr_color);
         if (win->info->win_style & WS_POPUP) Globals.hPopupWnd = win->hMainWnd = hWnd;
@@ -966,7 +966,7 @@ static LRESULT CALLBACK WINHELP_TextWndProc(HWND hWnd, UINT msg, WPARAM wParam,
         break;
 
     case WM_CREATE:
-        win = (WINHELP_WINDOW*) GetWindowLong(hWnd, 0);
+        win = (WINHELP_WINDOW*) GetWindowLongPtr(hWnd, 0);
 
         /* Calculate vertical size and position of a popup window */
         if (win->info->win_style & WS_POPUP)
@@ -1090,7 +1090,7 @@ static LRESULT CALLBACK WINHELP_TextWndProc(HWND hWnd, UINT msg, WPARAM wParam,
 
     case WM_PAINT:
         hDc = BeginPaint(hWnd, &ps);
-        win = (WINHELP_WINDOW*) GetWindowLong(hWnd, 0);
+        win = (WINHELP_WINDOW*) GetWindowLongPtr(hWnd, 0);
         scroll_pos = GetScrollPos(hWnd, SB_VERT);
 
         /* No DPtoLP needed - MM_TEXT map mode */
@@ -1189,7 +1189,7 @@ static LRESULT CALLBACK WINHELP_TextWndProc(HWND hWnd, UINT msg, WPARAM wParam,
         break;
 
     case WM_MOUSEMOVE:
-        win = (WINHELP_WINDOW*) GetWindowLong(hWnd, 0);
+        win = (WINHELP_WINDOW*) GetWindowLongPtr(hWnd, 0);
 
         if (WINHELP_IsOverLink(win, wParam, lParam))
             SetCursor(win->hHandCur); /* set to hand pointer cursor to indicate a link */
@@ -1199,7 +1199,7 @@ static LRESULT CALLBACK WINHELP_TextWndProc(HWND hWnd, UINT msg, WPARAM wParam,
         break;
 
     case WM_LBUTTONDOWN:
-        win = (WINHELP_WINDOW*) GetWindowLong(hWnd, 0);
+        win = (WINHELP_WINDOW*) GetWindowLongPtr(hWnd, 0);
 
         hPopupWnd = Globals.hPopupWnd;
         Globals.hPopupWnd = 0;
@@ -1248,7 +1248,7 @@ static LRESULT CALLBACK WINHELP_TextWndProc(HWND hWnd, UINT msg, WPARAM wParam,
         break;
 
     case WM_NCDESTROY:
-        win = (WINHELP_WINDOW*) GetWindowLong(hWnd, 0);
+        win = (WINHELP_WINDOW*) GetWindowLongPtr(hWnd, 0);
 
         if (hWnd == Globals.hPopupWnd) Globals.hPopupWnd = 0;
 
@@ -1284,11 +1284,11 @@ static LRESULT CALLBACK WINHELP_HistoryWndProc(HWND hWnd, UINT msg, WPARAM wPara
     {
     case WM_NCCREATE:
         win = (WINHELP_WINDOW*)((LPCREATESTRUCT)lParam)->lpCreateParams;
-        SetWindowLong(hWnd, 0, (LONG)win);
+        SetWindowLongPtr(hWnd, 0, (ULONG_PTR)win);
         win->hHistoryWnd = hWnd;
         break;
     case WM_CREATE:
-        win = (WINHELP_WINDOW*) GetWindowLong(hWnd, 0);
+        win = (WINHELP_WINDOW*) GetWindowLongPtr(hWnd, 0);
         hDc = GetDC(hWnd);
         GetTextMetrics(hDc, &tm);
         GetWindowRect(hWnd, &r);
@@ -1303,7 +1303,7 @@ static LRESULT CALLBACK WINHELP_HistoryWndProc(HWND hWnd, UINT msg, WPARAM wPara
         ReleaseDC(hWnd, hDc);
         break;
     case WM_LBUTTONDOWN:
-        win = (WINHELP_WINDOW*) GetWindowLong(hWnd, 0);
+        win = (WINHELP_WINDOW*) GetWindowLongPtr(hWnd, 0);
         hDc = GetDC(hWnd);
         GetTextMetrics(hDc, &tm);
         i = HIWORD(lParam) / tm.tmHeight;
@@ -1313,7 +1313,7 @@ static LRESULT CALLBACK WINHELP_HistoryWndProc(HWND hWnd, UINT msg, WPARAM wPara
         break;
     case WM_PAINT:
         hDc = BeginPaint(hWnd, &ps);
-        win = (WINHELP_WINDOW*) GetWindowLong(hWnd, 0);
+        win = (WINHELP_WINDOW*) GetWindowLongPtr(hWnd, 0);
         GetTextMetrics(hDc, &tm);
 
         for (i = 0; i < win->histIndex; i++)
@@ -1324,7 +1324,7 @@ static LRESULT CALLBACK WINHELP_HistoryWndProc(HWND hWnd, UINT msg, WPARAM wPara
         EndPaint(hWnd, &ps);
         break;
     case WM_DESTROY:
-        win = (WINHELP_WINDOW*) GetWindowLong(hWnd, 0);
+        win = (WINHELP_WINDOW*) GetWindowLongPtr(hWnd, 0);
         if (hWnd == win->hHistoryWnd)
             win->hHistoryWnd = 0;
         break;
@@ -1532,7 +1532,7 @@ static WINHELP_LINE_PART* WINHELP_AppendGfxObject(WINHELP_LINE ***linep, WINHELP
  */
 static BOOL WINHELP_SplitLines(HWND hWnd, LPSIZE newsize)
 {
-    WINHELP_WINDOW     *win = (WINHELP_WINDOW*) GetWindowLong(hWnd, 0);
+    WINHELP_WINDOW     *win = (WINHELP_WINDOW*) GetWindowLongPtr(hWnd, 0);
     HLPFILE_PARAGRAPH  *p;
     WINHELP_LINE      **line = &win->first_line;
     WINHELP_LINE_PART **part = 0;
@@ -1854,7 +1854,7 @@ static void WINHELP_DeleteWindow(WINHELP_WINDOW* win)
  */
 static void WINHELP_InitFonts(HWND hWnd)
 {
-    WINHELP_WINDOW *win = (WINHELP_WINDOW*) GetWindowLong(hWnd, 0);
+    WINHELP_WINDOW *win = (WINHELP_WINDOW*) GetWindowLongPtr(hWnd, 0);
     LOGFONT logfontlist[] = {
         {-10, 0, 0, 0, 400, 0, 0, 0, DEFAULT_CHARSET, 0, 0, 0, 32, "Helv"},
         {-12, 0, 0, 0, 700, 0, 0, 0, DEFAULT_CHARSET, 0, 0, 0, 32, "Helv"},
-- 
1.5.4.5






More information about the wine-patches mailing list