Gert Doering has submitted this change. ( 
https://gerrit.openvpn.net/c/openvpn/+/2381?usp=email )

Change subject: tapctl: Fix sign conversion warnings
......................................................................

tapctl: Fix sign conversion warnings

- Mostly related to the annoying LSTATUS return
  value of Reg* functions.
- Fixes one actual bug where get_reg_string could
  return ERROR_SUCCESS when ExpandEnvironmentStrings
  failed. But not sure how to trigger that.

Change-Id: I473c876cecffb4d057f6ffb23e50c3274de95989
Signed-off-by: Frank Lichtenheld <[email protected]>
Acked-by: Razvan Cojocaru <[email protected]>
Gerrit URL: https://gerrit.openvpn.net/c/openvpn/+/2381
Message-Id: <[email protected]>
URL: 
https://www.mail-archive.com/[email protected]/msg42324.html
Signed-off-by: Gert Doering <[email protected]>
---
M src/tapctl/tap.c
1 file changed, 7 insertions(+), 15 deletions(-)




diff --git a/src/tapctl/tap.c b/src/tapctl/tap.c
index 672bd2d..5aac7ff 100644
--- a/src/tapctl/tap.c
+++ b/src/tapctl/tap.c
@@ -102,11 +102,6 @@
 }
 #endif

-#if defined(__GNUC__) || defined(__clang__)
-#pragma GCC diagnostic push
-#pragma GCC diagnostic ignored "-Wsign-conversion"
-#endif
-
 /**
  * Returns length of string of strings
  *
@@ -121,7 +116,7 @@
     for (s = szz; s[0]; s += wcslen(s) + 1)
     {
     }
-    return s - szz;
+    return (size_t)(s - szz);
 }


@@ -391,7 +386,7 @@
     }

     DWORD dwValueType = REG_NONE, dwSize = 0;
-    DWORD dwResult = RegQueryValueEx(hKey, szName, NULL, &dwValueType, NULL, 
&dwSize);
+    DWORD dwResult = (DWORD)RegQueryValueEx(hKey, szName, NULL, &dwValueType, 
NULL, &dwSize);
     if (dwResult != ERROR_SUCCESS)
     {
         /* MSDN does not mention RegQueryValueEx() to set GetLastError(). But
@@ -415,7 +410,7 @@
                 return ERROR_OUTOFMEMORY;
             }

-            dwResult = RegQueryValueEx(hKey, szName, NULL, NULL, 
(LPBYTE)szValue, &dwSize);
+            dwResult = (DWORD)RegQueryValueEx(hKey, szName, NULL, NULL, 
(LPBYTE)szValue, &dwSize);
             if (dwResult != ERROR_SUCCESS)
             {
                 SetLastError(dwResult);
@@ -441,6 +436,7 @@
                 DWORD dwCountExpResult = ExpandEnvironmentStrings(szValue, 
szValueExp, dwCountExp);
                 if (dwCountExpResult == 0)
                 {
+                    dwResult = GetLastError();
                     msg(M_NONFATAL | M_ERRNO, "%s: expanding \"%ls\" registry 
value failed",
                         __FUNCTION__, szName);
                     free(szValueExp);
@@ -533,7 +529,7 @@
         /* Query the NetCfgInstanceId value. Using get_reg_string() right on 
might clutter the
          * output with error messages while the registry is still being 
populated. */
         LPWSTR szCfgGuidString = NULL;
-        dwResult = RegQueryValueEx(hKey, L"NetCfgInstanceId", NULL, NULL, 
NULL, NULL);
+        dwResult = (DWORD)RegQueryValueEx(hKey, L"NetCfgInstanceId", NULL, 
NULL, NULL, NULL);
         if (dwResult != ERROR_SUCCESS)
         {
             if (dwResult == ERROR_FILE_NOT_FOUND && --iNumAttempts > 0)
@@ -953,7 +949,7 @@

     /* Open network adapter registry key. */
     HKEY hKey = NULL;
-    dwResult = RegOpenKeyEx(HKEY_LOCAL_MACHINE, szRegKey, 0, KEY_QUERY_VALUE, 
&hKey);
+    dwResult = (DWORD)RegOpenKeyEx(HKEY_LOCAL_MACHINE, szRegKey, 0, 
KEY_QUERY_VALUE, &hKey);
     if (dwResult != ERROR_SUCCESS)
     {
         SetLastError(dwResult);
@@ -1120,7 +1116,7 @@

         /* Open network adapter registry key. */
         HKEY hKey = NULL;
-        dwResult = RegOpenKeyEx(HKEY_LOCAL_MACHINE, szRegKey, 0, KEY_READ, 
&hKey);
+        dwResult = (DWORD)RegOpenKeyEx(HKEY_LOCAL_MACHINE, szRegKey, 0, 
KEY_READ, &hKey);
         if (dwResult != ERROR_SUCCESS)
         {
             SetLastError(dwResult);
@@ -1185,10 +1181,6 @@
     return dwResult;
 }

-#if defined(__GNUC__) || defined(__clang__)
-#pragma GCC diagnostic pop
-#endif
-
 void
 tap_free_adapter_list(_In_ struct tap_adapter_node *pAdapterList)
 {

--
To view, visit https://gerrit.openvpn.net/c/openvpn/+/2381?usp=email
To unsubscribe, or for help writing mail filters, visit 
https://gerrit.openvpn.net/settings?usp=email

Gerrit-MessageType: merged
Gerrit-Project: openvpn
Gerrit-Branch: master
Gerrit-Change-Id: I473c876cecffb4d057f6ffb23e50c3274de95989
Gerrit-Change-Number: 2381
Gerrit-PatchSet: 3
Gerrit-Owner: Frank Lichtenheld <[email protected]>
Gerrit-Reviewer: Arne Schwabe <[email protected]>
Gerrit-Reviewer: Răzvan Cojocaru <[email protected]>
Gerrit-CC: openvpn-devel <[email protected]>
_______________________________________________
Openvpn-devel mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/openvpn-devel

Reply via email to