Date: Tue, 2 Feb 1999 16:12:50 +1100 From: Bruce Evans <bde@zeta.org.au> To: mjacob@feral.com, wollman@khavrinen.lcs.mit.edu Cc: cvs-commiters@FreeBSD.ORG Subject: Re: sizeof (ptr) != sizeof (unsigned) Message-ID: <199902020512.QAA17600@godzilla.zeta.org.au>
next in thread | raw e-mail | index | archive | help
>> 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
Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?199902020512.QAA17600>