Skip to content

Commit 459da72

Browse files
committedApr 23, 2015
liblwip/netif/liteethif: follow lwip doc recommendations regarding end of pbuf chain detection
1 parent 7290013 commit 459da72

File tree

1 file changed

+14
-6
lines changed

1 file changed

+14
-6
lines changed
 

Diff for: ‎soc/runtime/liblwip/netif/liteethif.c

+14-6
Original file line numberDiff line numberDiff line change
@@ -59,10 +59,15 @@ static err_t liteeth_low_level_output(struct netif *netif, struct pbuf *p)
5959
struct pbuf *q;
6060

6161
txlen = 0;
62-
for(q = p; q != NULL; q = q->next) {
62+
q = p;
63+
while(q) {
6364
memcpy(txbuffer, q->payload, q->len);
6465
txbuffer += q->len;
6566
txlen += q->len;
67+
if(q->tot_len != q->len)
68+
q = q->next;
69+
else
70+
q = NULL;
6671
}
6772

6873
ethmac_sram_reader_slot_write(txslot);
@@ -91,11 +96,14 @@ static struct pbuf *liteeth_low_level_input(struct netif *netif)
9196
rxbuffer = rxbuffer0;
9297

9398
p = pbuf_alloc(PBUF_RAW, rxlen, PBUF_POOL);
94-
if(p != NULL) {
95-
for(q = p; q != NULL; q = q->next) {
96-
memcpy(q->payload, rxbuffer, q->len);
97-
rxbuffer += q->len;
98-
}
99+
q = p;
100+
while(q) {
101+
memcpy(q->payload, rxbuffer, q->len);
102+
rxbuffer += q->len;
103+
if(q->tot_len != q->len)
104+
q = q->next;
105+
else
106+
q = NULL;
99107
}
100108

101109
return p;

0 commit comments

Comments
 (0)
Please sign in to comment.