kernel: Constify some formal parameters

Andrew Talbot Andrew.Talbot at talbotville.com
Thu Aug 31 16:15:23 CDT 2006


More preparation for cast-qual warnings elimination elsewhere.
---
Changelog:
    kernel: Constify some formal parameters.

diff -urN a/dlls/kernel/resource16.c b/dlls/kernel/resource16.c
--- a/dlls/kernel/resource16.c	2006-08-31 21:43:26.000000000 +0100
+++ b/dlls/kernel/resource16.c	2006-08-31 21:48:45.000000000 +0100
@@ -578,9 +578,9 @@
 /**********************************************************************
  *	    GetDialog32Size   (KERNEL.618)
  */
-WORD WINAPI GetDialog32Size16( LPVOID dialog32 )
+WORD WINAPI GetDialog32Size16( LPCVOID dialog32 )
 {
-    LPVOID p = dialog32;
+    LPCVOID p = dialog32;
     WORD nbItems, data, dialogEx;
     DWORD style;
 
@@ -588,110 +588,110 @@
     dialogEx = (style == 0xffff0001);  /* DIALOGEX resource */
     if (dialogEx)
     {
-        p = (DWORD *)p + 1; /* helpID */
-        p = (DWORD *)p + 1; /* exStyle */
+        p = (const DWORD *)p + 1; /* helpID */
+        p = (const DWORD *)p + 1; /* exStyle */
         style = get_dword(&p); /* style */
     }
     else
-        p = (DWORD *)p + 1; /* exStyle */
+        p = (const DWORD *)p + 1; /* exStyle */
 
     nbItems = get_word(&p);
-    p = (WORD *)p + 1; /* x */
-    p = (WORD *)p + 1; /* y */
-    p = (WORD *)p + 1; /* cx */
-    p = (WORD *)p + 1; /* cy */
+    p = (const DWORD *)p + 1; /* x */
+    p = (const DWORD *)p + 1; /* y */
+    p = (const DWORD *)p + 1; /* cx */
+    p = (const DWORD *)p + 1; /* cy */
 
     /* Skip menu name */
-    switch (*((WORD *)p))
+    switch (*((const DWORD *)p))
     {
-    case 0x0000:  p = (WORD *)p + 1; break;
-    case 0xffff:  p = (WORD *)p + 2; break;
-    default:      p = (LPWSTR)p + strlenW( (LPWSTR)p ) + 1; break;
+    case 0x0000:  p = (const DWORD *)p + 1; break;
+    case 0xffff:  p = (const DWORD *)p + 2; break;
+    default:      p = (LPCWSTR)p + strlenW( p ) + 1; break;
     }
 
     /* Skip class name */
-    switch (*((WORD *)p))
+    switch (*((const DWORD *)p))
     {
-    case 0x0000:  p = (WORD *)p + 1; break;
-    case 0xffff:  p = (WORD *)p + 2; break;
-    default:      p = (LPWSTR)p + strlenW( (LPWSTR)p ) + 1; break;
+    case 0x0000:  p = (const DWORD *)p + 1; break;
+    case 0xffff:  p = (const DWORD *)p + 2; break;
+    default:      p = (LPCWSTR)p + strlenW( p ) + 1; break;
     }
 
     /* Skip window caption */
-    p = (LPWSTR)p + strlenW( (LPWSTR)p ) + 1;
+    p = (LPCWSTR)p + strlenW( p ) + 1;
 
     /* Skip font info */
     if (style & DS_SETFONT)
     {
-        p = (WORD *)p + 1;  /* pointSize */
+        p = (const DWORD *)p + 1;  /* pointSize */
         if (dialogEx)
         {
-            p = (WORD *)p + 1; /* weight */
-            p = (WORD *)p + 1; /* italic */
+            p = (const DWORD *)p + 1; /* weight */
+            p = (const DWORD *)p + 1; /* italic */
         }
-        p = (LPWSTR)p + strlenW( (LPWSTR)p ) + 1;  /* faceName */
+        p = (LPCWSTR)p + strlenW( p ) + 1;  /* faceName */
     }
 
     /* Skip dialog items */
     while (nbItems)
     {
         /* align on DWORD boundary */
-        p = (LPVOID)(((UINT_PTR)p + 3) & ~3);
+        p = (LPCVOID)(((UINT_PTR)p + 3) & ~3);
 
         if (dialogEx)
         {
-            p = (DWORD *)p + 1; /* helpID */
-            p = (DWORD *)p + 1; /* exStyle */
-            p = (DWORD *)p + 1; /* style */
+            p = (const DWORD *)p + 1; /* helpID */
+            p = (const DWORD *)p + 1; /* exStyle */
+            p = (const DWORD *)p + 1; /* style */
         }
         else
         {
-            p = (DWORD *)p + 1; /* style */
-            p = (DWORD *)p + 1; /* exStyle */
+            p = (const DWORD *)p + 1; /* style */
+            p = (const DWORD *)p + 1; /* exStyle */
         }
 
-        p = (WORD *)p + 1; /* x */
-        p = (WORD *)p + 1; /* y */
-        p = (WORD *)p + 1; /* cx */
-        p = (WORD *)p + 1; /* cy */
+        p = (const DWORD *)p + 1; /* x */
+        p = (const DWORD *)p + 1; /* y */
+        p = (const DWORD *)p + 1; /* cx */
+        p = (const DWORD *)p + 1; /* cy */
 
         if (dialogEx)
-            p = (DWORD *)p + 1; /* ID */
+            p = (const DWORD *)p + 1; /* ID */
         else
-            p = (WORD *)p + 1; /* ID */
+            p = (const DWORD *)p + 1; /* ID */
 
         /* Skip class name */
-        switch (*((WORD *)p))
+        switch (*(const DWORD *)p)
         {
-        case 0x0000:  p = (WORD *)p + 1; break;
-        case 0xffff:  p = (WORD *)p + 2; break;
-        default:      p = (LPWSTR)p + strlenW( (LPWSTR)p ) + 1; break;
+        case 0x0000:  p = (const DWORD *)p + 1; break;
+        case 0xffff:  p = (const DWORD *)p + 2; break;
+        default:      p = (LPCWSTR)p + strlenW( p ) + 1; break;
         }
 
         /* Skip window name */
-        switch (*((WORD *)p))
+        switch (*(const DWORD *)p)
         {
-        case 0x0000:  p = (WORD *)p + 1; break;
-        case 0xffff:  p = (WORD *)p + 2; break;
-        default:      p = (LPWSTR)p + strlenW( (LPWSTR)p ) + 1; break;
+        case 0x0000:  p = (const DWORD *)p + 1; break;
+        case 0xffff:  p = (const DWORD *)p + 2; break;
+        default:      p = (LPCWSTR)p + strlenW( p ) + 1; break;
         }
 
         /* Skip data */
         data = get_word(&p);
-        p = (BYTE *)p + data;
+        p = (const BYTE *)p + data;
 
         /* Next item */
         nbItems--;
     }
 
-    return (WORD)((LPSTR)p - (LPSTR)dialog32);
+    return (WORD)((LPCSTR)p - (LPCSTR)dialog32);
 }
 
 
 /**********************************************************************
  *	    ConvertMenu32To16   (KERNEL.616)
  */
-VOID WINAPI ConvertMenu32To16( LPVOID menu32, DWORD size, LPVOID menu16 )
+VOID WINAPI ConvertMenu32To16( LPCVOID menu32, DWORD size, LPVOID menu16 )
 {
     WORD version, headersize, flags, level = 1;
 
@@ -703,7 +703,7 @@
     {
         memcpy( menu16, menu32, headersize );
         menu16 = (BYTE *)menu16 + headersize;
-        menu32 = (BYTE *)menu32 + headersize;
+        menu32 = (const BYTE *)menu32 + headersize;
     }
 
     while ( level )
@@ -717,8 +717,8 @@
                 level++;
 
             WideCharToMultiByte( CP_ACP, 0, menu32, -1, menu16, 0x7fffffff, NULL, NULL );
-            menu16 = (LPSTR)menu16 + strlen( (LPSTR)menu16 ) + 1;
-            menu32 = (LPWSTR)menu32 + strlenW( (LPWSTR)menu32 ) + 1;
+            menu16 = (LPSTR)menu16 + strlen( menu16 ) + 1;
+            menu32 = (LPCWSTR)menu32 + strlenW( menu32 ) + 1;
 
             if ( flags & MF_END )
                 level--;
@@ -732,11 +732,11 @@
             put_byte(&menu16,flags);
 
             WideCharToMultiByte( CP_ACP, 0, menu32, -1, menu16, 0x7fffffff, NULL, NULL );
-            menu16 = (LPSTR)menu16 + strlen( (LPSTR)menu16 ) + 1;
-            menu32 = (LPWSTR)menu32 + strlenW( (LPWSTR)menu32 ) + 1;
+            menu16 = (LPSTR)menu16 + strlen( menu16 ) + 1;
+            menu32 = (LPCWSTR)menu32 + strlenW( menu32 ) + 1;
 
             /* align on DWORD boundary (32-bit only) */
-            menu32 = (LPVOID)(((UINT_PTR)menu32 + 3) & ~3);
+            menu32 = (LPCVOID)(((UINT_PTR)menu32 + 3) & ~3);
 
             /* If popup, transfer helpid */
             if ( flags & 1)
@@ -754,45 +754,45 @@
 /**********************************************************************
  *	    GetMenu32Size   (KERNEL.617)
  */
-WORD WINAPI GetMenu32Size16( LPVOID menu32 )
+WORD WINAPI GetMenu32Size16( LPCVOID menu32 )
 {
-    LPVOID p = menu32;
+    LPCVOID p = menu32;
     WORD version, headersize, flags, level = 1;
 
     version = get_word(&p);
     headersize = get_word(&p);
-    p = (BYTE *)p + headersize;
+    p = (const BYTE *)p + headersize;
 
     while ( level )
         if ( version == 0 )  /* standard */
         {
             flags = get_word(&p);
             if ( !(flags & MF_POPUP) )
-                p = (WORD *)p + 1;  /* ID */
+                p = (const WORD *)p + 1;  /* ID */
             else
                 level++;
 
-            p = (LPWSTR)p + strlenW( (LPWSTR)p ) + 1;
+            p = (LPCWSTR)p + strlenW( p ) + 1;
 
             if ( flags & MF_END )
                 level--;
         }
         else  /* extended */
         {
-            p = (DWORD *)p + 1; /* fType */
-            p = (DWORD *)p + 1; /* fState */
-            p = (DWORD *)p + 1; /* ID */
+            p = (const DWORD *)p + 1; /* fType */
+            p = (const DWORD *)p + 1; /* fState */
+            p = (const DWORD *)p + 1; /* ID */
             flags = get_word(&p);
 
-            p = (LPWSTR)p + strlenW( (LPWSTR)p ) + 1;
+            p = (LPCWSTR)p + strlenW( p ) + 1;
 
             /* align on DWORD boundary (32-bit only) */
-            p = (LPVOID)(((UINT_PTR)p + 3) & ~3);
+            p = (LPCVOID)(((UINT_PTR)p + 3) & ~3);
 
             /* If popup, skip helpid */
             if ( flags & 1)
             {
-                p = (DWORD *)p + 1;
+                p = (const DWORD *)p + 1;
                 level++;
             }
 
@@ -800,14 +800,14 @@
                 level--;
         }
 
-    return (WORD)((LPSTR)p - (LPSTR)menu32);
+    return (WORD)((LPCSTR)p - (LPCSTR)menu32);
 }
 
 
 /**********************************************************************
  *	    ConvertAccelerator32To16
  */
-static void ConvertAccelerator32To16( LPVOID acc32, DWORD size, LPVOID acc16 )
+static void ConvertAccelerator32To16( LPCVOID acc32, DWORD size, LPVOID acc16 )
 {
     BYTE type;
 
@@ -831,7 +831,7 @@
 /**********************************************************************
  *	    NE_LoadPEResource
  */
-static HGLOBAL16 NE_LoadPEResource( NE_MODULE *pModule, WORD type, LPVOID bits, DWORD size )
+static HGLOBAL16 NE_LoadPEResource( NE_MODULE *pModule, WORD type, LPCVOID bits, DWORD size )
 {
     HGLOBAL16 handle;
 



More information about the wine-patches mailing list