Path: utzoo!attcan!uunet!husc6!mailrus!ncar!ames!elroy!spl1!laidbak!stevea From: stevea@laidbak.UUCP (Steve Alexander) Newsgroups: comp.lang.c Subject: Re: assigning an integer to the negation of ... Message-ID: <1889@laidbak.UUCP> Date: 22 Dec 88 16:16:54 GMT References: <1911@pembina.UUCP> <15090@mimsy.UUCP> <22651@apple.Apple.COM> Reply-To: stevea@laidbak.UUCP (Steve Alexander) Organization: Lachman Associates, Inc. Naperville, Il. Lines: 18 In article <22651@apple.Apple.COM> desnoyer@Apple.COM (Peter Desnoyers) writes: [ About i = -(unsigned short)j producing different results on BSD and SunOS ] > >It was pointed out that the context in which this problem arose was >TCP software - I would bet it was the window size calculations. > Peter Desnoyers Err, umm, (sorry, Guy) actually, this code is in IP, not TCP. It occurs in netinet/ip_input.c at the point where IP is deciding how big the datagram is. It negates the data length in the IP header (i = -(unsigned short)ip->ip_len) and then adds the lengths of all mbufs in the chain to the negated length. If the result is negative, the datagram is thrown away because it is too short. Otherwise, m_adj is called to trim the excess garbage from the end of the chain. -- Steve Alexander, TCP/IP Development | stevea%laidbak@sun.com Lachman Associates, Inc. | ...!sun!laidbak!stevea