Shameless bump, now when we're out of beta. :-)
On Sat, Sep 16, 2017 at 10:53:47PM +0200, Jesper Wallin wrote:
> Hi all,
>
> I was reading through the code for less/filename.c and noticed that the
> calling for seek_filesize() in filesize() is superfluous? A wild guess
> is that it's remains from when BAD_LSEEK was removed?
>
>
> Jesper Wallin
>
>
> Index: usr.bin/less/filename.c
> ===================================================================
> RCS file: /cvs/src/usr.bin/less/filename.c,v
> retrieving revision 1.25
> diff -u -p -r1.25 filename.c
> --- usr.bin/less/filename.c 17 Sep 2016 15:06:41 -0000 1.25
> +++ usr.bin/less/filename.c 16 Sep 2017 20:28:34 -0000
> @@ -363,20 +363,6 @@ bin_file(int f)
> }
>
> /*
> - * Try to determine the size of a file by seeking to the end.
> - */
> -static off_t
> -seek_filesize(int f)
> -{
> - off_t spos;
> -
> - spos = lseek(f, (off_t)0, SEEK_END);
> - if (spos == (off_t)-1)
> - return (-1);
> - return (spos);
> -}
> -
> -/*
> * Read a string from a file.
> * Return a pointer to the string in memory.
> */
> @@ -751,7 +737,7 @@ filesize(int f)
>
> if (fstat(f, &statbuf) >= 0)
> return (statbuf.st_size);
> - return (seek_filesize(f));
> + return (lseek(f, 0, SEEK_END));
> }
>
> /*