Relay-Version: version B 2.10 5/3/83; site utzoo.UUCP
Posting-Version: version B 2.10 5/3/83; site felix.UUCP
Path: utzoo!linus!philabs!sdcsvax!sdcrdcf!bmcg!felix!wes
From: wes@felix.UUCP
Newsgroups: net.bugs.uucp
Subject: Bug in pk0.c on 32 bit machines
Message-ID: <113@felix.UUCP>
Date: Fri, 8-Jul-83 13:51:12 EDT
Article-I.D.: felix.113
Posted: Fri Jul  8 13:51:12 1983
Date-Received: Sat, 9-Jul-83 19:15:14 EDT
Organization: FileNet Corp., Costa Mesa, Ca.
Lines: 33

Reference: <>

	Neil MacKenzie of Simon Fraser University (143@sfucmpt.UUCP) asked
for help in getting uucp to run between a Perkin-Elmer machine and a VAX.
The symptom was alarm messages from uucico after protocol selection.  Since
I've run across a similar problem on a couple of 32 bit machines using
the PCC compiler (esp. UniSoft ports to 68000's), I thought that the
fix deserved general notice.

	The bug is in pk0.c and appears at or near line 620 in the routine
chksum():

620c620
old< 		if ((unsigned)sum <= t) {
---
new> 		if ((unsigned short)sum <= t) {

The problem is in the meaning of casts, which were initially implemented
differently in the Ritchie and PCC compilers.  Sum is declared as short and
t as unsigned short.  The PCC compiler defines unsigned to be unsigned int
which on the Motorola 68000 and, I strongly suspect, the Perkin-Elmer is
the same as unsigned long.  The code that gets generated (properly according
to the most recent interpretation of casts) for "(unsigned)sum <= t" is:
	sign-extend sum to a long (because the underlying type decides
		the type of extension)
	zero extend t to a long (ditto)
	compare as unsigned longs
What was desired is to do an unsigned comparison of sum and t as
shorts (hence the fix).

	Wes Chalfant
	FileNet Corp.
	..!{decvax,ucbvax}!trw-unix!felix!wes