[PATCH] msacm32: Use the ARRAY_SIZE() macro

Michael Stefaniuc mstefani at winehq.org
Wed Jul 25 17:05:50 CDT 2018


Signed-off-by: Michael Stefaniuc <mstefani at winehq.org>
---
 dlls/msacm32/filter.c       |  4 ++--
 dlls/msacm32/format.c       | 18 +++++++++---------
 dlls/msacm32/internal.c     | 14 +++++++-------
 dlls/msacm32/pcmconverter.c | 15 +++++++--------
 dlls/msacm32/tests/msacm.c  |  2 +-
 5 files changed, 26 insertions(+), 27 deletions(-)

diff --git a/dlls/msacm32/filter.c b/dlls/msacm32/filter.c
index 53db82777d..8d5abced9d 100644
--- a/dlls/msacm32/filter.c
+++ b/dlls/msacm32/filter.c
@@ -361,8 +361,8 @@ MMRESULT WINAPI acmFilterTagDetailsW(HACMDRIVER had, PACMFILTERTAGDETAILSW paftd
 
     if (mmr == MMSYSERR_NOERROR &&
 	paftd->dwFilterTag == WAVE_FORMAT_PCM && paftd->szFilterTag[0] == 0)
-        MultiByteToWideChar( CP_ACP, 0, "PCM", -1, paftd->szFilterTag,
-                             sizeof(paftd->szFilterTag)/sizeof(WCHAR) );
+        MultiByteToWideChar(CP_ACP, 0, "PCM", -1, paftd->szFilterTag,
+                            ARRAY_SIZE(paftd->szFilterTag));
 
     return mmr;
 }
diff --git a/dlls/msacm32/format.c b/dlls/msacm32/format.c
index b3d2900393..fcc0d9b1c6 100644
--- a/dlls/msacm32/format.c
+++ b/dlls/msacm32/format.c
@@ -503,9 +503,9 @@ MMRESULT WINAPI acmFormatDetailsW(HACMDRIVER had, PACMFORMATDETAILSW pafd, DWORD
 	    wsprintfW(pafd->szFormat + lstrlenW(pafd->szFormat), fmt2,
 		      pafd->pwfx->wBitsPerSample);
 	}
-        MultiByteToWideChar( CP_ACP, 0, (pafd->pwfx->nChannels == 1) ? "; Mono" : "; Stereo", -1,
-                             pafd->szFormat + strlenW(pafd->szFormat),
-                             sizeof(pafd->szFormat)/sizeof(WCHAR) - strlenW(pafd->szFormat) );
+        MultiByteToWideChar(CP_ACP, 0, (pafd->pwfx->nChannels == 1) ? "; Mono" : "; Stereo", -1,
+                            pafd->szFormat + strlenW(pafd->szFormat),
+                            ARRAY_SIZE(pafd->szFormat) - strlenW(pafd->szFormat));
     }
 
     TRACE("=> %d\n", mmr);
@@ -929,8 +929,8 @@ MMRESULT WINAPI acmFormatTagDetailsW(HACMDRIVER had, PACMFORMATTAGDETAILSW paftd
 
     if (mmr == MMSYSERR_NOERROR &&
 	paftd->dwFormatTag == WAVE_FORMAT_PCM && paftd->szFormatTag[0] == 0)
-        MultiByteToWideChar( CP_ACP, 0, "PCM", -1, paftd->szFormatTag,
-                             sizeof(paftd->szFormatTag)/sizeof(WCHAR) );
+        MultiByteToWideChar(CP_ACP, 0, "PCM", -1, paftd->szFormatTag,
+                            ARRAY_SIZE(paftd->szFormatTag));
 
     return mmr;
 }
@@ -1036,8 +1036,8 @@ MMRESULT WINAPI acmFormatTagEnumW(HACMDRIVER had, PACMFORMATTAGDETAILSW paftd,
                 (LPARAM)paftd, ACM_FORMATTAGDETAILSF_INDEX) == MMSYSERR_NOERROR) {
                 if (paftd->dwFormatTag == WAVE_FORMAT_PCM) {
                     if (paftd->szFormatTag[0] == 0)
-                        MultiByteToWideChar( CP_ACP, 0, "PCM", -1, paftd->szFormatTag,
-                                            sizeof(paftd->szFormatTag)/sizeof(WCHAR) );
+                        MultiByteToWideChar(CP_ACP, 0, "PCM", -1, paftd->szFormatTag,
+                                            ARRAY_SIZE(paftd->szFormatTag));
                     /* (WS) I'm preserving this PCM hack since it seems to be
                      * correct. Please notice this block was borrowed from
                      * below.
@@ -1062,8 +1062,8 @@ MMRESULT WINAPI acmFormatTagEnumW(HACMDRIVER had, PACMFORMATTAGDETAILSW paftd,
                         (LPARAM)paftd, ACM_FORMATTAGDETAILSF_INDEX) == MMSYSERR_NOERROR) {
                         if (paftd->dwFormatTag == WAVE_FORMAT_PCM) {
                             if (paftd->szFormatTag[0] == 0)
-                                MultiByteToWideChar( CP_ACP, 0, "PCM", -1, paftd->szFormatTag,
-                                                     sizeof(paftd->szFormatTag)/sizeof(WCHAR) );
+                                MultiByteToWideChar(CP_ACP, 0, "PCM", -1, paftd->szFormatTag,
+                                                    ARRAY_SIZE(paftd->szFormatTag));
                             /* FIXME (EPP): I'm not sure this is the correct
                              * algorithm (should make more sense to apply the same
                              * for all already loaded formats, but this will do
diff --git a/dlls/msacm32/internal.c b/dlls/msacm32/internal.c
index 7bafcaad5e..aad071e8ad 100644
--- a/dlls/msacm32/internal.c
+++ b/dlls/msacm32/internal.c
@@ -72,7 +72,7 @@ PWINE_ACMDRIVERID MSACM_RegisterDriverFromRegistry(LPCWSTR pszRegEntry)
     /* The requested registry entry must have the format msacm.XXXXX in order to
        be recognized in any future sessions of msacm
      */
-    if (0 == strncmpiW(pszRegEntry, msacmW, sizeof(msacmW)/sizeof(WCHAR))) {
+    if (0 == strncmpiW(pszRegEntry, msacmW, ARRAY_SIZE(msacmW))) {
         lRet = RegOpenKeyExW(HKEY_LOCAL_MACHINE, drvkey, 0, KEY_QUERY_VALUE, &hKey);
         if (lRet != ERROR_SUCCESS) {
             WARN("unable to open registry key - 0x%08x\n", lRet);
@@ -373,31 +373,31 @@ void MSACM_RegisterAllDrivers(void)
     if (lRet == ERROR_SUCCESS) {
 	RegQueryInfoKeyW( hKey, 0, 0, 0, &cnt, 0, 0, 0, 0, 0, 0, 0);
 	for (i = 0; i < cnt; i++) {
-	    bufLen = sizeof(buf) / sizeof(buf[0]);
+	    bufLen = ARRAY_SIZE(buf);
 	    lRet = RegEnumKeyExW(hKey, i, buf, &bufLen, 0, 0, 0, &lastWrite);
 	    if (lRet != ERROR_SUCCESS) continue;
-	    if (strncmpiW(buf, msacmW, sizeof(msacmW)/sizeof(msacmW[0]))) continue;
+	    if (strncmpiW(buf, msacmW, ARRAY_SIZE(msacmW))) continue;
 	    if (!(name = strchrW(buf, '='))) continue;
 	    *name = 0;
 	    MSACM_RegisterDriver(buf, name + 1, 0);
 	}
 	i = 0;
-	cnt = sizeof(valname) / sizeof(*valname);
+	cnt = ARRAY_SIZE(valname);
 	bufLen = sizeof(buf);
 	while(RegEnumValueW(hKey, i, valname, &cnt, 0,
 		    &type, (BYTE*)buf, &bufLen) == ERROR_SUCCESS){
-	    if(!strncmpiW(valname, msacmW, sizeof(msacmW) / sizeof(*msacmW)))
+	    if (!strncmpiW(valname, msacmW, ARRAY_SIZE(msacmW)))
 		MSACM_RegisterDriver(valname, buf, 0);
 	    ++i;
 	}
     	RegCloseKey( hKey );
     }
 
-    if (GetPrivateProfileSectionW(drv32, buf, sizeof(buf)/sizeof(buf[0]), sys))
+    if (GetPrivateProfileSectionW(drv32, buf, ARRAY_SIZE(buf), sys))
     {
 	for(s = buf; *s;  s += strlenW(s) + 1)
 	{
-	    if (strncmpiW(s, msacmW, sizeof(msacmW)/sizeof(msacmW[0]))) continue;
+	    if (strncmpiW(s, msacmW, ARRAY_SIZE(msacmW))) continue;
 	    if (!(name = strchrW(s, '='))) continue;
 	    *name = 0;
 	    MSACM_RegisterDriver(s, name + 1, 0);
diff --git a/dlls/msacm32/pcmconverter.c b/dlls/msacm32/pcmconverter.c
index f26f125fcd..dc10f11e7a 100644
--- a/dlls/msacm32/pcmconverter.c
+++ b/dlls/msacm32/pcmconverter.c
@@ -984,14 +984,13 @@ static	LRESULT PCM_DriverDetails(PACMDRIVERDETAILSW add)
     add->cFormatTags = 1;
     add->cFilterTags = 0;
     add->hicon = NULL;
-    MultiByteToWideChar( CP_ACP, 0, "MS-PCM", -1,
-                         add->szShortName, sizeof(add->szShortName)/sizeof(WCHAR) );
-    MultiByteToWideChar( CP_ACP, 0, "Wine PCM converter", -1,
-                         add->szLongName, sizeof(add->szLongName)/sizeof(WCHAR) );
-    MultiByteToWideChar( CP_ACP, 0, "Brought to you by the Wine team...", -1,
-                         add->szCopyright, sizeof(add->szCopyright)/sizeof(WCHAR) );
-    MultiByteToWideChar( CP_ACP, 0, "Refer to LICENSE file", -1,
-                         add->szLicensing, sizeof(add->szLicensing)/sizeof(WCHAR) );
+    MultiByteToWideChar(CP_ACP, 0, "MS-PCM", -1, add->szShortName, ARRAY_SIZE(add->szShortName));
+    MultiByteToWideChar(CP_ACP, 0, "Wine PCM converter", -1,
+                        add->szLongName, ARRAY_SIZE(add->szLongName));
+    MultiByteToWideChar(CP_ACP, 0, "Brought to you by the Wine team...", -1,
+                        add->szCopyright, ARRAY_SIZE(add->szCopyright));
+    MultiByteToWideChar(CP_ACP, 0, "Refer to LICENSE file", -1,
+                        add->szLicensing, ARRAY_SIZE(add->szLicensing) );
     add->szFeatures[0] = 0;
 
     return MMSYSERR_NOERROR;
diff --git a/dlls/msacm32/tests/msacm.c b/dlls/msacm32/tests/msacm.c
index 959ec7f0c0..180639fa54 100644
--- a/dlls/msacm32/tests/msacm.c
+++ b/dlls/msacm32/tests/msacm.c
@@ -1106,7 +1106,7 @@ static void test_convert(void)
     MMRESULT mmr;
     unsigned i;
 
-    for (i = 0; i < sizeof(expected_output)/sizeof(struct stream_output); i++)
+    for (i = 0; i < ARRAY_SIZE(expected_output); i++)
     {
         mmr = acmStreamOpen(&has, NULL, (WAVEFORMATEX *)&expected_output[i].src, (WAVEFORMATEX *)&expected_output[i].dst, NULL, 0, 0, 0);
         ok(mmr == MMSYSERR_NOERROR, "#%d: open failed: 0x%x\n", i, mmr);
-- 
2.14.4




More information about the wine-devel mailing list