walsh@Bbn-Labs-B.ARPA (05/11/84)
From: Bob Walsh <walsh@Bbn-Labs-B.ARPA> This funtions does not act properly if it is passed an mbuf chain like: mbuf ------> mbufs of data +--------+ | tcp/ip | | header | | m_len=0| +--------+ and it is asked to trim some number of bytes from the end of the chain. To correct the code, *** uipc_mbuf.c Fri May 11 08:04:03 1984 --- uipc_mbuf.old Fri May 11 07:55:07 1984 *************** *** 375,383 struct mbuf *mp; register int len; { - #ifdef BUGFIXES - register struct mbuf *m; - #else register struct mbuf *m, *n; #endif --- 375,380 ----- struct mbuf *mp; register int len; { register struct mbuf *m, *n; if ((m = mp) == NULL) *************** *** 379,385 register struct mbuf *m; #else register struct mbuf *m, *n; - #endif if ((m = mp) == NULL) return; --- 376,381 ----- register int len; { register struct mbuf *m, *n; if ((m = mp) == NULL) return; *************** *** 396,432 } } } else { - #ifdef BUGFIXES - register struct mbuf *last, *next; - - /* step one, reverse mbuf chain */ - /* it is at least one long */ - last = 0; - len = (-len); - do { - next = m->m_next; - m->m_next = last; - last = m; - m = next; - } while (m); - - /* step two, reverse list and remove bytes */ - m = last; - last = 0; - do { - next = m->m_next; - m->m_next = last; - last = m; - if (len > m->m_len){ /* shave */ - len -= m->m_len; /* shave */ - m->m_len = 0; /* shave */ - } else { /* shave */ - m->m_len -= len; /* shave */ - len = 0; /* shave */ - } - m = next; - } while (m); - #else /* a 2 pass algorithm might be better */ len = -len; while (len > 0 && m->m_len != 0) { --- 392,397 ----- } } } else { /* a 2 pass algorithm might be better */ len = -len; while (len > 0 && m->m_len != 0) { *************** *** 443,449 break; } } - #endif } } --- 408,413 ----- break; } } } } bob walsh complexity". It clearly was not worth the effort, was not cost effective, and any really good programmer could use scaled integer arithmetic anyway. They didn't have compilers then like we have now (most programming was in assembler), and so the argument about the compiler doing the scaling couldn't be made, but otherwise the current discussion sounds like a rehash of some of those old debates, with simple string substitution for the topics). Those who do not study history are doomed to repeat it... have fun joe -------