[PATCH v2] dmloader: Use wide-char string literals

Michael Stefaniuc mstefani at winehq.org
Tue Dec 17 14:45:04 CST 2019


Signed-off-by: Michael Stefaniuc <mstefani at winehq.org>
---
v2: Keep some variables to avoid casts.


Alexandre, feel free to just apply the test portion. I'll resubmit after
the freeze; better for my commit count anyway ;)

bye
        michael


 dlls/dmloader/loader.c       |  8 ++++----
 dlls/dmloader/tests/loader.c | 11 +++++------
 2 files changed, 9 insertions(+), 10 deletions(-)

diff --git a/dlls/dmloader/loader.c b/dlls/dmloader/loader.c
index 51eeb57879..c5f5094fab 100644
--- a/dlls/dmloader/loader.c
+++ b/dlls/dmloader/loader.c
@@ -621,7 +621,6 @@ static HRESULT WINAPI IDirectMusicLoaderImpl_SetSearchDirectory(IDirectMusicLoad
 static HRESULT WINAPI IDirectMusicLoaderImpl_ScanDirectory(IDirectMusicLoader8 *iface, REFGUID rguidClass, WCHAR *pwzFileExtension, WCHAR *pwzScanFileName)
 {
 	IDirectMusicLoaderImpl *This = impl_from_IDirectMusicLoader8(iface);
-	static const WCHAR wszAny[] = {'*',0};
 	WIN32_FIND_DATAW FileData;
 	HANDLE hSearch;
 	WCHAR wszSearchString[MAX_PATH];
@@ -643,11 +642,12 @@ static HRESULT WINAPI IDirectMusicLoaderImpl_ScanDirectory(IDirectMusicLoader8 *
 	p = wszSearchString + lstrlenW(wszSearchString);
 	if (p > wszSearchString && p[-1] != '\\') *p++ = '\\';
 	*p++ = '*'; /* any file */
-	if (lstrcmpW (pwzFileExtension, wszAny)) *p++ = '.'; /* if we have actual extension, put a dot */
+        if (lstrcmpW (pwzFileExtension, L"*"))
+                *p++ = '.'; /* if we have actual extension, put a dot */
 	lstrcpyW (p, pwzFileExtension);
-	
+
 	TRACE(": search string: %s\n", debugstr_w(wszSearchString));
-	
+
 	hSearch = FindFirstFileW (wszSearchString, &FileData);
 	if (hSearch == INVALID_HANDLE_VALUE) {
 		TRACE(": no files found\n");
diff --git a/dlls/dmloader/tests/loader.c b/dlls/dmloader/tests/loader.c
index 0ab2e9eaba..418a4ebb7a 100644
--- a/dlls/dmloader/tests/loader.c
+++ b/dlls/dmloader/tests/loader.c
@@ -48,10 +48,10 @@ static void test_directory(void)
 {
     IDirectMusicLoader8 *loader = NULL;
     HRESULT hr;
-    WCHAR con[] = {'c', 'o', 'n', 0};
+    WCHAR con[] = L"con";
+    WCHAR empty[] = L"";
+    WCHAR invalid_path[] = L"/invalid path";
     WCHAR path[MAX_PATH];
-    WCHAR empty[] = {0};
-    WCHAR invalid_path[] = {'/', 'i', 'n', 'v', 'a', 'l', 'i', 'd', ' ', 'p', 'a', 't', 'h', 0};
 
     hr = CoCreateInstance(&CLSID_DirectMusicLoader, NULL, CLSCTX_INPROC, &IID_IDirectMusicLoader8,
             (void**)&loader);
@@ -477,7 +477,6 @@ static void test_parsedescriptor(void)
     DMUS_OBJECTDESC desc;
     HRESULT hr;
     DWORD valid;
-    const WCHAR s_unam[] = {'U','N','A','M','\0'};
     const FOURCC alldesc[] =
     {
         FOURCC_RIFF, DMUS_FOURCC_CONTAINER_FORM, DMUS_FOURCC_CATEGORY_CHUNK, FOURCC_LIST,
@@ -562,7 +561,7 @@ static void test_parsedescriptor(void)
             wine_dbgstr_guid(&desc.guidClass));
     ok(IsEqualGUID(&desc.guidObject, &GUID_NULL), "Got object guid %s, expected GUID_NULL\n",
             wine_dbgstr_guid(&desc.guidClass));
-    ok(!memcmp(desc.wszName, s_unam, sizeof(s_unam)), "Got name '%s', expected 'UNAM'\n",
+    ok(!lstrcmpW(desc.wszName, L"UNAM"), "Got name '%s', expected 'UNAM'\n",
             wine_dbgstr_w(desc.wszName));
     IStream_Release(stream);
 
@@ -596,7 +595,7 @@ static void test_parsedescriptor(void)
     ok(hr == S_OK, "ParseDescriptor failed: %08x, expected S_OK\n", hr);
     valid = DMUS_OBJ_OBJECT|DMUS_OBJ_CLASS|DMUS_OBJ_NAME|DMUS_OBJ_CATEGORY|DMUS_OBJ_VERSION;
     ok(desc.dwValidData == valid, "Got valid data %#x, expected %#x\n", desc.dwValidData, valid);
-    ok(!memcmp(desc.wszName, s_unam, sizeof(s_unam)), "Got name '%s', expected 'UNAM'\n",
+    ok(!lstrcmpW(desc.wszName, L"UNAM"), "Got name '%s', expected 'UNAM'\n",
             wine_dbgstr_w(desc.wszName));
     IStream_Release(stream);
 
-- 
2.23.0




More information about the wine-devel mailing list