Skip site navigation (1)Skip section navigation (2)
Date:      Wed, 12 Mar 1997 21:10:02 -0800 (PST)
From:      Stephen McKay <syssgm@devetir.qld.gov.au>
To:        freebsd-bugs
Subject:   Re: kern/2966: ftruncate() problem in FreeBSD 2.1.7-RELEASE i386
Message-ID:  <199703130510.VAA05202@freefall.freebsd.org>

next in thread | raw e-mail | index | archive | help
The following reply was made to PR kern/2966; it has been noted by GNATS.

From: Stephen McKay <syssgm@devetir.qld.gov.au>
To: j@uriah.heep.sax.de (J Wunsch)
Cc: freebsd-gnats-submit@freebsd.org, syssgm@devetir.qld.gov.au
Subject: Re: kern/2966: ftruncate() problem in FreeBSD 2.1.7-RELEASE i386
Date: Thu, 13 Mar 1997 14:56:45 +1000 (EST)

 j@uriah.heep.sax.de (J Wunsch) wrote:
 
 > [Rick Ace misuses ftruncate()]
 >
 > Rule #1: Thou shalt declare all your functions.
 > 
 > ftruncate() takes an argument of type off_t.  If you fail to declare
 > this function (and fail to cast the argument), you get what you
 > deserve.
 > 
 > #include <unistd.h>
 
 Is it time to special-case truncate() and ftruncate() in <sys/types.h>
 like lseek()?  Ugly or not, it should reduce surprises.  These 3 should
 be the only special ones.  mmap() uses off_t, but you can't get by without
 <sys/mman.h>, and that declares mmap() correctly.
 
 An other option is to include clever macro stuff in <sys/types.h> so that
 use of lseek, truncate, and ftruncate is impossible unless <unistd.h> is
 also included.  Actually, I'm just being silly here :-) though it can be
 done this way:
 
 In <sys/types.h>
 
     #ifndef _UNISTD_H_
     #define truncate read_thine_C_book_novice
     #endif
 
 In <unistd.h>
 
     #undef truncate
     int truncate __P((const char *, off_t));
 
 :-) :-)
 
 Stephen.



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