Skip site navigation (1)Skip section navigation (2)
Date:      Mon, 11 Mar 1996 13:04:20 +0100 (MET)
From:      Wolfram Schneider <wosch@cs.tu-berlin.de>
To:        Bruce Evans <bde@zeta.org.au>
Cc:        current@FreeBSD.org
Subject:   Re: *.mk wishes
Message-ID:  <199603111204.NAA23816@caramba.cs.tu-berlin.de>
In-Reply-To: <199603102124.IAA15692@godzilla.zeta.org.au>
References:  <199603102124.IAA15692@godzilla.zeta.org.au>

next in thread | previous in thread | raw e-mail | index | archive | help
Bruce Evans writes:
>newfs/mkfs.c passes an uncast 0 for a pointer and an uncast 0 for an off_t.
>rpc.statd passes an uncast NULL for a pointer and an uncast 0 for an off_t.
>I would't worry about fixing this.  There must be a prototype in scope for
>the uncast 0 for an off_t to work, and it isn't a bug to omit the casts iff
>there is a prototype in scope.  Just fix the configuration.  Do we have a
>working mmap? :-)

http://www.lysator.liu.se/c/ten-commandments.html

3 Thou shalt cast all function arguments to the expected type if they
are not of that type already, even when thou art convinced that this
is unnecessary, lest they take cruel vengeance upon thee when thou
least expect it.

      A programmer should understand the type structure of his
language, lest great misfortune befall him. Contrary to the heresies
espoused by some of the dwellers on the Western Shore, `int' and
`long' are not the same type.  The moment of their equivalence in size
and representation is short, and the agony that awaits believers in
their interchangeability shall last forever and ever once 64-bit
machines become common.

Also, contrary to the beliefs common among the more backward
inhabitants of the Polluted Eastern Marshes, `NULL' does not have a
pointer type, and must be cast to the correct type whenever it is used
as a function argument.

(The words of the prophet Ansi, which permit NULL to be defined as
having the type `void *', are oft taken out of context and
misunderstood.  The prophet was granting a special dispensation for
use in cases of great hardship in wild lands.  Verily, a righteous
program must make its own way through the Thicket Of Types without
lazily relying on this rarely-available dispensation to solve all its
problems.  In any event, the great deity Dmr who created C hath wisely
endowed it with many types of pointers, not just one, and thus it
would still be necessary to convert the prophet's NULL to the desired
type.)

It may be thought that the radical new blessing of ``prototypes''
might eliminate the need for caution about argument types.  Not so,
brethren.  Firstly, when confronted with the twisted strangeness of
variable numbers of arguments, the problem returns... and he who has
not kept his faith strong by repeated practice shall surely fall to
this subtle trap.  Secondly, the wise men have observed that reliance
on prototypes doth open many doors to strange errors, and some indeed
had hoped that prototypes would be decreed for purposes of error
checking but would not cause implicit conversions.  Lastly, reliance
on prototypes causeth great difficulty in the Real World today, when
many cling to the old ways and the old compilers out of desire or
necessity, and no man knoweth what machine his code may be asked to
run on tomorrow.




Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?199603111204.NAA23816>