Skip to content

Commit

Permalink
UIPClient: ensure uip_slen (uip.c internal) is set allways set (as it…
Browse files Browse the repository at this point in the history
…'s not cleared bevore poll-requests) (saves 14 bytes of flash)
  • Loading branch information
ntruchsess committed Oct 13, 2014
1 parent 7f8fbc0 commit 9c58463
Showing 1 changed file with 13 additions and 14 deletions.
27 changes: 13 additions & 14 deletions UIPClient.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -329,6 +329,7 @@ UIPClient::flush()
void
uipclient_appcall(void)
{
uint16_t send_len = 0;
uip_userdata_t *u = (uip_userdata_t*)uip_conn->appstate;
if (!u && uip_connected())
{
Expand Down Expand Up @@ -406,7 +407,7 @@ uipclient_appcall(void)
UIPClient::_dumpAllData();
#endif
uip_conn->appstate = NULL;
goto nodata;
goto finish;
}
if (uip_acked())
{
Expand All @@ -424,28 +425,25 @@ uipclient_appcall(void)
{
if (u->packets_out[1] == NOBLOCK)
{
uip_len = u->out_pos;
if (uip_len > 0)
send_len = u->out_pos;
if (send_len > 0)
{
Enc28J60Network::resizeBlock(u->packets_out[0],0,uip_len);
Enc28J60Network::resizeBlock(u->packets_out[0],0,send_len);
}
}
else
uip_len = Enc28J60Network::blockSize(u->packets_out[0]);
if (uip_len > 0)
send_len = Enc28J60Network::blockSize(u->packets_out[0]);
if (send_len > 0)
{
UIPEthernetClass::uip_hdrlen = ((uint8_t*)uip_appdata)-uip_buf;
UIPEthernetClass::uip_packet = Enc28J60Network::allocBlock(UIPEthernetClass::uip_hdrlen+uip_len);
UIPEthernetClass::uip_packet = Enc28J60Network::allocBlock(UIPEthernetClass::uip_hdrlen+send_len);
if (UIPEthernetClass::uip_packet != NOBLOCK)
{
Enc28J60Network::copyPacket(UIPEthernetClass::uip_packet,UIPEthernetClass::uip_hdrlen,u->packets_out[0],0,uip_len);
Enc28J60Network::copyPacket(UIPEthernetClass::uip_packet,UIPEthernetClass::uip_hdrlen,u->packets_out[0],0,send_len);
UIPEthernetClass::packetstate |= UIPETHERNET_SENDPACKET;
uip_send(uip_appdata,uip_len);
return;
}
else
goto nodata;
}
goto finish;
}
}
// don't close connection unless all outgoing packets are sent
Expand Down Expand Up @@ -474,8 +472,9 @@ uipclient_appcall(void)
}
}
}
nodata:
uip_len=0;
finish:
uip_send(uip_appdata,send_len);
uip_len = send_len;
}

uip_userdata_t *
Expand Down

0 comments on commit 9c58463

Please sign in to comment.