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:
16
source/dcc.c
16
source/dcc.c
@@ -1793,16 +1793,18 @@ void BX_dcc_send_socketread(int snum)
|
|||||||
{
|
{
|
||||||
SocketList *s;
|
SocketList *s;
|
||||||
DCC_int *n;
|
DCC_int *n;
|
||||||
u_32int_t bytes = 0;
|
|
||||||
int bytesread = 0;
|
int bytesread = 0;
|
||||||
char *buffer = alloca(MAX_DCC_BLOCK_SIZE+1);
|
char buffer[MAX_DCC_BLOCK_SIZE+1];
|
||||||
|
|
||||||
s = get_socket(snum);
|
s = get_socket(snum);
|
||||||
n = (DCC_int *)s->info;
|
n = (DCC_int *)s->info;
|
||||||
if (n->readwaiting || n->eof)
|
|
||||||
{
|
|
||||||
int numbytes = 0;
|
|
||||||
if (!(s->flags & DCC_TDCC) && n->readwaiting)
|
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)
|
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));
|
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)
|
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;
|
u_32int_t *buf;
|
||||||
|
|
||||||
n->readwaiting = 1;
|
n->readwaiting = 1;
|
||||||
if ((ioctl(snum, FIONREAD, &numbytes) == -1))
|
if ((ioctl(snum, FIONREAD, &numbytes) == -1))
|
||||||
{
|
{
|
||||||
@@ -1851,7 +1856,6 @@ char *buffer = alloca(MAX_DCC_BLOCK_SIZE+1);
|
|||||||
}
|
}
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
|
||||||
if ((bytesread = read(n->file, buffer, n->blocksize)) > 0)
|
if ((bytesread = read(n->file, buffer, n->blocksize)) > 0)
|
||||||
{
|
{
|
||||||
|
|||||||
Reference in New Issue
Block a user