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:
parent
04847e68f8
commit
24f4781216
|
@ -396,7 +396,7 @@ HDRVR WINAPI OpenDriver(LPCWSTR lpDriverName, LPCWSTR lpSectionName, LPARAM lPar
|
||||||
|
|
||||||
if (lsn == NULL) {
|
if (lsn == NULL) {
|
||||||
static const WCHAR wszDrivers32[] = {'D','r','i','v','e','r','s','3','2',0};
|
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)))
|
if ((lpDrv = DRIVER_TryOpenDriver32(libName, lParam)))
|
||||||
goto the_end;
|
goto the_end;
|
||||||
|
|
|
@ -181,7 +181,7 @@ void MMDRV_Free(HANDLE hndl, LPWINE_MLD mld)
|
||||||
|
|
||||||
if ((UINT_PTR)hndl & 0x8000) {
|
if ((UINT_PTR)hndl & 0x8000) {
|
||||||
UINT_PTR idx = (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;
|
MM_MLDrvs[idx] = NULL;
|
||||||
HeapFree(GetProcessHeap(), 0, mld);
|
HeapFree(GetProcessHeap(), 0, mld);
|
||||||
return;
|
return;
|
||||||
|
@ -261,7 +261,7 @@ LPWINE_MLD MMDRV_Get(HANDLE _hndl, UINT type, BOOL bCanBeID)
|
||||||
hndl != (UINT16)-1 && hndl != (UINT)-1) {
|
hndl != (UINT16)-1 && hndl != (UINT)-1) {
|
||||||
if (hndl & 0x8000) {
|
if (hndl & 0x8000) {
|
||||||
UINT idx = hndl & ~0x8000;
|
UINT idx = hndl & ~0x8000;
|
||||||
if (idx < sizeof(MM_MLDrvs) / sizeof(MM_MLDrvs[0])) {
|
if (idx < ARRAY_SIZE(MM_MLDrvs)) {
|
||||||
__TRY
|
__TRY
|
||||||
{
|
{
|
||||||
mld = MM_MLDrvs[idx];
|
mld = MM_MLDrvs[idx];
|
||||||
|
@ -424,7 +424,7 @@ static BOOL MMDRV_Install(LPCSTR drvRegName, LPCSTR drvFileName, BOOL bIsMapper)
|
||||||
* drivers !!
|
* drivers !!
|
||||||
* If not just increase size of MMDrvs
|
* If not just increase size of MMDrvs
|
||||||
*/
|
*/
|
||||||
assert(MMDrvsHi <= sizeof(MMDrvs)/sizeof(MMDrvs[0]));
|
assert(MMDrvsHi <= ARRAY_SIZE(MMDrvs));
|
||||||
|
|
||||||
memset(lpDrv, 0, sizeof(*lpDrv));
|
memset(lpDrv, 0, sizeof(*lpDrv));
|
||||||
|
|
||||||
|
@ -589,7 +589,7 @@ void MMDRV_Exit(void)
|
||||||
unsigned int i;
|
unsigned int i;
|
||||||
TRACE("()\n");
|
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)
|
if (MM_MLDrvs[i] != NULL)
|
||||||
{
|
{
|
||||||
|
@ -602,7 +602,7 @@ void MMDRV_Exit(void)
|
||||||
}
|
}
|
||||||
|
|
||||||
/* unload driver, in reverse order of loading */
|
/* unload driver, in reverse order of loading */
|
||||||
i = sizeof(MMDrvs) / sizeof(MMDrvs[0]);
|
i = ARRAY_SIZE(MMDrvs);
|
||||||
while (i-- > 0)
|
while (i-- > 0)
|
||||||
{
|
{
|
||||||
MMDRV_ExitPerType(&MMDrvs[i], MMDRV_AUX);
|
MMDRV_ExitPerType(&MMDrvs[i], MMDRV_AUX);
|
||||||
|
|
|
@ -551,7 +551,7 @@ static UINT MCI_GetDevTypeFromResource(LPCWSTR lpstrName)
|
||||||
WCHAR buf[32];
|
WCHAR buf[32];
|
||||||
UINT uDevType;
|
UINT uDevType;
|
||||||
for (uDevType = MCI_DEVTYPE_FIRST; uDevType <= MCI_DEVTYPE_LAST; 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 */
|
/* FIXME: ignore digits suffix */
|
||||||
if (!strcmpiW(buf, lpstrName))
|
if (!strcmpiW(buf, lpstrName))
|
||||||
return uDevType;
|
return uDevType;
|
||||||
|
@ -668,7 +668,7 @@ static UINT MCI_GetCommandTable(UINT uDevType)
|
||||||
|
|
||||||
/* well try to load id */
|
/* well try to load id */
|
||||||
if (uDevType >= MCI_DEVTYPE_FIRST && uDevType <= MCI_DEVTYPE_LAST) {
|
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;
|
str = buf;
|
||||||
}
|
}
|
||||||
} else if (uDevType == 0) {
|
} 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};
|
static const WCHAR wszOpenWait[] = {'o','p','e','n',' ','%','s',' ','w','a','i','t',0};
|
||||||
WCHAR buf[138], retbuf[6];
|
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 */
|
/* 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;
|
goto errCleanUp;
|
||||||
auto_open = strtoulW(retbuf, NULL, 10);
|
auto_open = strtoulW(retbuf, NULL, 10);
|
||||||
TRACE("auto-opened %u for %s\n", auto_open, debugstr_w(dev));
|
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) {
|
if (dwParam & MCI_OPEN_TYPE_ID) {
|
||||||
WORD uDevType = LOWORD(lpParms->lpstrDeviceType);
|
WORD uDevType = LOWORD(lpParms->lpstrDeviceType);
|
||||||
|
|
||||||
if (uDevType < MCI_DEVTYPE_FIRST ||
|
if (uDevType < MCI_DEVTYPE_FIRST || uDevType > MCI_DEVTYPE_LAST ||
|
||||||
uDevType > MCI_DEVTYPE_LAST ||
|
!LoadStringW(hWinMM32Instance, uDevType, strDevTyp, ARRAY_SIZE(strDevTyp))) {
|
||||||
!LoadStringW(hWinMM32Instance, uDevType,
|
|
||||||
strDevTyp, sizeof(strDevTyp) / sizeof(WCHAR))) {
|
|
||||||
dwRet = MCIERR_BAD_INTEGER;
|
dwRet = MCIERR_BAD_INTEGER;
|
||||||
goto errCleanUp;
|
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);
|
RegQueryInfoKeyW( hKey, 0, 0, 0, &cnt, 0, 0, 0, 0, 0, 0, 0);
|
||||||
RegCloseKey( hKey );
|
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++;
|
for (s = buf; *s; s += strlenW(s) + 1) cnt++;
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
|
@ -2016,7 +2014,7 @@ static DWORD MCI_SysInfo(UINT uDevID, DWORD dwFlags, LPMCI_SYSINFO_PARMSW lpParm
|
||||||
if (RegQueryInfoKeyW( hKey, 0, 0, 0, &cnt,
|
if (RegQueryInfoKeyW( hKey, 0, 0, 0, &cnt,
|
||||||
0, 0, 0, 0, 0, 0, 0) == ERROR_SUCCESS &&
|
0, 0, 0, 0, 0, 0, 0) == ERROR_SUCCESS &&
|
||||||
lpParms->dwNumber <= cnt) {
|
lpParms->dwNumber <= cnt) {
|
||||||
DWORD bufLen = sizeof(buf)/sizeof(buf[0]);
|
DWORD bufLen = ARRAY_SIZE(buf);
|
||||||
if (RegEnumKeyExW(hKey, lpParms->dwNumber - 1,
|
if (RegEnumKeyExW(hKey, lpParms->dwNumber - 1,
|
||||||
buf, &bufLen, 0, 0, 0, 0) == ERROR_SUCCESS)
|
buf, &bufLen, 0, 0, 0, 0) == ERROR_SUCCESS)
|
||||||
s = buf;
|
s = buf;
|
||||||
|
@ -2024,7 +2022,7 @@ static DWORD MCI_SysInfo(UINT uDevID, DWORD dwFlags, LPMCI_SYSINFO_PARMSW lpParm
|
||||||
RegCloseKey( hKey );
|
RegCloseKey( hKey );
|
||||||
}
|
}
|
||||||
if (!s) {
|
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++) {
|
for (p = buf; *p; p += strlenW(p) + 1, cnt++) {
|
||||||
TRACE("%d: %s\n", cnt, debugstr_w(p));
|
TRACE("%d: %s\n", cnt, debugstr_w(p));
|
||||||
if (cnt == lpParms->dwNumber - 1) {
|
if (cnt == lpParms->dwNumber - 1) {
|
||||||
|
|
|
@ -315,7 +315,7 @@ static LPMMIOPROC MMIO_InstallIOProc(FOURCC fccIOProc, LPMMIOPROC pIOProc,
|
||||||
}
|
}
|
||||||
/* remove it, but only if it isn't builtin */
|
/* remove it, but only if it isn't builtin */
|
||||||
if ((*ppListNode) >= defaultProcs &&
|
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");
|
WARN("Tried to remove built-in mmio proc. Skipping\n");
|
||||||
} else {
|
} else {
|
||||||
/* Okay, nuke it */
|
/* Okay, nuke it */
|
||||||
|
|
|
@ -60,7 +60,7 @@ static HMMIO get_mmioFromFile(LPCWSTR lpszName)
|
||||||
ret = mmioOpenW((LPWSTR)lpszName, NULL,
|
ret = mmioOpenW((LPWSTR)lpszName, NULL,
|
||||||
MMIO_ALLOCBUF | MMIO_READ | MMIO_DENYWRITE);
|
MMIO_ALLOCBUF | MMIO_READ | MMIO_DENYWRITE);
|
||||||
if (ret != 0) return ret;
|
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,
|
return mmioOpenW(buf, NULL,
|
||||||
MMIO_ALLOCBUF | MMIO_READ | MMIO_DENYWRITE);
|
MMIO_ALLOCBUF | MMIO_READ | MMIO_DENYWRITE);
|
||||||
|
@ -86,11 +86,11 @@ static HMMIO get_mmioFromProfile(UINT uFlags, LPCWSTR lpszName)
|
||||||
static const WCHAR wszNull[] = {0};
|
static const WCHAR wszNull[] = {0};
|
||||||
|
|
||||||
TRACE("searching in SystemSound list for %s\n", debugstr_w(lpszName));
|
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 (lstrlenW(str) == 0)
|
||||||
{
|
{
|
||||||
if (uFlags & SND_NODEFAULT) goto next;
|
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;
|
if (lstrlenW(str) == 0) goto next;
|
||||||
}
|
}
|
||||||
for (ptr = str; *ptr && *ptr != ','; ptr++);
|
for (ptr = str; *ptr && *ptr != ','; ptr++);
|
||||||
|
@ -108,8 +108,8 @@ static HMMIO get_mmioFromProfile(UINT uFlags, LPCWSTR lpszName)
|
||||||
DWORD len;
|
DWORD len;
|
||||||
|
|
||||||
err = 1; /* error */
|
err = 1; /* error */
|
||||||
len = GetModuleFileNameW(0, str, sizeof(str)/sizeof(str[0]));
|
len = GetModuleFileNameW(0, str, ARRAY_SIZE(str));
|
||||||
if (len > 0 && len < sizeof(str)/sizeof(str[0]))
|
if (len > 0 && len < ARRAY_SIZE(str))
|
||||||
{
|
{
|
||||||
for (ptr = str + lstrlenW(str) - 1; ptr >= str; ptr--)
|
for (ptr = str + lstrlenW(str) - 1; ptr >= str; ptr--)
|
||||||
{
|
{
|
||||||
|
|
|
@ -4354,7 +4354,7 @@ UINT WINAPI mixerGetLineInfoA(HMIXEROBJ hmix, LPMIXERLINEA lpmliA,
|
||||||
mliW.Target.wMid = lpmliA->Target.wMid;
|
mliW.Target.wMid = lpmliA->Target.wMid;
|
||||||
mliW.Target.wPid = lpmliA->Target.wPid;
|
mliW.Target.wPid = lpmliA->Target.wPid;
|
||||||
mliW.Target.vDriverVersion = lpmliA->Target.vDriverVersion;
|
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;
|
break;
|
||||||
default:
|
default:
|
||||||
WARN("Unsupported fdwControls=0x%08x\n", fdwInfo);
|
WARN("Unsupported fdwControls=0x%08x\n", fdwInfo);
|
||||||
|
|
|
@ -1445,8 +1445,7 @@ static MMRESULT midistream_post_message_and_wait(WINE_MIDIStream* lpMidiStrm, UI
|
||||||
if (GetCurrentThreadId() != lpMidiStrm->dwThreadID) {
|
if (GetCurrentThreadId() != lpMidiStrm->dwThreadID) {
|
||||||
DWORD ret;
|
DWORD ret;
|
||||||
hObjects[1] = lpMidiStrm->hThread;
|
hObjects[1] = lpMidiStrm->hThread;
|
||||||
ret = WaitForMultipleObjects(sizeof(hObjects)/sizeof(hObjects[0]), hObjects,
|
ret = WaitForMultipleObjects(ARRAY_SIZE(hObjects), hObjects, FALSE, INFINITE);
|
||||||
FALSE, INFINITE);
|
|
||||||
if (ret != WAIT_OBJECT_0) {
|
if (ret != WAIT_OBJECT_0) {
|
||||||
CloseHandle(hObjects[0]);
|
CloseHandle(hObjects[0]);
|
||||||
WARN("bad WaitForSingleObject (%u)\n", ret);
|
WARN("bad WaitForSingleObject (%u)\n", ret);
|
||||||
|
|
Loading…
Reference in New Issue