Skip site navigation (1)Skip section navigation (2)
Date:      Tue, 20 Aug 2002 14:44:09 +0200
From:      Erik Trulsson <ertr1013@student.uu.se>
To:        Andrew Reilly <areilly@bigpond.net.au>
Cc:        Bill Vermillion <bv@wjv.com>, stable@FreeBSD.ORG, ports@FreeBSD.ORG
Subject:   Re: A but in Zoo
Message-ID:  <20020820124408.GA391@falcon.midgard.homeip.net>
In-Reply-To: <1029846175.26839.25.camel@gurney.reilly.home>
References:  <bulk.34340.20020814013822@hub.freebsd.org> <20020814114442.GA77130@wjv.com> <20020814130031.GA58489@falcon.midgard.homeip.net> <1029846175.26839.25.camel@gurney.reilly.home>

next in thread | previous in thread | raw e-mail | index | archive | help
On Tue, Aug 20, 2002 at 10:22:55PM +1000, Andrew Reilly wrote:
> On Wed, 2002-08-14 at 23:00, Erik Trulsson wrote:
> > A quick investigation indicates that this is a bug in zoo.  
> > It presumably was not exposed on earlier versions of FreeBSD.
> > To be more precise the function zootrunc() which can be found at the
> > end of the file bsd.c contains a line
> > 
> >         seekpos = lseek(fd, 0L, SEEK_CUR);
> > 
> > This should be changed to
> > 
> >         seekpos = lseek(fd, (off_t) 0L, SEEK_CUR);
> 
> Rather than changing the source like this, wouldn't it be much better,
> more portable and above all neater just to make sure that the prototype
> for lseek() was in scope at that point, so that the 0L could be promoted
> automatically and correctly by the compiler?  (I.e., #include <unistd.h>
> somewhere above.)

There is actually a #include <unistd.h> a couple of lines earlier.
See below why this doesn't help here.


> 
> In fact, with the prototype in scope, I'd be tempted to change the 2nd
> arg from 0L to just 0, and be done with it.

Why bother?

> 
> Hmm.  Looking at the header files just now, it seems that the
> declaration of lseek is conditional on a symbol _LSEEK_DECLARED, which
> is defined in both unistd.h and stdio.h (where it is, in turn,
> conditional on _ANSI_SOURCE and _POSIX_SOURCE).



The real problem is that a few lines above the call to lseek() that is
mentioned above the program attempts to declare lseek() itself as
off_t lseek();
This apparently overrides the prototype from <unistd.h> and thus
prevents any automatic promotion to happen.
The "correct" fix is thus simply to remove the declaration of lseek().
(Either this fix or my original fix of changing the call to lseek()
will work equally well.)
Here is a patch to the port to do this:



Index: files/patch-aa
===================================================================
RCS file: /ncvs/ports/archivers/zoo/files/patch-aa,v
retrieving revision 1.4
diff -u -r1.4 patch-aa
--- files/patch-aa	24 Apr 1997 02:12:23 -0000	1.4
+++ files/patch-aa	20 Aug 2002 12:35:54 -0000
@@ -65,7 +65,7 @@
   /* Truncate a file. */
   int zootrunc(f) FILE *f;
   {
-! 	extern off_t lseek();
+!
 ! 	off_t seekpos;
   	int fd = fileno(f);
   	seekpos = lseek(fd, 0L, SEEK_CUR);






-- 
<Insert your favourite quote here.>
Erik Trulsson
ertr1013@student.uu.se

To Unsubscribe: send mail to majordomo@FreeBSD.org
with "unsubscribe freebsd-ports" in the body of the message




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