Signed-off-by: Michael Stefaniuc mstefani@winehq.org --- dlls/serialui/confdlg.c | 26 +++++++------------------- dlls/serialui/tests/confdlg.c | 18 +++++++----------- 2 files changed, 14 insertions(+), 30 deletions(-)
diff --git a/dlls/serialui/confdlg.c b/dlls/serialui/confdlg.c index 45419edb421..23c9eb68c2a 100644 --- a/dlls/serialui/confdlg.c +++ b/dlls/serialui/confdlg.c @@ -46,8 +46,6 @@ WINE_DEFAULT_DEBUG_CHANNEL(comm);
static HMODULE SERIALUI_hModule;
-static const WCHAR comW[] = {'c','o','m',0 }; - /*********************************************************************** * DllMain [Internal] Initializes the internal 'SERIALUI.DLL'. * @@ -463,13 +461,7 @@ DWORD WINAPI drvCommConfigDialogA(LPCSTR lpszName, HWND hWndParent, LPCOMMCONFIG return r; }
-static const WCHAR lpszCommKey[] = { - 'S','y','s','t','e','m','\', - 'C','u','r','r','e','n','t','C','o','n','t','r','o','l','S','e','t','\', - 'S','e','r','v','i','c','e','s','\', - 'C','l','a','s','s','\','P','o','r','t','s',0 -}; -static const WCHAR lpszDCB[] = {'D','C','B',0}; +static const WCHAR lpszCommKey[] = L"System\CurrentControlSet\Services\Class\Ports";
/*********************************************************************** * drvSetDefaultCommConfigW (SERIALUI.@) @@ -484,7 +476,6 @@ BOOL WINAPI drvSetDefaultCommConfigW( HKEY hKeyReg=0, hKeyPort=0; WCHAR szKeyName[100]; DWORD r,dwDCBSize; - static const WCHAR fmt[] = {'%','s','\','%','s',0 };
TRACE("%p %p %x\n",lpszDevice,lpCommConfig,dwSize);
@@ -498,13 +489,12 @@ BOOL WINAPI drvSetDefaultCommConfigW( if(r != ERROR_SUCCESS) return FALSE;
- swprintf(szKeyName, ARRAY_SIZE(szKeyName), fmt, lpszCommKey, lpszDevice); + swprintf(szKeyName, ARRAY_SIZE(szKeyName), L"%s\%s", lpszCommKey, lpszDevice); r = RegCreateKeyW(hKeyReg, szKeyName, &hKeyPort); if(r == ERROR_SUCCESS) { dwDCBSize = sizeof (DCB); - r = RegSetValueExW( hKeyPort, lpszDCB, 0, REG_BINARY, - (LPBYTE)&lpCommConfig->dcb,dwDCBSize); + r = RegSetValueExW(hKeyPort, L"DCB", 0, REG_BINARY, (BYTE *)&lpCommConfig->dcb, dwDCBSize); TRACE("write key r=%d\n",r); RegCloseKey(hKeyPort); } @@ -539,7 +529,6 @@ DWORD WINAPI drvGetDefaultCommConfigW( HKEY hKeyReg, hKeyPort; WCHAR szKeyName[100]; DWORD r,dwSize,dwType; - static const WCHAR fmt[] = {'%','s','\','%','s',0 };
TRACE("(%s, %p, %p) *lpdwSize: %u\n", debugstr_w(lpszDevice), lpCommConfig, lpdwSize, lpdwSize ? *lpdwSize : 0);
@@ -553,11 +542,11 @@ DWORD WINAPI drvGetDefaultCommConfigW( }
/* only "com1" - "com9" is allowed */ - r = ARRAY_SIZE(comW); /* len of "com\0" */ + r = ARRAY_SIZE(L"com"); lstrcpynW(szKeyName, lpszDevice, r); /* simulate a lstrcmpnW */ r--;
- if( lstrcmpiW(szKeyName, comW) || + if (lstrcmpiW(szKeyName, L"com") || (lpszDevice[r] < '1') || (lpszDevice[r] > '9') || lpszDevice[r+1]) { return ERROR_BADKEY; } @@ -571,14 +560,13 @@ DWORD WINAPI drvGetDefaultCommConfigW( r = RegConnectRegistryW(NULL, HKEY_LOCAL_MACHINE, &hKeyReg); if(r != ERROR_SUCCESS) return r;
- swprintf(szKeyName, ARRAY_SIZE(szKeyName), fmt, lpszCommKey, lpszDevice); + swprintf(szKeyName, ARRAY_SIZE(szKeyName), L"%s\%s", lpszCommKey, lpszDevice); r = RegOpenKeyW(hKeyReg, szKeyName, &hKeyPort); if(r == ERROR_SUCCESS) { dwSize = sizeof (DCB); dwType = 0; - r = RegQueryValueExW( hKeyPort, lpszDCB, NULL, - &dwType, (LPBYTE)&lpCommConfig->dcb, &dwSize); + r = RegQueryValueExW(hKeyPort, L"DCB", NULL, &dwType, (BYTE *)&lpCommConfig->dcb, &dwSize);
RegCloseKey(hKeyPort); if ((r!=ERROR_SUCCESS) || (dwType != REG_BINARY) || (dwSize != sizeof(DCB))) { diff --git a/dlls/serialui/tests/confdlg.c b/dlls/serialui/tests/confdlg.c index bd541cda2b9..31669085d47 100644 --- a/dlls/serialui/tests/confdlg.c +++ b/dlls/serialui/tests/confdlg.c @@ -42,10 +42,6 @@ static const CHAR emptyA[] = ""; static const CHAR fmt_comA[] = "com%d"; static const CHAR str_colonA[] = ":";
-static const WCHAR com1W[] = {'c','o','m','1',0}; -static const WCHAR emptyW[] = {0}; -static const WCHAR str_colonW[] = {':',0}; - /* ################# */
static LPCSTR load_functions(void) @@ -202,7 +198,7 @@ static void test_drvCommConfigDialogW(void)
ZeroMemory(pCC, sizeof(pCC)); SetLastError(0xdeadbeef); - res = pCommConfigDialogW(emptyW, NULL, pCC); + res = pCommConfigDialogW(L"", NULL, pCC); ok( res == ERROR_INSUFFICIENT_BUFFER, "returned %u with %u (expected ERROR_INSUFFICIENT_BUFFER)\n", res, GetLastError()); @@ -211,7 +207,7 @@ static void test_drvCommConfigDialogW(void) ZeroMemory(pCC, sizeof(pCC)); pCC[0].dwSize = sizeof(COMMCONFIG); SetLastError(0xdeadbeef); - res = pCommConfigDialogW(emptyW, NULL, pCC); + res = pCommConfigDialogW(L"", NULL, pCC); ok( res == ERROR_BADKEY, "returned %u with %u (expected ERROR_BADKEY)\n", res, GetLastError());
@@ -334,7 +330,7 @@ static void test_drvGetDefaultCommConfigW(void) len = sizeof(COMMCONFIG) -1; ZeroMemory(pCC, sizeof(pCC)); SetLastError(0xdeadbeef); - res = pGetDefaultCommConfigW(com1W, pCC, &len); + res = pGetDefaultCommConfigW(L"com1", pCC, &len); if (res == ERROR_CALL_NOT_IMPLEMENTED) { win_skip("*W not implemented\n"); return; @@ -366,7 +362,7 @@ static void test_drvGetDefaultCommConfigW(void) /* a name with a colon is invalid */ if (res == ERROR_SUCCESS) { lstrcatA(bufferA, str_colonA); - lstrcatW(bufferW, str_colonW); + lstrcatW(bufferW, L":"); len = sizeof(pCC); ZeroMemory(pCC, sizeof(pCC)); res = pGetDefaultCommConfigW(bufferW, pCC, &len); @@ -380,7 +376,7 @@ static void test_drvGetDefaultCommConfigW(void) len = sizeof(pCC); ZeroMemory(pCC, sizeof(pCC)); SetLastError(0xdeadbeef); - res = pGetDefaultCommConfigW(emptyW, pCC, &len); + res = pGetDefaultCommConfigW(L"", pCC, &len); ok( res == ERROR_BADKEY, "returned %u with %u and %u for %s (expected ERROR_BADKEY)\n", res, GetLastError(), len, emptyA); @@ -397,14 +393,14 @@ static void test_drvGetDefaultCommConfigW(void)
len = sizeof(pCC); SetLastError(0xdeadbeef); - res = pGetDefaultCommConfigW(com1W, NULL, &len); + res = pGetDefaultCommConfigW(L"com1", NULL, &len); ok( res == ERROR_INVALID_PARAMETER, "returned %u with %u and %u (expected ERROR_INVALID_PARAMETER)\n", res, GetLastError(), len);
SetLastError(0xdeadbeef); - res = pGetDefaultCommConfigW(com1W, pCC, NULL); + res = pGetDefaultCommConfigW(L"com1", pCC, NULL); ok( res == ERROR_INVALID_PARAMETER, "returned %u with %u (expected ERROR_INVALID_PARAMETER)\n", res, GetLastError());