os2: several warning fixes.

mostly those "W007: '&array' may not produce intended result" warnings
from Watcom, visible only in C++ mode.  one or two others here & there.
This commit is contained in:
Ozkan Sezer 2020-10-14 23:01:02 +03:00
parent f9af19f51d
commit aa790837eb
10 changed files with 49 additions and 55 deletions

View File

@ -61,8 +61,8 @@ static int _MCIError(PSZ pszFunc, ULONG ulResult)
{
CHAR acBuf[128];
mciGetErrorString( ulResult, (PCHAR)&acBuf, sizeof(acBuf) );
return SDL_SetError( "[%s] %s", pszFunc, &acBuf );
mciGetErrorString( ulResult, acBuf, sizeof(acBuf) );
return SDL_SetError( "[%s] %s", pszFunc, acBuf );
}
static void _mixIOError(PSZ pszFunction, ULONG ulRC)
@ -128,7 +128,7 @@ static void OS2_DetectDevices(void)
ULONG ulHandle = 0;
acBuf[0] = '\0';
stMCISysInfo.pszReturn = &acBuf;
stMCISysInfo.pszReturn = acBuf;
stMCISysInfo.ulRetSize = sizeof(acBuf);
stMCISysInfo.usDeviceType = MCI_DEVTYPE_AUDIO_AMPMIX;
ulRC = mciSendCommand( 0, MCI_SYSINFO, MCI_WAIT | MCI_SYSINFO_QUANTITY,
@ -145,7 +145,7 @@ static void OS2_DetectDevices(void)
stSysInfoParams.ulNumber++ )
{
// Get device install name.
stSysInfoParams.pszReturn = &acBuf;
stSysInfoParams.pszReturn = acBuf;
stSysInfoParams.ulRetSize = sizeof( acBuf );
stSysInfoParams.usDeviceType = MCI_DEVTYPE_AUDIO_AMPMIX;
ulRC = mciSendCommand( 0, MCI_SYSINFO, MCI_WAIT | MCI_SYSINFO_INSTALLNAME,
@ -159,7 +159,7 @@ static void OS2_DetectDevices(void)
// Get textual product description.
stSysInfoParams.ulItem = MCI_SYSINFO_QUERY_DRIVER;
stSysInfoParams.pSysInfoParm = &stLogDevice;
strcpy( &stLogDevice.szInstallName, stSysInfoParams.pszReturn );
strcpy( stLogDevice.szInstallName, stSysInfoParams.pszReturn );
ulRC = mciSendCommand( 0, MCI_SYSINFO, MCI_WAIT | MCI_SYSINFO_ITEM,
&stSysInfoParams, 0 );
if ( ulRC != NO_ERROR )
@ -169,9 +169,9 @@ static void OS2_DetectDevices(void)
}
ulHandle++;
SDL_AddAudioDevice( 0, &stLogDevice.szProductInfo, (void *)(ulHandle) );
SDL_AddAudioDevice( 0, stLogDevice.szProductInfo, (void *)(ulHandle) );
ulHandle++;
SDL_AddAudioDevice( 1, &stLogDevice.szProductInfo, (void *)(ulHandle) );
SDL_AddAudioDevice( 1, stLogDevice.szProductInfo, (void *)(ulHandle) );
}
}
@ -226,11 +226,9 @@ static void OS2_CloseDevice(_THIS)
return;
/* Close up audio */
if ( pAData->usDeviceId != (USHORT)~0 )
{
// Device is open.
if ( pAData->stMCIMixSetup.ulBitsPerSample != 0 )
{
// Mixer was initialized.

View File

@ -47,7 +47,7 @@ static BOOL _loadDLL(PSZ pszName, PSZ pszIconvOpen, PSZ pszIconv,
ULONG ulRC;
CHAR acError[256];
ulRC = DosLoadModule( &acError, sizeof(acError), pszName, &hmIconv );
ulRC = DosLoadModule( acError, sizeof(acError), pszName, &hmIconv );
if ( ulRC != NO_ERROR )
{
debug( "DLL not loaded: %s", &acError );

View File

@ -288,7 +288,7 @@ char * os2cpToName(unsigned long cp)
ULONG aulCP[3];
ULONG cCP;
if ( DosQueryCp( sizeof(aulCP), &aulCP, &cCP ) != NO_ERROR )
if ( DosQueryCp( sizeof(aulCP), aulCP, &cCP ) != NO_ERROR )
return NULL;
cp = aulCP[0];
@ -336,7 +336,7 @@ unsigned long os2cpFromName(char *cp)
ULONG aulCP[3];
ULONG cCP;
return DosQueryCp( sizeof(aulCP), &aulCP, &cCP ) != NO_ERROR ? 0 : aulCP[0];
return DosQueryCp( sizeof(aulCP), aulCP, &cCP ) != NO_ERROR ? 0 : aulCP[0];
}
while( isspace( *cp ) ) cp++;
@ -348,17 +348,17 @@ unsigned long os2cpFromName(char *cp)
if ( ulNext >= sizeof(acBuf) )
return 0;
memcpy( &acBuf, cp, ulNext );
memcpy( acBuf, cp, ulNext );
acBuf[ulNext] = '\0';
strupr( &acBuf );
strupr( acBuf );
lCmp = strcmp( aName2CP[0].pszName, &acBuf );
lCmp = strcmp( aName2CP[0].pszName, acBuf );
if ( lCmp > 0 )
return 0;
else if ( lCmp == 0 )
return aName2CP[0].ulCode;
lCmp = strcmp( aName2CP[ulHi].pszName, &acBuf );
lCmp = strcmp( aName2CP[ulHi].pszName, acBuf );
if ( lCmp < 0 )
return 0;
else if ( lCmp == 0 )
@ -368,7 +368,7 @@ unsigned long os2cpFromName(char *cp)
{
ulNext = ( ulLo + ulHi ) / 2;
lCmp = strcmp( aName2CP[ulNext].pszName, &acBuf );
lCmp = strcmp( aName2CP[ulNext].pszName, acBuf );
if ( lCmp < 0 )
ulLo = ulNext;
else if ( lCmp > 0 )

View File

@ -49,7 +49,7 @@ static int _createUconvObj(const char *code, UconvObject *uobj)
}
}
return UniCreateUconvObject( &uc_code, uobj );
return UniCreateUconvObject( uc_code, uobj );
}
static int uconv_open(const char *code, UconvObject *uobj)
@ -68,8 +68,8 @@ static int uconv_open(const char *code, UconvObject *uobj)
unsigned long cp = os2cpFromName( (char *)code );
char cp_name[16];
if ( cp != 0 && _snprintf( &cp_name, sizeof(cp_name), "IBM-%u", cp ) > 0 )
rc = _createUconvObj( &cp_name, uobj );
if ( cp != 0 && _snprintf( cp_name, sizeof(cp_name), "IBM-%u", cp ) > 0 )
rc = _createUconvObj( cp_name, uobj );
}
return rc;

View File

@ -64,7 +64,7 @@ SDL_GetBasePath(void)
}
cbResult = pcEnd - pib->pib_pchcmd;
SDL_memcpy( &acBuf, pib->pib_pchcmd, cbResult );
SDL_memcpy( acBuf, pib->pib_pchcmd, cbResult );
acBuf[cbResult] = '\0';
return OS2_SysToUTF8( acBuf );
@ -91,12 +91,12 @@ SDL_GetPrefPath(const char *org, const char *app)
return NULL;
}
lPosApp = SDL_snprintf( &acBuf, sizeof(acBuf) - 1, "%s\\%s", pszPath, pszOrg );
lPosApp = SDL_snprintf( acBuf, sizeof(acBuf) - 1, "%s\\%s", pszPath, pszOrg );
SDL_free( pszOrg );
if ( lPosApp == -1 )
return NULL;
mkdir( &acBuf );
mkdir( acBuf );
pszApp = OS2_UTF8ToSys( app );
if ( pszApp == NULL )
@ -111,10 +111,10 @@ SDL_GetPrefPath(const char *org, const char *app)
if ( lPosOrg == -1 )
return NULL;
mkdir( &acBuf );
mkdir( acBuf );
*((PUSHORT)&acBuf[lPosApp + lPosOrg]) = (USHORT)'\0\\';
return OS2_SysToUTF8( &acBuf );
return OS2_SysToUTF8( acBuf );
}
#endif /* SDL_FILESYSTEM_OS2 */

View File

@ -40,10 +40,9 @@ SDL_LoadObject(const char *sofile)
PSZ pszModName = OS2_UTF8ToSys( sofile );
CHAR acError[256];
ulRC = DosLoadModule( &acError, sizeof(acError), pszModName, &hModule );
SDL_free( pszModName );
if ( ulRC != NO_ERROR )
{
ulRC = DosLoadModule(acError, sizeof(acError), pszModName, &hModule);
SDL_free(pszModName);
if (ulRC != NO_ERROR) {
SDL_SetError( "Failed loading %s (E%u)", acError, ulRC );
return NULL;
}
@ -57,9 +56,8 @@ SDL_LoadFunction(void *handle, const char *name)
ULONG ulRC;
PFN pFN;
ulRC = DosQueryProcAddr( (HMODULE)handle, 0, name, &pFN );
if ( ulRC != NO_ERROR )
{
ulRC = DosQueryProcAddr((HMODULE)handle, 0, name, &pFN);
if (ulRC != NO_ERROR) {
SDL_SetError( "Failed loading procedure %s (E%u)", name, ulRC );
return NULL;
}
@ -70,7 +68,7 @@ SDL_LoadFunction(void *handle, const char *name)
void
SDL_UnloadObject(void *handle)
{
if ( handle != NULL )
if (handle != NULL)
DosFreeModule( (HMODULE)handle );
}

View File

@ -72,7 +72,7 @@ static BOOL voQueryInfo(PVIDEOOUTPUTINFO pInfo)
// Query information about display hardware from DIVE.
sDiveCaps.pFormatData = &fccFormats;
sDiveCaps.pFormatData = fccFormats;
sDiveCaps.ulFormatLength = 100;
sDiveCaps.ulStructLen = sizeof(DIVE_CAPS);

View File

@ -68,10 +68,10 @@ static VOID _wmInitDlg(HWND hwnd, PMSGBOXDLGDATA pDlgData)
while( ( hWndNext = WinGetNextWindow( hEnum ) ) != NULLHANDLE )
{
if ( WinQueryClassName( hWndNext, sizeof(acBuf), &acBuf ) == 0 )
if ( WinQueryClassName( hWndNext, sizeof(acBuf), acBuf ) == 0 )
continue;
if ( strcmp( &acBuf, "#3" ) == 0 ) // Class name of button.
if ( strcmp( acBuf, "#3" ) == 0 ) // Class name of button.
{
if ( cButtons < sizeof(aButtons) / sizeof(struct _BUTTON) )
{
@ -91,8 +91,8 @@ static VOID _wmInitDlg(HWND hwnd, PMSGBOXDLGDATA pDlgData)
for( ulIdx = 0; ulIdx < cButtons; ulIdx++ )
{
// Query size of text in window coordinates.
cbBuf = WinQueryWindowText( aButtons[ulIdx].hwnd, sizeof(acBuf), &acBuf );
GpiQueryTextBox( hps, cbBuf, acBuf, TXTBOX_COUNT, &aptText );
cbBuf = WinQueryWindowText( aButtons[ulIdx].hwnd, sizeof(acBuf), acBuf );
GpiQueryTextBox( hps, cbBuf, acBuf, TXTBOX_COUNT, aptText );
aptText[TXTBOX_TOPRIGHT].x -= aptText[TXTBOX_BOTTOMLEFT].x;
aptText[TXTBOX_TOPRIGHT].y -= aptText[TXTBOX_BOTTOMLEFT].y;
// Convert text size to dialog coordinates.
@ -154,7 +154,7 @@ static VOID _wmInitDlg(HWND hwnd, PMSGBOXDLGDATA pDlgData)
aptText[1].x = aButtons[ulIdx].ulCX;
aptText[1].y = ulButtonsCY;
// Convert to window coordinates.
WinMapDlgPoints( hwnd, &aptText, 2, TRUE );
WinMapDlgPoints( hwnd, aptText, 2, TRUE );
WinSetWindowPos( aButtons[ulIdx].hwnd, HWND_TOP,
aptText[0].x, aptText[0].y, aptText[1].x, aptText[1].y,
@ -229,10 +229,8 @@ static HWND _makeDlg(const SDL_MessageBoxData *messageboxdata)
PSZ pszBtnText;
ULONG cbBtnText;
HWND hwnd;
SDL_MessageBoxColor *pSDLColors = messageboxdata->colorScheme == NULL
? NULL
: (SDL_MessageBoxColor *)&messageboxdata->colorScheme->colors;
SDL_MessageBoxColor *pSDLColor;
const SDL_MessageBoxColor *pSDLColors = (messageboxdata->colorScheme == NULL)? NULL : messageboxdata->colorScheme->colors;
const SDL_MessageBoxColor *pSDLColor;
MSGBOXDLGDATA stDlgData;
/* Build a dialog tamplate in memory */
@ -256,7 +254,7 @@ static HWND _makeDlg(const SDL_MessageBoxData *messageboxdata)
( 48 * cSDLBtnData ); /* PP for buttons. */
// Allocate memory for the dialog template.
pTemplate = SDL_malloc( cbTemplate );
pTemplate = (PDLGTEMPLATE) SDL_malloc( cbTemplate );
// Pointer on data for dialog items in allocated memory.
pcDlgData = &((PCHAR)pTemplate)[ sizeof(DLGTEMPLATE) +
( (2 + cSDLBtnData) * sizeof(DLGTITEM) ) ];
@ -276,7 +274,7 @@ static HWND _makeDlg(const SDL_MessageBoxData *messageboxdata)
/* First item info - frame */
pDlgItem = &pTemplate->adlgti;
pDlgItem = pTemplate->adlgti;
pDlgItem->fsItemStatus = 0; /* Reserved? */
/* Number of dialog item child windows owned by this item. */
pDlgItem->cChildren = 2 + cSDLBtnData; // Ststic text + buttons.

View File

@ -330,9 +330,9 @@ static VOID _wmChar(PWINDATA pWinData, MPARAM mp1, MPARAM mp2)
if ( (ulFlags & KC_CHAR) != 0 )
{
CHAR acUTF8[4];
LONG lRC = StrUTF8( 1, &acUTF8, sizeof(acUTF8), (PSZ)&ulCharCode, 1 );
LONG lRC = StrUTF8( 1, acUTF8, sizeof(acUTF8), (PSZ)&ulCharCode, 1 );
SDL_SendKeyboardText( lRC > 0 ? &acUTF8 : (PSZ)&ulCharCode );
SDL_SendKeyboardText( lRC > 0 ? acUTF8 : (PSZ)&ulCharCode );
}
}
@ -421,13 +421,13 @@ static MRESULT _wmDrop(PWINDATA pWinData, PDRAGINFO pDragInfo)
{
// Get file name from the item.
DrgQueryStrName( pDragItem->hstrContainerName,
sizeof(acFName), &acFName );
pcFName = strchr( &acFName, '\0' );
sizeof(acFName), acFName );
pcFName = strchr( acFName, '\0' );
DrgQueryStrName( pDragItem->hstrSourceName,
sizeof(acFName) - (pcFName - &acFName), pcFName );
sizeof(acFName) - (pcFName - acFName), pcFName );
// Send to SDL full file name converted to UTF-8.
pcFName = OS2_SysToUTF8( &acFName );
pcFName = OS2_SysToUTF8( acFName );
SDL_SendDropFile( pcFName );
SDL_free( pcFName );
@ -852,7 +852,7 @@ static int OS2_CreateWindowFrom(_THIS, SDL_Window *window, const void *data)
// Get client and frame window handles.
WinQueryClassName( hwndUser, sizeof(acBuf), acBuf );
if ( !WinQueryClassInfo( pVData->hab, &acBuf, &stCI ) )
if ( !WinQueryClassInfo( pVData->hab, acBuf, &stCI ) )
return SDL_SetError( "Cannot get user window class information" );
if ( (stCI.flClassStyle & CS_FRAME) == 0 )
@ -879,7 +879,7 @@ static int OS2_CreateWindowFrom(_THIS, SDL_Window *window, const void *data)
hwndFrame = hwndUser;
WinQueryClassName( hwnd, sizeof(acBuf), acBuf );
if ( !WinQueryClassInfo( pVData->hab, &acBuf, &stCI ) )
if ( !WinQueryClassInfo( pVData->hab, acBuf, &stCI ) )
return SDL_SetError( "Cannot get client window class information" );
}

View File

@ -103,7 +103,7 @@ static BOOL _vmanInit()
return TRUE;
// Load vman.dll
ulRC = DosLoadModule( &acBuf, sizeof(acBuf), "VMAN", &hmodVMan );
ulRC = DosLoadModule( acBuf, sizeof(acBuf), "VMAN", &hmodVMan );
if ( ulRC != NO_ERROR )
{
debug( "Could not load VMAN.DLL, rc = %u : %s", ulRC, &acBuf );