msacm32: Use the ARRAY_SIZE() macro.

Signed-off-by: Michael Stefaniuc <mstefani@winehq.org>
Signed-off-by: Andrew Eikum <aeikum@codeweavers.com>
Signed-off-by: Alexandre Julliard <julliard@winehq.org>
This commit is contained in:
Michael Stefaniuc 2018-07-26 00:05:50 +02:00 committed by Alexandre Julliard
parent f1a0cb0b85
commit 077db39cec
5 changed files with 26 additions and 27 deletions

View File

@ -361,8 +361,8 @@ MMRESULT WINAPI acmFilterTagDetailsW(HACMDRIVER had, PACMFILTERTAGDETAILSW paftd
if (mmr == MMSYSERR_NOERROR && if (mmr == MMSYSERR_NOERROR &&
paftd->dwFilterTag == WAVE_FORMAT_PCM && paftd->szFilterTag[0] == 0) paftd->dwFilterTag == WAVE_FORMAT_PCM && paftd->szFilterTag[0] == 0)
MultiByteToWideChar( CP_ACP, 0, "PCM", -1, paftd->szFilterTag, MultiByteToWideChar(CP_ACP, 0, "PCM", -1, paftd->szFilterTag,
sizeof(paftd->szFilterTag)/sizeof(WCHAR) ); ARRAY_SIZE(paftd->szFilterTag));
return mmr; return mmr;
} }

View File

@ -503,9 +503,9 @@ MMRESULT WINAPI acmFormatDetailsW(HACMDRIVER had, PACMFORMATDETAILSW pafd, DWORD
wsprintfW(pafd->szFormat + lstrlenW(pafd->szFormat), fmt2, wsprintfW(pafd->szFormat + lstrlenW(pafd->szFormat), fmt2,
pafd->pwfx->wBitsPerSample); pafd->pwfx->wBitsPerSample);
} }
MultiByteToWideChar( CP_ACP, 0, (pafd->pwfx->nChannels == 1) ? "; Mono" : "; Stereo", -1, MultiByteToWideChar(CP_ACP, 0, (pafd->pwfx->nChannels == 1) ? "; Mono" : "; Stereo", -1,
pafd->szFormat + strlenW(pafd->szFormat), pafd->szFormat + strlenW(pafd->szFormat),
sizeof(pafd->szFormat)/sizeof(WCHAR) - strlenW(pafd->szFormat) ); ARRAY_SIZE(pafd->szFormat) - strlenW(pafd->szFormat));
} }
TRACE("=> %d\n", mmr); TRACE("=> %d\n", mmr);
@ -929,8 +929,8 @@ MMRESULT WINAPI acmFormatTagDetailsW(HACMDRIVER had, PACMFORMATTAGDETAILSW paftd
if (mmr == MMSYSERR_NOERROR && if (mmr == MMSYSERR_NOERROR &&
paftd->dwFormatTag == WAVE_FORMAT_PCM && paftd->szFormatTag[0] == 0) paftd->dwFormatTag == WAVE_FORMAT_PCM && paftd->szFormatTag[0] == 0)
MultiByteToWideChar( CP_ACP, 0, "PCM", -1, paftd->szFormatTag, MultiByteToWideChar(CP_ACP, 0, "PCM", -1, paftd->szFormatTag,
sizeof(paftd->szFormatTag)/sizeof(WCHAR) ); ARRAY_SIZE(paftd->szFormatTag));
return mmr; return mmr;
} }
@ -1036,8 +1036,8 @@ MMRESULT WINAPI acmFormatTagEnumW(HACMDRIVER had, PACMFORMATTAGDETAILSW paftd,
(LPARAM)paftd, ACM_FORMATTAGDETAILSF_INDEX) == MMSYSERR_NOERROR) { (LPARAM)paftd, ACM_FORMATTAGDETAILSF_INDEX) == MMSYSERR_NOERROR) {
if (paftd->dwFormatTag == WAVE_FORMAT_PCM) { if (paftd->dwFormatTag == WAVE_FORMAT_PCM) {
if (paftd->szFormatTag[0] == 0) if (paftd->szFormatTag[0] == 0)
MultiByteToWideChar( CP_ACP, 0, "PCM", -1, paftd->szFormatTag, MultiByteToWideChar(CP_ACP, 0, "PCM", -1, paftd->szFormatTag,
sizeof(paftd->szFormatTag)/sizeof(WCHAR) ); ARRAY_SIZE(paftd->szFormatTag));
/* (WS) I'm preserving this PCM hack since it seems to be /* (WS) I'm preserving this PCM hack since it seems to be
* correct. Please notice this block was borrowed from * correct. Please notice this block was borrowed from
* below. * below.
@ -1062,8 +1062,8 @@ MMRESULT WINAPI acmFormatTagEnumW(HACMDRIVER had, PACMFORMATTAGDETAILSW paftd,
(LPARAM)paftd, ACM_FORMATTAGDETAILSF_INDEX) == MMSYSERR_NOERROR) { (LPARAM)paftd, ACM_FORMATTAGDETAILSF_INDEX) == MMSYSERR_NOERROR) {
if (paftd->dwFormatTag == WAVE_FORMAT_PCM) { if (paftd->dwFormatTag == WAVE_FORMAT_PCM) {
if (paftd->szFormatTag[0] == 0) if (paftd->szFormatTag[0] == 0)
MultiByteToWideChar( CP_ACP, 0, "PCM", -1, paftd->szFormatTag, MultiByteToWideChar(CP_ACP, 0, "PCM", -1, paftd->szFormatTag,
sizeof(paftd->szFormatTag)/sizeof(WCHAR) ); ARRAY_SIZE(paftd->szFormatTag));
/* FIXME (EPP): I'm not sure this is the correct /* FIXME (EPP): I'm not sure this is the correct
* algorithm (should make more sense to apply the same * algorithm (should make more sense to apply the same
* for all already loaded formats, but this will do * for all already loaded formats, but this will do

View File

@ -72,7 +72,7 @@ PWINE_ACMDRIVERID MSACM_RegisterDriverFromRegistry(LPCWSTR pszRegEntry)
/* The requested registry entry must have the format msacm.XXXXX in order to /* The requested registry entry must have the format msacm.XXXXX in order to
be recognized in any future sessions of msacm 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); lRet = RegOpenKeyExW(HKEY_LOCAL_MACHINE, drvkey, 0, KEY_QUERY_VALUE, &hKey);
if (lRet != ERROR_SUCCESS) { if (lRet != ERROR_SUCCESS) {
WARN("unable to open registry key - 0x%08x\n", lRet); WARN("unable to open registry key - 0x%08x\n", lRet);
@ -373,31 +373,31 @@ void MSACM_RegisterAllDrivers(void)
if (lRet == ERROR_SUCCESS) { if (lRet == ERROR_SUCCESS) {
RegQueryInfoKeyW( hKey, 0, 0, 0, &cnt, 0, 0, 0, 0, 0, 0, 0); RegQueryInfoKeyW( hKey, 0, 0, 0, &cnt, 0, 0, 0, 0, 0, 0, 0);
for (i = 0; i < cnt; i++) { 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); lRet = RegEnumKeyExW(hKey, i, buf, &bufLen, 0, 0, 0, &lastWrite);
if (lRet != ERROR_SUCCESS) continue; 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; if (!(name = strchrW(buf, '='))) continue;
*name = 0; *name = 0;
MSACM_RegisterDriver(buf, name + 1, 0); MSACM_RegisterDriver(buf, name + 1, 0);
} }
i = 0; i = 0;
cnt = sizeof(valname) / sizeof(*valname); cnt = ARRAY_SIZE(valname);
bufLen = sizeof(buf); bufLen = sizeof(buf);
while(RegEnumValueW(hKey, i, valname, &cnt, 0, while(RegEnumValueW(hKey, i, valname, &cnt, 0,
&type, (BYTE*)buf, &bufLen) == ERROR_SUCCESS){ &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); MSACM_RegisterDriver(valname, buf, 0);
++i; ++i;
} }
RegCloseKey( hKey ); 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) 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; if (!(name = strchrW(s, '='))) continue;
*name = 0; *name = 0;
MSACM_RegisterDriver(s, name + 1, 0); MSACM_RegisterDriver(s, name + 1, 0);

View File

@ -984,14 +984,13 @@ static LRESULT PCM_DriverDetails(PACMDRIVERDETAILSW add)
add->cFormatTags = 1; add->cFormatTags = 1;
add->cFilterTags = 0; add->cFilterTags = 0;
add->hicon = NULL; add->hicon = NULL;
MultiByteToWideChar( CP_ACP, 0, "MS-PCM", -1, MultiByteToWideChar(CP_ACP, 0, "MS-PCM", -1, add->szShortName, ARRAY_SIZE(add->szShortName));
add->szShortName, sizeof(add->szShortName)/sizeof(WCHAR) ); MultiByteToWideChar(CP_ACP, 0, "Wine PCM converter", -1,
MultiByteToWideChar( CP_ACP, 0, "Wine PCM converter", -1, add->szLongName, ARRAY_SIZE(add->szLongName));
add->szLongName, sizeof(add->szLongName)/sizeof(WCHAR) ); MultiByteToWideChar(CP_ACP, 0, "Brought to you by the Wine team...", -1,
MultiByteToWideChar( CP_ACP, 0, "Brought to you by the Wine team...", -1, add->szCopyright, ARRAY_SIZE(add->szCopyright));
add->szCopyright, sizeof(add->szCopyright)/sizeof(WCHAR) ); MultiByteToWideChar(CP_ACP, 0, "Refer to LICENSE file", -1,
MultiByteToWideChar( CP_ACP, 0, "Refer to LICENSE file", -1, add->szLicensing, ARRAY_SIZE(add->szLicensing) );
add->szLicensing, sizeof(add->szLicensing)/sizeof(WCHAR) );
add->szFeatures[0] = 0; add->szFeatures[0] = 0;
return MMSYSERR_NOERROR; return MMSYSERR_NOERROR;

View File

@ -1106,7 +1106,7 @@ static void test_convert(void)
MMRESULT mmr; MMRESULT mmr;
unsigned i; 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); 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); ok(mmr == MMSYSERR_NOERROR, "#%d: open failed: 0x%x\n", i, mmr);