Various application fixes by Jan Roeloffzen, bug #5182, part 3

arp: Remove unused variables
ftp: tabs->spaces, remove unused variables
nslookup: Remove unused variables

svn path=/trunk/; revision=47460
This commit is contained in:
Gregor Schneider 2010-05-30 20:31:58 +00:00
parent 81d25d5267
commit ad964bddb1
4 changed files with 92 additions and 112 deletions

View file

@ -170,9 +170,7 @@ INT DisplayArpEntries(PTCHAR pszInetAddr, PTCHAR pszIfAddr)
ZeroMemory(pIpNetTable, sizeof(*pIpNetTable));
iRet = GetIpNetTable(pIpNetTable, &Size, TRUE);
if (iRet != NO_ERROR)
if (GetIpNetTable(pIpNetTable, &Size, TRUE) != NO_ERROR)
{
_tprintf(_T("failed to allocate memory for GetIpNetTable\n"));
DoFormatMessage();
@ -201,9 +199,7 @@ INT DisplayArpEntries(PTCHAR pszInetAddr, PTCHAR pszIfAddr)
ZeroMemory(pIpAddrTable, sizeof(*pIpAddrTable));
iRet = GetIpAddrTable(pIpAddrTable, &Size, TRUE);
if (iRet != NO_ERROR)
if ((iRet = GetIpAddrTable(pIpAddrTable, &Size, TRUE)) != NO_ERROR)
{
_tprintf(_T("GetIpAddrTable failed: %d\n"), iRet);
DoFormatMessage();
@ -272,7 +268,7 @@ INT Addhost(PTCHAR pszInetAddr, PTCHAR pszEthAddr, PTCHAR pszIfAddr)
PMIB_IPNETTABLE pIpNetTable = NULL;
DWORD dwIpAddr = 0;
ULONG Size = 0;
INT iRet, i, val, c;
INT i, val, c;
/* error checking */
@ -320,9 +316,7 @@ INT Addhost(PTCHAR pszInetAddr, PTCHAR pszEthAddr, PTCHAR pszIfAddr)
ZeroMemory(pIpNetTable, sizeof(*pIpNetTable));
iRet = GetIpNetTable(pIpNetTable, &Size, TRUE);
if (iRet != NO_ERROR)
if (GetIpNetTable(pIpNetTable, &Size, TRUE) != NO_ERROR)
{
_tprintf(_T("failed to allocate memory for GetIpNetTable\n"));
DoFormatMessage();
@ -382,7 +376,7 @@ INT Addhost(PTCHAR pszInetAddr, PTCHAR pszEthAddr, PTCHAR pszIfAddr)
/* Add the ARP entry */
if ((iRet = SetIpNetEntry(pAddHost)) != NO_ERROR)
if (SetIpNetEntry(pAddHost) != NO_ERROR)
{
DoFormatMessage();
goto cleanup;
@ -415,7 +409,6 @@ INT Deletehost(PTCHAR pszInetAddr, PTCHAR pszIfAddr)
PMIB_IPNETTABLE pIpNetTable = NULL;
ULONG Size = 0;
DWORD dwIpAddr = 0;
INT iRet;
BOOL bFlushTable = FALSE;
/* error checking */
@ -449,9 +442,7 @@ INT Deletehost(PTCHAR pszInetAddr, PTCHAR pszIfAddr)
ZeroMemory(pIpNetTable, sizeof(*pIpNetTable));
iRet = GetIpNetTable(pIpNetTable, &Size, TRUE);
if (iRet != NO_ERROR)
if (GetIpNetTable(pIpNetTable, &Size, TRUE) != NO_ERROR)
{
_tprintf(_T("failed to allocate memory for GetIpNetTable\n"));
DoFormatMessage();
@ -485,7 +476,7 @@ INT Deletehost(PTCHAR pszInetAddr, PTCHAR pszIfAddr)
if (bFlushTable == TRUE)
{
/* delete arp cache */
if ((iRet = FlushIpNetTable(pDelHost->dwIndex)) != NO_ERROR)
if (FlushIpNetTable(pDelHost->dwIndex) != NO_ERROR)
{
DoFormatMessage();
goto cleanup;
@ -501,7 +492,7 @@ INT Deletehost(PTCHAR pszInetAddr, PTCHAR pszIfAddr)
pDelHost->dwAddr = dwIpAddr;
/* Add the ARP entry */
if ((iRet = DeleteIpNetEntry(pDelHost)) != NO_ERROR)
if (DeleteIpNetEntry(pDelHost) != NO_ERROR)
{
DoFormatMessage();
goto cleanup;

View file

@ -29,10 +29,10 @@ int checkRecv(SOCKET s)
void blkfree(char **av0)
{
register char **av = av0;
register char **av = av0;
while (*av)
free(*av++);
while (*av)
free(*av++);
}
char **glob(register char *v)
@ -52,16 +52,16 @@ int herror(char *string)
#if 0
int gettimeofday(struct timeval *timenow,
struct timezone *zone)
struct timezone *zone)
{
time_t t;
time_t t;
t = clock();
t = clock();
timenow->tv_usec = t;
timenow->tv_sec = t / CLK_TCK;
timenow->tv_usec = t;
timenow->tv_sec = t / CLK_TCK;
return 0;
return 0;
}
int fgetcSocket(int s)
@ -100,13 +100,13 @@ int fgetcSocket(int s)
total = recv(s, buffer, sizeof(buffer), 0);
if (total == SOCKET_ERROR)
{
total = 0;
return ERROR;
}
{
total = 0;
return ERROR;
}
if (total == 0)
return EOF;
return EOF;
}
return buffer[index++];
}
@ -142,29 +142,29 @@ int fputcSocket(int s, char putChar)
buffer[1] = '\0';
if(SOCKET_ERROR==send(s, buffer, 1, 0)) {
int iret=WSAGetLastError ();
fprintf(stdout,"fputcSocket: %d\n",iret);
return 0;
int iret=WSAGetLastError ();
fprintf(stdout,"fputcSocket: %d\n",iret);
return 0;
}
else {
return putChar;
return putChar;
}
}
int fputSocket(int s, char *buffer, int len)
{
int iret;
while(len) {
if(SOCKET_ERROR==(iret=send(s, buffer, len, 0)))
{
iret=WSAGetLastError ();
fprintf(stdout,"fputcSocket: %d\n",iret);
return 0;
}
else {
return len-=iret;
}
}
return 0;
int iret;
while(len) {
if(SOCKET_ERROR==(iret=send(s, buffer, len, 0)))
{
iret=WSAGetLastError ();
fprintf(stdout,"fputcSocket: %d\n",iret);
return 0;
}
else {
return len-=iret;
}
}
return 0;
}
char *fgetsSocket(int s, char *string)
@ -180,31 +180,31 @@ char *fgetsSocket(int s, char *string)
if (count == SOCKET_ERROR)
{
printf("Error in fgetssocket");
return NULL;
printf("Error in fgetssocket");
return NULL;
}
if (count == 1)
{
string[i] = buffer[0];
string[i] = buffer[0];
if (i == MAX_ASCII - 3)
{
count = 0;
string[++i] = '\n';
string[++i] = '\0';
}
if (i == MAX_ASCII - 3)
{
count = 0;
string[++i] = '\n';
string[++i] = '\0';
}
}
else
{
if (i == 0)
return NULL;
else
{
string[i] = '\n';
string[i + 1] = '\0'; // This is risky
return string;
}
if (i == 0)
return NULL;
else
{
string[i] = '\n';
string[i + 1] = '\0'; // This is risky
return string;
}
}
@ -250,44 +250,44 @@ char *getpass (const char * prompt)
int rc;
if (istty)
{
if (GetConsoleMode (in, &old_flags))
SetConsoleMode (in, ENABLE_LINE_INPUT | ENABLE_PROCESSED_INPUT);
else
istty = 0;
}
{
if (GetConsoleMode (in, &old_flags))
SetConsoleMode (in, ENABLE_LINE_INPUT | ENABLE_PROCESSED_INPUT);
else
istty = 0;
}
/* Need to read line one byte at time to avoid blocking, if not a
tty, so always do it this way. */
count = 0;
while (1)
{
DWORD dummy;
char one_char;
{
DWORD dummy;
char one_char;
rc = ReadFile (in, &one_char, 1, &dummy, NULL);
if (rc == 0)
break;
if (one_char == '\r')
{
/* CR is always followed by LF if reading from tty. */
if (istty)
continue;
else
break;
}
if (one_char == '\n')
break;
/* Silently truncate password string if overly long. */
if (count < sizeof (input) - 1)
input[count++] = one_char;
}
rc = ReadFile (in, &one_char, 1, &dummy, NULL);
if (rc == 0)
break;
if (one_char == '\r')
{
/* CR is always followed by LF if reading from tty. */
if (istty)
continue;
else
break;
}
if (one_char == '\n')
break;
/* Silently truncate password string if overly long. */
if (count < sizeof (input) - 1)
input[count++] = one_char;
}
input[count] = '\0';
WriteFile (err, "\r\n", 2, &count, NULL);
if (istty)
SetConsoleMode (in, old_flags);
SetConsoleMode (in, old_flags);
if (rc)
return input;
return input;
}
return NULL;

View file

@ -345,7 +345,7 @@ getreply(expecteof)
cp = reply_string;
while ((c = fgetcSocket(cin)) != '\n') {
if (c == IAC) { /* handle telnet commands */
switch (c = fgetcSocket(cin)) {
switch (fgetcSocket(cin)) {
case WILL:
case WONT:
c = fgetcSocket(cin);
@ -745,7 +745,7 @@ void recvrequest(const char *cmd, const char *local, const char *remote, const c
long bytes = 0, hashbytes = HASHBYTES;
// struct
fd_set mask;
register int c, d;
register int c;
struct timeval start, stop;
// struct stat st;
@ -781,6 +781,7 @@ null();// (void) signal(SIGINT, oldintr);
null();// oldintr = signal(SIGINT, abortrecv);
if (strcmp(local, "-") && *local != '|') {
#ifndef _WIN32
register int d;
// This whole thing is a problem... access Won't work on non-existent files
if (access(local, 2) < 0) {
char *dir = rindex(local, '/');
@ -919,7 +920,7 @@ null();// oldintp = signal(SIGPIPE, SIG_IGN);
(*closefunc)(fout);
return;
}
errno = d = 0;
errno = 0;
// while ((c = recv(din, buf, bufsize, 1)) > 0) {
// if ((d = write(fileno(fout), buf, c)) != c)
// if ((d = write(fileno(fout), buf, c)) != c)
@ -1106,10 +1107,10 @@ null();// (void) signal(SIGINT,oldintr);
lostpeer();
}
if (din && FD_ISSET(din, &mask)) {
while ((c = recv(din, buf, bufsize, 0)) > 0)
while (recv(din, buf, bufsize, 0) > 0)
;
}
if ((c = getreply(0)) == ERROR && code == 552) { /* needed for nic style abort */
if (getreply(0) == ERROR && code == 552) { /* needed for nic style abort */
if (data >= 0) {
(void) close(data);
data = -1;

View file

@ -90,11 +90,7 @@ BOOL PerformInternalLookup( PCHAR pAddr, PCHAR pResult )
BOOL bOk = FALSE;
/* Makes things easier when parsing the response packet. */
UCHAR Header1, Header2;
USHORT NumQuestions;
USHORT NumAnswers;
USHORT NumAuthority;
USHORT NumAdditional;
USHORT Type;
if( (strlen( pAddr ) + 1) > 255 ) return FALSE;
@ -198,12 +194,7 @@ BOOL PerformInternalLookup( PCHAR pAddr, PCHAR pResult )
if( !bOk ) goto cleanup;
/* Start parsing the received packet. */
Header1 = RecBuffer[2];
Header2 = RecBuffer[3];
NumQuestions = ntohs( ((PSHORT)&RecBuffer[4])[0] );
NumAnswers = ntohs( ((PSHORT)&RecBuffer[6])[0] );
NumAuthority = ntohs( ((PUSHORT)&RecBuffer[8])[0] );
NumAdditional = ntohs( ((PUSHORT)&RecBuffer[10])[0] );
k = 12;
@ -257,11 +248,10 @@ void PerformLookup( PCHAR pAddr )
BOOL bOk = FALSE;
/* Makes things easier when parsing the response packet. */
UCHAR Header1, Header2;
UCHAR Header2;
USHORT NumQuestions;
USHORT NumAnswers;
USHORT NumAuthority;
USHORT NumAdditional;
USHORT Type;
if( (strlen( pAddr ) + 1) > 255 ) return;
@ -368,19 +358,17 @@ void PerformLookup( PCHAR pAddr )
((PSHORT)&Buffer[i])[0] = htons( ClassNametoClassID( State.Class ) );
/* Ship off the request to the DNS server. */
bOk = SendRequest( Buffer,
bOk = SendRequest( Buffer,
BufferLength,
RecBuffer,
&RecBufferLength );
if( !bOk ) goto cleanup;
/* Start parsing the received packet. */
Header1 = RecBuffer[2];
Header2 = RecBuffer[3];
NumQuestions = ntohs( ((PSHORT)&RecBuffer[4])[0] );
NumAnswers = ntohs( ((PSHORT)&RecBuffer[6])[0] );
NumAuthority = ntohs( ((PUSHORT)&RecBuffer[8])[0] );
NumAdditional = ntohs( ((PUSHORT)&RecBuffer[10])[0] );
Type = 0;
/* Check the RCODE for failure. */