[Top][All Lists]

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

RE: [lwip-devel] Checksum optimizations

From: Bill Auerbach
Subject: RE: [lwip-devel] Checksum optimizations
Date: Tue, 11 Mar 2008 11:20:17 -0400

I missed a curly brace – I see why it’s done like it is.  As mentioned, the while loop can still be safely omitted.




From: lwip-develaddress@hidden [mailto:lwip-develaddress@hidden On Behalf Of Bill Auerbach
Sent: Tuesday, March 11, 2008 10:07 AM
To: 'lwip-devel'
Subject: RE: [lwip-devel] Checksum optimizations


Looking at this a bit close, I have to question:

  for(q = p; q != NULL; q = q->next) {

    acc += LWIP_CHKSUM(q->payload, q->len);

    while ((acc >> 16) != 0) {

      acc = (acc & 0xffffUL) + (acc >> 16);



I don’t think:


    while ((acc >> 16) != 0) {

      acc = (acc & 0xffffUL) + (acc >> 16);



Should be inside the for loop.  It makes no difference if the carry-outs are taken care of at the end versus in the loop.  Except as you noted in the loop there can only be one carry out and after the loop there could be 2.


inet_chksum_pbuf's use of this while loop can also be simplified as per your suggestion.

reply via email to

[Prev in Thread] Current Thread [Next in Thread]