[PATCH] wineoss.drv: Use the ARRAY_SIZE() macro
Andrew Eikum
aeikum at codeweavers.com
Fri Aug 10 07:56:54 CDT 2018
Signed-off-by: Andrew Eikum <aeikum at codeweavers.com>
On Thu, Aug 09, 2018 at 08:59:33PM +0200, Michael Stefaniuc wrote:
> Not compile tested as I don't have a system with OSSv4.
>
> Signed-off-by: Michael Stefaniuc <mstefani at winehq.org>
> ---
> dlls/wineoss.drv/midi.c | 12 +++++-------
> dlls/wineoss.drv/mmdevdrv.c | 7 +++----
> 2 files changed, 8 insertions(+), 11 deletions(-)
>
> diff --git a/dlls/wineoss.drv/midi.c b/dlls/wineoss.drv/midi.c
> index 3a2ab2580d..24b3e7037b 100644
> --- a/dlls/wineoss.drv/midi.c
> +++ b/dlls/wineoss.drv/midi.c
> @@ -230,9 +230,8 @@ static LRESULT OSS_MidiInit(void)
> MidiOutDev[i].caps.wTechnology = MOD_MIDIPORT;
> MidiOutDev[i].bEnabled = FALSE;
> } else {
> - MultiByteToWideChar( CP_UNIXCP, 0, sinfo.name, -1,
> - MidiOutDev[i].caps.szPname,
> - sizeof(MidiOutDev[i].caps.szPname)/sizeof(WCHAR) );
> + MultiByteToWideChar(CP_UNIXCP, 0, sinfo.name, -1, MidiOutDev[i].caps.szPname,
> + ARRAY_SIZE(MidiOutDev[i].caps.szPname));
> MidiOutDev[i].caps.wTechnology = MIDI_UnixToWindowsDeviceType(sinfo.synth_type);
>
> if (MOD_MIDIPORT != MidiOutDev[i].caps.wTechnology) {
> @@ -313,7 +312,7 @@ static LRESULT OSS_MidiInit(void)
> } else {
> MultiByteToWideChar(CP_UNIXCP, 0, minfo.name, -1,
> MidiOutDev[numsynthdevs + i].caps.szPname,
> - sizeof(MidiOutDev[numsynthdevs + i].caps.szPname) / sizeof(WCHAR));
> + ARRAY_SIZE(MidiOutDev[numsynthdevs + i].caps.szPname));
> MidiOutDev[numsynthdevs + i].bEnabled = TRUE;
> }
> MidiOutDev[numsynthdevs + i].caps.wTechnology = MOD_MIDIPORT;
> @@ -338,9 +337,8 @@ static LRESULT OSS_MidiInit(void)
> wsprintfW(MidiInDev[i].caps.szPname, fmt, numsynthdevs + i);
> MidiInDev[i].state = -1;
> } else {
> - MultiByteToWideChar(CP_UNIXCP, 0, minfo.name, -1,
> - MidiInDev[i].caps.szPname,
> - sizeof(MidiInDev[i].caps.szPname) / sizeof(WCHAR));
> + MultiByteToWideChar(CP_UNIXCP, 0, minfo.name, -1, MidiInDev[i].caps.szPname,
> + ARRAY_SIZE(MidiInDev[i].caps.szPname));
> MidiInDev[i].state = 0;
> }
> MidiInDev[i].caps.dwSupport = 0; /* mandatory with MIDIINCAPS */
> diff --git a/dlls/wineoss.drv/mmdevdrv.c b/dlls/wineoss.drv/mmdevdrv.c
> index 1686c8c96c..fa3f885ea1 100644
> --- a/dlls/wineoss.drv/mmdevdrv.c
> +++ b/dlls/wineoss.drv/mmdevdrv.c
> @@ -349,8 +349,7 @@ static void get_device_guid(EDataFlow flow, const char *device, GUID *guid)
> else
> key_name[0] = '0';
> key_name[1] = ',';
> - MultiByteToWideChar(CP_UNIXCP, 0, device, -1, key_name + 2,
> - (sizeof(key_name) / sizeof(*key_name)) - 2);
> + MultiByteToWideChar(CP_UNIXCP, 0, device, -1, key_name + 2, ARRAY_SIZE(key_name) - 2);
>
> if(RegOpenKeyExW(HKEY_CURRENT_USER, drv_key_devicesW, 0, KEY_WRITE|KEY_READ, &key) == ERROR_SUCCESS){
> if(RegOpenKeyExW(key, key_name, 0, KEY_READ, &dev_key) == ERROR_SUCCESS){
> @@ -543,11 +542,11 @@ HRESULT WINAPI AUDDRV_GetEndpointIDs(EDataFlow flow, WCHAR ***ids, GUID **guids,
> len = MultiByteToWideChar(CP_UNIXCP, 0, ai.name, -1, NULL, 0);
> if(flow == eRender){
> prefix = outW;
> - prefix_len = (sizeof(outW) / sizeof(*outW)) - 1;
> + prefix_len = ARRAY_SIZE(outW) - 1;
> len += prefix_len;
> }else{
> prefix = inW;
> - prefix_len = (sizeof(inW) / sizeof(*inW)) - 1;
> + prefix_len = ARRAY_SIZE(inW) - 1;
> len += prefix_len;
> }
> (*ids)[*num] = HeapAlloc(GetProcessHeap(), 0,
> --
> 2.14.4
>
>
>
More information about the wine-devel
mailing list