[PATCH v2] winhttp: Make strings in WINHTTP_PROXY_INFO non-const

Heiko Hund heiko.hund at sophos.com
Thu Jul 19 03:22:59 CDT 2012


The strings shouldn't be const according to the docs at [1] and
declaring them as LPWSTR removes some false warnings when
compiling code GlobalFree()ing them with mingw.

[1] http://msdn.microsoft.com/en-us/library/aa383912.aspx
---
 dlls/winhttp/request.c            |   16 ++++++++--------
 dlls/winhttp/session.c            |    8 ++++----
 dlls/winhttp/tests/notification.c |    4 ++--
 dlls/winhttp/tests/winhttp.c      |    8 ++++----
 include/winhttp.h                 |    4 ++--
 5 files changed, 20 insertions(+), 20 deletions(-)

diff --git a/dlls/winhttp/request.c b/dlls/winhttp/request.c
index 8870e50..8109290 100644
--- a/dlls/winhttp/request.c
+++ b/dlls/winhttp/request.c
@@ -2238,8 +2238,8 @@ static void free_request( struct winhttp_request *request )
     CloseHandle( request->thread );
     CloseHandle( request->wait );
     CloseHandle( request->cancel );
-    heap_free( (WCHAR *)request->proxy.lpszProxy );
-    heap_free( (WCHAR *)request->proxy.lpszProxyBypass );
+    heap_free( request->proxy.lpszProxy );
+    heap_free( request->proxy.lpszProxyBypass );
     heap_free( request->buffer );
     heap_free( request->verb );
     VariantClear( &request->data );
@@ -2430,16 +2430,16 @@ static HRESULT WINAPI winhttp_request_SetProxy(
     {
     case HTTPREQUEST_PROXYSETTING_DEFAULT:
         request->proxy.dwAccessType = WINHTTP_ACCESS_TYPE_DEFAULT_PROXY;
-        heap_free( (WCHAR *)request->proxy.lpszProxy );
-        heap_free( (WCHAR *)request->proxy.lpszProxyBypass );
+        heap_free( request->proxy.lpszProxy );
+        heap_free( request->proxy.lpszProxyBypass );
         request->proxy.lpszProxy = NULL;
         request->proxy.lpszProxyBypass = NULL;
         break;
 
     case HTTPREQUEST_PROXYSETTING_DIRECT:
         request->proxy.dwAccessType = WINHTTP_ACCESS_TYPE_NO_PROXY;
-        heap_free( (WCHAR *)request->proxy.lpszProxy );
-        heap_free( (WCHAR *)request->proxy.lpszProxyBypass );
+        heap_free( request->proxy.lpszProxy );
+        heap_free( request->proxy.lpszProxyBypass );
         request->proxy.lpszProxy = NULL;
         request->proxy.lpszProxyBypass = NULL;
         break;
@@ -2448,12 +2448,12 @@ static HRESULT WINAPI winhttp_request_SetProxy(
         request->proxy.dwAccessType = WINHTTP_ACCESS_TYPE_NAMED_PROXY;
         if (V_VT( &proxy_server ) == VT_BSTR)
         {
-            heap_free( (WCHAR *)request->proxy.lpszProxy );
+            heap_free( request->proxy.lpszProxy );
             request->proxy.lpszProxy = strdupW( V_BSTR( &proxy_server ) );
         }
         if (V_VT( &bypass_list ) == VT_BSTR)
         {
-            heap_free( (WCHAR *)request->proxy.lpszProxyBypass );
+            heap_free( request->proxy.lpszProxyBypass );
             request->proxy.lpszProxyBypass = strdupW( V_BSTR( &bypass_list ) );
         }
         break;
diff --git a/dlls/winhttp/session.c b/dlls/winhttp/session.c
index b4a46e0..e3e5e2b 100644
--- a/dlls/winhttp/session.c
+++ b/dlls/winhttp/session.c
@@ -229,14 +229,14 @@ HINTERNET WINAPI WinHttpOpen( LPCWSTR agent, DWORD access, LPCWSTR proxy, LPCWST
         session->access = info.dwAccessType;
         if (info.lpszProxy && !(session->proxy_server = strdupW( info.lpszProxy )))
         {
-            GlobalFree( (LPWSTR)info.lpszProxy );
-            GlobalFree( (LPWSTR)info.lpszProxyBypass );
+            GlobalFree( info.lpszProxy );
+            GlobalFree( info.lpszProxyBypass );
             goto end;
         }
         if (info.lpszProxyBypass && !(session->proxy_bypass = strdupW( info.lpszProxyBypass )))
         {
-            GlobalFree( (LPWSTR)info.lpszProxy );
-            GlobalFree( (LPWSTR)info.lpszProxyBypass );
+            GlobalFree( info.lpszProxy );
+            GlobalFree( info.lpszProxyBypass );
             goto end;
         }
     }
diff --git a/dlls/winhttp/tests/notification.c b/dlls/winhttp/tests/notification.c
index 84a3569..8ef2115 100644
--- a/dlls/winhttp/tests/notification.c
+++ b/dlls/winhttp/tests/notification.c
@@ -68,9 +68,9 @@ static BOOL proxy_active(void)
     {
         active = (proxy_info.lpszProxy != NULL);
         if (active)
-            GlobalFree((HGLOBAL) proxy_info.lpszProxy);
+            GlobalFree(proxy_info.lpszProxy);
         if (proxy_info.lpszProxyBypass != NULL)
-            GlobalFree((HGLOBAL) proxy_info.lpszProxyBypass);
+            GlobalFree(proxy_info.lpszProxyBypass);
     }
     else
        active = FALSE;
diff --git a/dlls/winhttp/tests/winhttp.c b/dlls/winhttp/tests/winhttp.c
index 9d75dbf..ce93dd8 100644
--- a/dlls/winhttp/tests/winhttp.c
+++ b/dlls/winhttp/tests/winhttp.c
@@ -46,9 +46,9 @@ static BOOL proxy_active(void)
     {
         active = (proxy_info.lpszProxy != NULL);
         if (active)
-            GlobalFree((HGLOBAL) proxy_info.lpszProxy);
+            GlobalFree(proxy_info.lpszProxy);
         if (proxy_info.lpszProxyBypass != NULL)
-            GlobalFree((HGLOBAL) proxy_info.lpszProxyBypass);
+            GlobalFree(proxy_info.lpszProxyBypass);
     }
     else
        active = FALSE;
@@ -2699,8 +2699,8 @@ static void test_WinHttpGetProxyForUrl(void)
         trace("%u\n", info.dwAccessType);
         trace("%s\n", wine_dbgstr_w(info.lpszProxy));
         trace("%s\n", wine_dbgstr_w(info.lpszProxyBypass));
-        GlobalFree( (WCHAR *)info.lpszProxy );
-        GlobalFree( (WCHAR *)info.lpszProxyBypass );
+        GlobalFree( info.lpszProxy );
+        GlobalFree( info.lpszProxyBypass );
     }
     WinHttpCloseHandle( session );
 }
diff --git a/include/winhttp.h b/include/winhttp.h
index b54bd92..cf0da83 100644
--- a/include/winhttp.h
+++ b/include/winhttp.h
@@ -487,8 +487,8 @@ typedef struct
 typedef struct
 {
     DWORD dwAccessType;
-    LPCWSTR lpszProxy;
-    LPCWSTR lpszProxyBypass;
+    LPWSTR lpszProxy;
+    LPWSTR lpszProxyBypass;
 } WINHTTP_PROXY_INFO, *LPWINHTTP_PROXY_INFO;
 typedef WINHTTP_PROXY_INFO WINHTTP_PROXY_INFOW;
 typedef LPWINHTTP_PROXY_INFO LPWINHTTP_PROXY_INFOW;
-- 
1.7.9.1




More information about the wine-patches mailing list