Simplify dcc_send_socketread()

There should be no change in behaviour.  Replaces a code block of the form:

if (a || b)
{
    if (c && a)
    {
        /* one */
    }
    else if (b)
    {
        /* two */
    }
}

with the simpler equivalent:

if (c && a)
{
    /* one */
}
else if (b)
{
    /* two */
}
This commit is contained in:
Kevin Easton
2018-04-12 00:20:13 +10:00
parent 99c5ec9872
commit 208fddb9f5

View File

@@ -1791,18 +1791,20 @@ void close_dcc_file(int snum)
void BX_dcc_send_socketread(int snum)
{
SocketList *s;
DCC_int *n;
u_32int_t bytes = 0;
int bytesread = 0;
char *buffer = alloca(MAX_DCC_BLOCK_SIZE+1);
SocketList *s;
DCC_int *n;
int bytesread = 0;
char buffer[MAX_DCC_BLOCK_SIZE+1];
s = get_socket(snum);
n = (DCC_int *)s->info;
if (n->readwaiting || n->eof)
{
int numbytes = 0;
if (!(s->flags & DCC_TDCC) && n->readwaiting)
{
/* n->readwaiting is set when we have sent a block and are waiting for an acknowledgement. */
int numbytes = 0;
u_32int_t bytes = 0;
if ((ioctl(snum, FIONREAD, &numbytes)) == -1)
{
erase_dcc_info(snum, 1, convert_output_format("$G %RDCC%n Remote $0 closed dcc send", "%s", s->server));
@@ -1830,7 +1832,10 @@ char *buffer = alloca(MAX_DCC_BLOCK_SIZE+1);
}
else if (n->eof)
{
/* n->eof is set if read() on the file we are sending returns EOF or error. */
int numbytes = 0;
u_32int_t *buf;
n->readwaiting = 1;
if ((ioctl(snum, FIONREAD, &numbytes) == -1))
{
@@ -1851,7 +1856,6 @@ char *buffer = alloca(MAX_DCC_BLOCK_SIZE+1);
}
return;
}
}
if ((bytesread = read(n->file, buffer, n->blocksize)) > 0)
{