Fix some MSVC warnings
I'm feeling very lazy today, today's commits prove that point nicely :)
Modified: trunk/reactos/apps/utils/net/arp/arp.c
_____
Modified: trunk/reactos/apps/utils/net/arp/arp.c
--- trunk/reactos/apps/utils/net/arp/arp.c 2005-12-28 01:29:42 UTC
(rev 20389)
+++ trunk/reactos/apps/utils/net/arp/arp.c 2005-12-28 02:20:27 UTC
(rev 20390)
@@ -66,26 +66,30 @@
{
LPVOID lpMsgBuf;
DWORD RetVal;
- /* double brackets to silence the assignment warning message */
- if ((RetVal = FormatMessage(
- FORMAT_MESSAGE_ALLOCATE_BUFFER |
- FORMAT_MESSAGE_FROM_SYSTEM |
- FORMAT_MESSAGE_IGNORE_INSERTS,
- NULL,
- ErrorCode,
- MAKELANGID(LANG_NEUTRAL, SUBLANG_DEFAULT), /* Default
language */
- (LPTSTR) &lpMsgBuf,
- 0,
- NULL ))) {
- _tprintf(_T("%s"), (LPTSTR)lpMsgBuf);
- LocalFree(lpMsgBuf);
- /* return number of TCHAR's stored in output buffer
- * excluding '\0' - as FormatMessage does*/
- return RetVal;
+ if (ErrorCode != ERROR_SUCCESS)
+ {
+ RetVal = FormatMessage(FORMAT_MESSAGE_ALLOCATE_BUFFER |
+ FORMAT_MESSAGE_FROM_SYSTEM |
+ FORMAT_MESSAGE_IGNORE_INSERTS,
+ NULL,
+ ErrorCode,
+ MAKELANGID(LANG_NEUTRAL,
SUBLANG_DEFAULT), /* Default language */
+ (LPTSTR) &lpMsgBuf,
+ 0,
+ NULL );
+
+ if (RetVal != 0)
+ {
+ _tprintf(_T("%s"), (LPTSTR)lpMsgBuf);
+
+ LocalFree(lpMsgBuf);
+ /* return number of TCHAR's stored in output buffer
+ * excluding '\0' - as FormatMessage does*/
+ return RetVal;
+ }
}
- else
- return 0;
+ return 0;
}
@@ -256,8 +260,7 @@
DWORD dwIpAddr = 0;
DWORD dwSize = 0;
ULONG ulSize = 0;
- INT iRet, i, val;
- TCHAR c;
+ INT iRet, i, val, c;
/* error checking */
@@ -318,7 +321,14 @@
/* set dwIndex field to the index of a local IP address to
* indicate the network on which the ARP entry applies */
if (pszIfAddr)
- sscanf(pszIfAddr, "%lx", &pAddHost->dwIndex);
+ {
+ if (sscanf(pszIfAddr, "%lx", &pAddHost->dwIndex) == EOF)
+ {
+ free(pIpNetTable);
+ free(pAddHost);
+ return EXIT_FAILURE;
+ }
+ }
else
{
/* map the IP to the index */
@@ -355,7 +365,7 @@
c = toupper(pszEthAddr[i*3 + 1]);
c = c - (isdigit(c) ? '0' : ('A' - 10));
val += c;
- pAddHost->bPhysAddr[i] = val;
+ pAddHost->bPhysAddr[i] = (BYTE)val;
}
@@ -444,7 +454,15 @@
/* set dwIndex field to the index of a local IP address to
* indicate the network on which the ARP entry applies */
if (pszIfAddr)
- sscanf(pszIfAddr, "%lx", &pDelHost->dwIndex);
+ {
+ if (sscanf(pszIfAddr, "%lx", &pDelHost->dwIndex) == EOF)
+ {
+ free(pIpNetTable);
+ free(pIpAddrTable);
+ free(pDelHost);
+ return EXIT_FAILURE;
+ }
+ }
else
{
/* map the IP to the index */