Alexandre Julliard : setupapi: Simplify the SetupDiGetClassDescriptionExA/ W implementation.

Alexandre Julliard julliard at winehq.org
Fri Sep 21 07:23:08 CDT 2007


Module: wine
Branch: master
Commit: 5d0dc4819336dd99537206a151e3f79285136b71
URL:    http://source.winehq.org/git/wine.git/?a=commit;h=5d0dc4819336dd99537206a151e3f79285136b71

Author: Alexandre Julliard <julliard at winehq.org>
Date:   Fri Sep 21 12:21:17 2007 +0200

setupapi: Simplify the SetupDiGetClassDescriptionExA/W implementation.

---

 dlls/setupapi/devinst.c |   70 +++++++----------------------------------------
 1 files changed, 10 insertions(+), 60 deletions(-)

diff --git a/dlls/setupapi/devinst.c b/dlls/setupapi/devinst.c
index dc92431..bc51c2a 100644
--- a/dlls/setupapi/devinst.c
+++ b/dlls/setupapi/devinst.c
@@ -1373,6 +1373,7 @@ BOOL WINAPI SetupDiGetClassDescriptionExA(
 {
     HKEY hKey;
     DWORD dwLength;
+    BOOL ret;
 
     hKey = SetupDiOpenClassRegKeyExA(ClassGuid,
                                      KEY_ALL_ACCESS,
@@ -1385,38 +1386,12 @@ BOOL WINAPI SetupDiGetClassDescriptionExA(
 	return FALSE;
     }
 
-    if (RequiredSize != NULL)
-    {
-	dwLength = 0;
-	if (RegQueryValueExA(hKey,
-			     NULL,
-			     NULL,
-			     NULL,
-			     NULL,
-			     &dwLength))
-	{
-	    RegCloseKey(hKey);
-	    return FALSE;
-	}
-
-	*RequiredSize = dwLength;
-    }
-
     dwLength = ClassDescriptionSize;
-    if (RegQueryValueExA(hKey,
-			 NULL,
-			 NULL,
-			 NULL,
-			 (LPBYTE)ClassDescription,
-			 &dwLength))
-    {
-	RegCloseKey(hKey);
-	return FALSE;
-    }
-
+    ret = !RegQueryValueExA( hKey, NULL, NULL, NULL,
+                             (LPBYTE)ClassDescription, &dwLength );
+    if (RequiredSize) *RequiredSize = dwLength;
     RegCloseKey(hKey);
-
-    return TRUE;
+    return ret;
 }
 
 /***********************************************************************
@@ -1432,6 +1407,7 @@ BOOL WINAPI SetupDiGetClassDescriptionExW(
 {
     HKEY hKey;
     DWORD dwLength;
+    BOOL ret;
 
     hKey = SetupDiOpenClassRegKeyExW(ClassGuid,
                                      KEY_ALL_ACCESS,
@@ -1444,38 +1420,12 @@ BOOL WINAPI SetupDiGetClassDescriptionExW(
 	return FALSE;
     }
 
-    if (RequiredSize != NULL)
-    {
-	dwLength = 0;
-	if (RegQueryValueExW(hKey,
-			     NULL,
-			     NULL,
-			     NULL,
-			     NULL,
-			     &dwLength))
-	{
-	    RegCloseKey(hKey);
-	    return FALSE;
-	}
-
-	*RequiredSize = dwLength / sizeof(WCHAR);
-    }
-
     dwLength = ClassDescriptionSize * sizeof(WCHAR);
-    if (RegQueryValueExW(hKey,
-			 NULL,
-			 NULL,
-			 NULL,
-			 (LPBYTE)ClassDescription,
-			 &dwLength))
-    {
-	RegCloseKey(hKey);
-	return FALSE;
-    }
-
+    ret = !RegQueryValueExW( hKey, NULL, NULL, NULL,
+                             (LPBYTE)ClassDescription, &dwLength );
+    if (RequiredSize) *RequiredSize = dwLength / sizeof(WCHAR);
     RegCloseKey(hKey);
-
-    return TRUE;
+    return ret;
 }
 
 /***********************************************************************




More information about the wine-cvs mailing list