winmm: 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-09-19 21:01:11 +02:00 committed by Alexandre Julliard
parent 04847e68f8
commit 24f4781216
7 changed files with 23 additions and 26 deletions

View File

@ -396,7 +396,7 @@ HDRVR WINAPI OpenDriver(LPCWSTR lpDriverName, LPCWSTR lpSectionName, LPARAM lPar
if (lsn == NULL) {
static const WCHAR wszDrivers32[] = {'D','r','i','v','e','r','s','3','2',0};
lstrcpynW(libName, lpDriverName, sizeof(libName) / sizeof(WCHAR));
lstrcpynW(libName, lpDriverName, ARRAY_SIZE(libName));
if ((lpDrv = DRIVER_TryOpenDriver32(libName, lParam)))
goto the_end;

View File

@ -181,7 +181,7 @@ void MMDRV_Free(HANDLE hndl, LPWINE_MLD mld)
if ((UINT_PTR)hndl & 0x8000) {
UINT_PTR idx = (UINT_PTR)hndl & ~0x8000;
if (idx < sizeof(MM_MLDrvs) / sizeof(MM_MLDrvs[0])) {
if (idx < ARRAY_SIZE(MM_MLDrvs)) {
MM_MLDrvs[idx] = NULL;
HeapFree(GetProcessHeap(), 0, mld);
return;
@ -261,7 +261,7 @@ LPWINE_MLD MMDRV_Get(HANDLE _hndl, UINT type, BOOL bCanBeID)
hndl != (UINT16)-1 && hndl != (UINT)-1) {
if (hndl & 0x8000) {
UINT idx = hndl & ~0x8000;
if (idx < sizeof(MM_MLDrvs) / sizeof(MM_MLDrvs[0])) {
if (idx < ARRAY_SIZE(MM_MLDrvs)) {
__TRY
{
mld = MM_MLDrvs[idx];
@ -424,7 +424,7 @@ static BOOL MMDRV_Install(LPCSTR drvRegName, LPCSTR drvFileName, BOOL bIsMapper)
* drivers !!
* If not just increase size of MMDrvs
*/
assert(MMDrvsHi <= sizeof(MMDrvs)/sizeof(MMDrvs[0]));
assert(MMDrvsHi <= ARRAY_SIZE(MMDrvs));
memset(lpDrv, 0, sizeof(*lpDrv));
@ -589,7 +589,7 @@ void MMDRV_Exit(void)
unsigned int i;
TRACE("()\n");
for (i = 0; i < sizeof(MM_MLDrvs) / sizeof(MM_MLDrvs[0]); i++)
for (i = 0; i < ARRAY_SIZE(MM_MLDrvs); i++)
{
if (MM_MLDrvs[i] != NULL)
{
@ -602,7 +602,7 @@ void MMDRV_Exit(void)
}
/* unload driver, in reverse order of loading */
i = sizeof(MMDrvs) / sizeof(MMDrvs[0]);
i = ARRAY_SIZE(MMDrvs);
while (i-- > 0)
{
MMDRV_ExitPerType(&MMDrvs[i], MMDRV_AUX);

View File

@ -551,7 +551,7 @@ static UINT MCI_GetDevTypeFromResource(LPCWSTR lpstrName)
WCHAR buf[32];
UINT uDevType;
for (uDevType = MCI_DEVTYPE_FIRST; uDevType <= MCI_DEVTYPE_LAST; uDevType++) {
if (LoadStringW(hWinMM32Instance, uDevType, buf, sizeof(buf) / sizeof(WCHAR))) {
if (LoadStringW(hWinMM32Instance, uDevType, buf, ARRAY_SIZE(buf))) {
/* FIXME: ignore digits suffix */
if (!strcmpiW(buf, lpstrName))
return uDevType;
@ -668,7 +668,7 @@ static UINT MCI_GetCommandTable(UINT uDevType)
/* well try to load id */
if (uDevType >= MCI_DEVTYPE_FIRST && uDevType <= MCI_DEVTYPE_LAST) {
if (LoadStringW(hWinMM32Instance, uDevType, buf, sizeof(buf) / sizeof(WCHAR))) {
if (LoadStringW(hWinMM32Instance, uDevType, buf, ARRAY_SIZE(buf))) {
str = buf;
}
} else if (uDevType == 0) {
@ -1450,9 +1450,9 @@ DWORD WINAPI mciSendStringW(LPCWSTR lpstrCommand, LPWSTR lpstrRet,
{
static const WCHAR wszOpenWait[] = {'o','p','e','n',' ','%','s',' ','w','a','i','t',0};
WCHAR buf[138], retbuf[6];
snprintfW(buf, sizeof(buf)/sizeof(WCHAR), wszOpenWait, dev);
snprintfW(buf, ARRAY_SIZE(buf), wszOpenWait, dev);
/* open via mciSendString handles quoting, dev!file syntax and alias creation */
if ((dwRet = mciSendStringW(buf, retbuf, sizeof(retbuf)/sizeof(WCHAR), 0)) != 0)
if ((dwRet = mciSendStringW(buf, retbuf, ARRAY_SIZE(retbuf), 0)) != 0)
goto errCleanUp;
auto_open = strtoulW(retbuf, NULL, 10);
TRACE("auto-opened %u for %s\n", auto_open, debugstr_w(dev));
@ -1746,10 +1746,8 @@ static DWORD MCI_Open(DWORD dwParam, LPMCI_OPEN_PARMSW lpParms)
if (dwParam & MCI_OPEN_TYPE_ID) {
WORD uDevType = LOWORD(lpParms->lpstrDeviceType);
if (uDevType < MCI_DEVTYPE_FIRST ||
uDevType > MCI_DEVTYPE_LAST ||
!LoadStringW(hWinMM32Instance, uDevType,
strDevTyp, sizeof(strDevTyp) / sizeof(WCHAR))) {
if (uDevType < MCI_DEVTYPE_FIRST || uDevType > MCI_DEVTYPE_LAST ||
!LoadStringW(hWinMM32Instance, uDevType, strDevTyp, ARRAY_SIZE(strDevTyp))) {
dwRet = MCIERR_BAD_INTEGER;
goto errCleanUp;
}
@ -1946,7 +1944,7 @@ static DWORD MCI_SysInfo(UINT uDevID, DWORD dwFlags, LPMCI_SYSINFO_PARMSW lpParm
RegQueryInfoKeyW( hKey, 0, 0, 0, &cnt, 0, 0, 0, 0, 0, 0, 0);
RegCloseKey( hKey );
}
if (GetPrivateProfileStringW(wszMci, 0, wszNull, buf, sizeof(buf) / sizeof(buf[0]), wszSystemIni))
if (GetPrivateProfileStringW(wszMci, 0, wszNull, buf, ARRAY_SIZE(buf), wszSystemIni))
for (s = buf; *s; s += strlenW(s) + 1) cnt++;
}
} else {
@ -2016,7 +2014,7 @@ static DWORD MCI_SysInfo(UINT uDevID, DWORD dwFlags, LPMCI_SYSINFO_PARMSW lpParm
if (RegQueryInfoKeyW( hKey, 0, 0, 0, &cnt,
0, 0, 0, 0, 0, 0, 0) == ERROR_SUCCESS &&
lpParms->dwNumber <= cnt) {
DWORD bufLen = sizeof(buf)/sizeof(buf[0]);
DWORD bufLen = ARRAY_SIZE(buf);
if (RegEnumKeyExW(hKey, lpParms->dwNumber - 1,
buf, &bufLen, 0, 0, 0, 0) == ERROR_SUCCESS)
s = buf;
@ -2024,7 +2022,7 @@ static DWORD MCI_SysInfo(UINT uDevID, DWORD dwFlags, LPMCI_SYSINFO_PARMSW lpParm
RegCloseKey( hKey );
}
if (!s) {
if (GetPrivateProfileStringW(wszMci, 0, wszNull, buf, sizeof(buf) / sizeof(buf[0]), wszSystemIni)) {
if (GetPrivateProfileStringW(wszMci, 0, wszNull, buf, ARRAY_SIZE(buf), wszSystemIni)) {
for (p = buf; *p; p += strlenW(p) + 1, cnt++) {
TRACE("%d: %s\n", cnt, debugstr_w(p));
if (cnt == lpParms->dwNumber - 1) {

View File

@ -315,7 +315,7 @@ static LPMMIOPROC MMIO_InstallIOProc(FOURCC fccIOProc, LPMMIOPROC pIOProc,
}
/* remove it, but only if it isn't builtin */
if ((*ppListNode) >= defaultProcs &&
(*ppListNode) < defaultProcs + sizeof(defaultProcs) / sizeof(defaultProcs[0])) {
(*ppListNode) < defaultProcs + ARRAY_SIZE(defaultProcs)) {
WARN("Tried to remove built-in mmio proc. Skipping\n");
} else {
/* Okay, nuke it */

View File

@ -60,7 +60,7 @@ static HMMIO get_mmioFromFile(LPCWSTR lpszName)
ret = mmioOpenW((LPWSTR)lpszName, NULL,
MMIO_ALLOCBUF | MMIO_READ | MMIO_DENYWRITE);
if (ret != 0) return ret;
if (SearchPathW(NULL, lpszName, dotwav, sizeof(buf)/sizeof(buf[0]), buf, &dummy))
if (SearchPathW(NULL, lpszName, dotwav, ARRAY_SIZE(buf), buf, &dummy))
{
return mmioOpenW(buf, NULL,
MMIO_ALLOCBUF | MMIO_READ | MMIO_DENYWRITE);
@ -86,11 +86,11 @@ static HMMIO get_mmioFromProfile(UINT uFlags, LPCWSTR lpszName)
static const WCHAR wszNull[] = {0};
TRACE("searching in SystemSound list for %s\n", debugstr_w(lpszName));
GetProfileStringW(wszSounds, lpszName, wszNull, str, sizeof(str)/sizeof(str[0]));
GetProfileStringW(wszSounds, lpszName, wszNull, str, ARRAY_SIZE(str));
if (lstrlenW(str) == 0)
{
if (uFlags & SND_NODEFAULT) goto next;
GetProfileStringW(wszSounds, wszDefault, wszNull, str, sizeof(str)/sizeof(str[0]));
GetProfileStringW(wszSounds, wszDefault, wszNull, str, ARRAY_SIZE(str));
if (lstrlenW(str) == 0) goto next;
}
for (ptr = str; *ptr && *ptr != ','; ptr++);
@ -108,8 +108,8 @@ static HMMIO get_mmioFromProfile(UINT uFlags, LPCWSTR lpszName)
DWORD len;
err = 1; /* error */
len = GetModuleFileNameW(0, str, sizeof(str)/sizeof(str[0]));
if (len > 0 && len < sizeof(str)/sizeof(str[0]))
len = GetModuleFileNameW(0, str, ARRAY_SIZE(str));
if (len > 0 && len < ARRAY_SIZE(str))
{
for (ptr = str + lstrlenW(str) - 1; ptr >= str; ptr--)
{

View File

@ -4354,7 +4354,7 @@ UINT WINAPI mixerGetLineInfoA(HMIXEROBJ hmix, LPMIXERLINEA lpmliA,
mliW.Target.wMid = lpmliA->Target.wMid;
mliW.Target.wPid = lpmliA->Target.wPid;
mliW.Target.vDriverVersion = lpmliA->Target.vDriverVersion;
MultiByteToWideChar( CP_ACP, 0, lpmliA->Target.szPname, -1, mliW.Target.szPname, sizeof(mliW.Target.szPname)/sizeof(WCHAR));
MultiByteToWideChar(CP_ACP, 0, lpmliA->Target.szPname, -1, mliW.Target.szPname, ARRAY_SIZE(mliW.Target.szPname));
break;
default:
WARN("Unsupported fdwControls=0x%08x\n", fdwInfo);

View File

@ -1445,8 +1445,7 @@ static MMRESULT midistream_post_message_and_wait(WINE_MIDIStream* lpMidiStrm, UI
if (GetCurrentThreadId() != lpMidiStrm->dwThreadID) {
DWORD ret;
hObjects[1] = lpMidiStrm->hThread;
ret = WaitForMultipleObjects(sizeof(hObjects)/sizeof(hObjects[0]), hObjects,
FALSE, INFINITE);
ret = WaitForMultipleObjects(ARRAY_SIZE(hObjects), hObjects, FALSE, INFINITE);
if (ret != WAIT_OBJECT_0) {
CloseHandle(hObjects[0]);
WARN("bad WaitForSingleObject (%u)\n", ret);