Fix some MSVC warnings

I'm feeling very lazy today, today's commits prove that point nicely :)

svn path=/trunk/; revision=20390
This commit is contained in:
Ged Murphy 2005-12-28 02:20:27 +00:00
parent ecdb896991
commit 4662df1208

View file

@ -66,9 +66,10 @@ DWORD DoFormatMessage(DWORD ErrorCode)
{ {
LPVOID lpMsgBuf; LPVOID lpMsgBuf;
DWORD RetVal; DWORD RetVal;
/* double brackets to silence the assignment warning message */
if ((RetVal = FormatMessage( if (ErrorCode != ERROR_SUCCESS)
FORMAT_MESSAGE_ALLOCATE_BUFFER | {
RetVal = FormatMessage(FORMAT_MESSAGE_ALLOCATE_BUFFER |
FORMAT_MESSAGE_FROM_SYSTEM | FORMAT_MESSAGE_FROM_SYSTEM |
FORMAT_MESSAGE_IGNORE_INSERTS, FORMAT_MESSAGE_IGNORE_INSERTS,
NULL, NULL,
@ -76,7 +77,10 @@ DWORD DoFormatMessage(DWORD ErrorCode)
MAKELANGID(LANG_NEUTRAL, SUBLANG_DEFAULT), /* Default language */ MAKELANGID(LANG_NEUTRAL, SUBLANG_DEFAULT), /* Default language */
(LPTSTR) &lpMsgBuf, (LPTSTR) &lpMsgBuf,
0, 0,
NULL ))) { NULL );
if (RetVal != 0)
{
_tprintf(_T("%s"), (LPTSTR)lpMsgBuf); _tprintf(_T("%s"), (LPTSTR)lpMsgBuf);
LocalFree(lpMsgBuf); LocalFree(lpMsgBuf);
@ -84,7 +88,7 @@ DWORD DoFormatMessage(DWORD ErrorCode)
* excluding '\0' - as FormatMessage does*/ * excluding '\0' - as FormatMessage does*/
return RetVal; return RetVal;
} }
else }
return 0; return 0;
} }
@ -256,8 +260,7 @@ INT Addhost(PTCHAR pszInetAddr, PTCHAR pszEthAddr, PTCHAR pszIfAddr)
DWORD dwIpAddr = 0; DWORD dwIpAddr = 0;
DWORD dwSize = 0; DWORD dwSize = 0;
ULONG ulSize = 0; ULONG ulSize = 0;
INT iRet, i, val; INT iRet, i, val, c;
TCHAR c;
/* error checking */ /* error checking */
@ -318,7 +321,14 @@ INT Addhost(PTCHAR pszInetAddr, PTCHAR pszEthAddr, PTCHAR pszIfAddr)
/* set dwIndex field to the index of a local IP address to /* set dwIndex field to the index of a local IP address to
* indicate the network on which the ARP entry applies */ * indicate the network on which the ARP entry applies */
if (pszIfAddr) if (pszIfAddr)
sscanf(pszIfAddr, "%lx", &pAddHost->dwIndex); {
if (sscanf(pszIfAddr, "%lx", &pAddHost->dwIndex) == EOF)
{
free(pIpNetTable);
free(pAddHost);
return EXIT_FAILURE;
}
}
else else
{ {
/* map the IP to the index */ /* map the IP to the index */
@ -355,7 +365,7 @@ INT Addhost(PTCHAR pszInetAddr, PTCHAR pszEthAddr, PTCHAR pszIfAddr)
c = toupper(pszEthAddr[i*3 + 1]); c = toupper(pszEthAddr[i*3 + 1]);
c = c - (isdigit(c) ? '0' : ('A' - 10)); c = c - (isdigit(c) ? '0' : ('A' - 10));
val += c; val += c;
pAddHost->bPhysAddr[i] = val; pAddHost->bPhysAddr[i] = (BYTE)val;
} }
@ -444,7 +454,15 @@ INT Deletehost(PTCHAR pszInetAddr, PTCHAR pszIfAddr)
/* set dwIndex field to the index of a local IP address to /* set dwIndex field to the index of a local IP address to
* indicate the network on which the ARP entry applies */ * indicate the network on which the ARP entry applies */
if (pszIfAddr) if (pszIfAddr)
sscanf(pszIfAddr, "%lx", &pDelHost->dwIndex); {
if (sscanf(pszIfAddr, "%lx", &pDelHost->dwIndex) == EOF)
{
free(pIpNetTable);
free(pIpAddrTable);
free(pDelHost);
return EXIT_FAILURE;
}
}
else else
{ {
/* map the IP to the index */ /* map the IP to the index */