Skip to content

Commit 9c58463

Browse files
committed
UIPClient: ensure uip_slen (uip.c internal) is set allways set (as it's not cleared bevore poll-requests) (saves 14 bytes of flash)
1 parent 7f8fbc0 commit 9c58463

File tree

1 file changed

+13
-14
lines changed

1 file changed

+13
-14
lines changed

UIPClient.cpp

Lines changed: 13 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -329,6 +329,7 @@ UIPClient::flush()
329329
void
330330
uipclient_appcall(void)
331331
{
332+
uint16_t send_len = 0;
332333
uip_userdata_t *u = (uip_userdata_t*)uip_conn->appstate;
333334
if (!u && uip_connected())
334335
{
@@ -406,7 +407,7 @@ uipclient_appcall(void)
406407
UIPClient::_dumpAllData();
407408
#endif
408409
uip_conn->appstate = NULL;
409-
goto nodata;
410+
goto finish;
410411
}
411412
if (uip_acked())
412413
{
@@ -424,28 +425,25 @@ uipclient_appcall(void)
424425
{
425426
if (u->packets_out[1] == NOBLOCK)
426427
{
427-
uip_len = u->out_pos;
428-
if (uip_len > 0)
428+
send_len = u->out_pos;
429+
if (send_len > 0)
429430
{
430-
Enc28J60Network::resizeBlock(u->packets_out[0],0,uip_len);
431+
Enc28J60Network::resizeBlock(u->packets_out[0],0,send_len);
431432
}
432433
}
433434
else
434-
uip_len = Enc28J60Network::blockSize(u->packets_out[0]);
435-
if (uip_len > 0)
435+
send_len = Enc28J60Network::blockSize(u->packets_out[0]);
436+
if (send_len > 0)
436437
{
437438
UIPEthernetClass::uip_hdrlen = ((uint8_t*)uip_appdata)-uip_buf;
438-
UIPEthernetClass::uip_packet = Enc28J60Network::allocBlock(UIPEthernetClass::uip_hdrlen+uip_len);
439+
UIPEthernetClass::uip_packet = Enc28J60Network::allocBlock(UIPEthernetClass::uip_hdrlen+send_len);
439440
if (UIPEthernetClass::uip_packet != NOBLOCK)
440441
{
441-
Enc28J60Network::copyPacket(UIPEthernetClass::uip_packet,UIPEthernetClass::uip_hdrlen,u->packets_out[0],0,uip_len);
442+
Enc28J60Network::copyPacket(UIPEthernetClass::uip_packet,UIPEthernetClass::uip_hdrlen,u->packets_out[0],0,send_len);
442443
UIPEthernetClass::packetstate |= UIPETHERNET_SENDPACKET;
443-
uip_send(uip_appdata,uip_len);
444-
return;
445444
}
446-
else
447-
goto nodata;
448445
}
446+
goto finish;
449447
}
450448
}
451449
// don't close connection unless all outgoing packets are sent
@@ -474,8 +472,9 @@ uipclient_appcall(void)
474472
}
475473
}
476474
}
477-
nodata:
478-
uip_len=0;
475+
finish:
476+
uip_send(uip_appdata,send_len);
477+
uip_len = send_len;
479478
}
480479

481480
uip_userdata_t *

0 commit comments

Comments
 (0)