From owner-cvs-all Mon Feb 1 21:13:00 1999 Return-Path: Received: (from majordom@localhost) by hub.freebsd.org (8.8.8/8.8.8) id VAA11149 for cvs-all-outgoing; Mon, 1 Feb 1999 21:13:00 -0800 (PST) (envelope-from owner-cvs-all@FreeBSD.ORG) Received: from godzilla.zeta.org.au (godzilla.zeta.org.au [203.26.10.9]) by hub.freebsd.org (8.8.8/8.8.8) with ESMTP id VAA11142 for ; Mon, 1 Feb 1999 21:12:56 -0800 (PST) (envelope-from bde@godzilla.zeta.org.au) Received: (from bde@localhost) by godzilla.zeta.org.au (8.8.7/8.8.7) id QAA17600; Tue, 2 Feb 1999 16:12:50 +1100 Date: Tue, 2 Feb 1999 16:12:50 +1100 From: Bruce Evans Message-Id: <199902020512.QAA17600@godzilla.zeta.org.au> To: mjacob@feral.com, wollman@khavrinen.lcs.mit.edu Subject: Re: sizeof (ptr) != sizeof (unsigned) Cc: cvs-commiters@FreeBSD.ORG Sender: owner-cvs-all@FreeBSD.ORG Precedence: bulk >> bcopy(&p1->p_procsig->ps_begincopy, &p2->p_procsig->ps_begincopy, >> (unsigned)&p1->p_procsig->ps_endcopy - >> (unsigned)&p1->p_procsig->ps_begincopy); > >> What's this for? > >This copies just the part of the proc struct that's supposed to be >copied. Er, not quite. This copies the part of the procsig struct that's supposed to be copied. See about 45 lines lines earlier in kern_fork.c for much older, somewhat less bogus code where part of the proc struct is copied. >It would be cleaner if the operands were cast to `char *', The old code does cast to caddr_t. This is equivalent, since the kernel makes so many assumptions that caddr_t is precisely `char *' that caddr_t is just an obfuscation of `char *'. >but it should work either way on any processor architecture the kernel >is ever likely to run on. (Of course, the type of the third formal >argument to bcopy() must have at least the range of a positive >ptrdiff_t, but there are plenty of other places where this is already >required.) However, it is stupid to cast to unsigned instead of to the actual type of bcopy()'s third arg, i.e., size_t. Casting to size_t would "fix" (i.e., break) the warning on alphas. The old code has half-baked K&R support. After subtracting the caddr_t's to hopefully get a ptrdiff_t, it casts to unsigned in case there is no prototype for bcopy() in scope, but bcopy() doesn't actually take an unsigned 3rd arg, and its first 2 args are not cast. The new code has many style bugs (line longer than 80, wrong continuation indent, Gnu style for function calls in nearby code). Bruce To Unsubscribe: send mail to majordomo@FreeBSD.org with "unsubscribe cvs-all" in the body of the message