[net.bugs.4bsd] Q: lseek returns long or int?

donn@utah-cs.UUCP (Donn Seeley) (09/23/84)

	From henry@utzoo.UUCP (Henry Spencer):

	This is yet another piece of gratuitous brain-damage brought to
	you by the morons at Berkeley. ...

This is yet another gratuitous insult from someone who should have
better things to do.  I have no illusions that a lecture on the joys of
being constructive would be other than wasted breath (or keystrokes),
so I will merely point out that if there weren't any constructive
people, we wouldn't have Unix at all.

It IS a bit ironic that this latest flap involves typing, since the
Berkeley kernel is fairly obsessive in using typedefs to make types
system-independent.  For instance, the lseek() call has its own
typedef, 'off_t', for representing the type of a file offset; this is
surely a greater nod to portability than merely stamping the value as
'long'.  At any rate the manual page chooses not to use this typedef,
which is probably a mistake.  It is easily corrected if one spends a
minute or two looking at the situation (in man2/lseek.2):

------------------------------------------------------------------------
*** /tmp/,RCSt1023012	Sun Sep 23 05:17:09 1984
--- lseek.2	Sun Sep 23 04:56:28 1984
***************
*** 5,11
  .SH SYNOPSIS
  .nf
  .ft B
! .ta 1.25i 1.6i
  #define L_SET	0	/* set the seek pointer */
  #define L_INCR	1	/* increment the seek pointer */
  #define L_XTND	2	/* extend the file size */

--- 5,16 -----
  .SH SYNOPSIS
  .nf
  .ft B
! #include <sys/types.h>
! #include <sys/file.h>
! .PP
! .nf
! .ft B
! .ta 1.25i 1.6i 1.8i
  #define L_SET	0	/* set the seek pointer */
  #define L_INCR	1	/* increment the seek pointer */
  #define L_XTND	2	/* extend the file size */
***************
*** 12,19
  .PP
  .ft B
  pos = lseek(d, offset, whence)
! int pos;
! int d, offset, whence;
  .fi
  .ft R
  .SH DESCRIPTION

--- 17,26 -----
  .PP
  .ft B
  pos = lseek(d, offset, whence)
! off_t pos;
! int d;
! off_t offset;
! int whence;
  .fi
  .ft R
  .SH DESCRIPTION
------------------------------------------------------------------------

Despite this trivial problem, lseek.2 and the 4.2 manual entries in
general are definitely a vast improvement over the earlier Berkeley
versions, which usually failed to enumerate the errors which a call
could return and sometimes even omitted the return values.  Many things
which used to be magic cookies in previous versions of the system, such
as lseek()'s 'whence', are now clearly parameterized (perhaps
influenced by USG Unixes).  Efforts at improvement such as this should
be commended, not sneered at.

Waiting for a return to civility (but not holding my breath),

Donn Seeley    University of Utah CS Dept    donn@utah-cs.arpa
40 46' 6"N 111 50' 34"W    (801) 581-5668    decvax!utah-cs!donn

henry@utzoo.UUCP (Henry Spencer) (09/26/84)

> 	This is yet another piece of gratuitous brain-damage brought to
> 	you by the morons at Berkeley. ...
> 
> This is yet another gratuitous insult from someone who should have
> better things to do.

I do have better things to do, but sometimes I run across a Berkeley
atrocity that angers me beyond bearing.  I realize that speaking out
about it is largely a waste of time, since most Berkeleyphiles are
unreceptive to the suggestion that their beloved x.yBSD could possibly
have flaws, but I keep trying...

> I have no illusions that a lecture on the joys of
> being constructive would be other than wasted breath (or keystrokes),
> so I will merely point out that if there weren't any constructive
> people, we wouldn't have Unix at all.

Most true.  Berkeley (and USG) should try harder to be constructive.
So far their batting average, while not zero, is lower than it should be.

> It IS a bit ironic that this latest flap involves typing, since the
> Berkeley kernel is fairly obsessive in using typedefs to make types
> system-independent.  For instance, the lseek() call has its own
> typedef, 'off_t', for representing the type of a file offset; this is
> surely a greater nod to portability than merely stamping the value as
> 'long'.

Actually, my original note should have said "off_t"; point taken.  This
is not something Berkeley should be given any credit for, by the way,
since "off_t" and its relatives came from Bell Labs.  Berkeley should
be making more use of them than they do; the Berkeley people themselves
have been heard to say, in about so many words, "if your ints aren't 32
bits, forget about running 4.2BSD networking".

> At any rate the manual page chooses not to use this typedef,
> which is probably a mistake.  It is easily corrected...

No "probably" about it, alas.  Furthermore, the original Unix manual
page at least said "long", which is closer to being right than "int".
The change from the semi-portable "long" to the grossly-unportable "int"
is another case of an attitude that others have characterized as "all
the world's a VAX".

> Despite this trivial problem, lseek.2 and the 4.2 manual entries in
> general are definitely a vast improvement over the earlier Berkeley
> versions...

Berkeley is to be commended for adopting the more-detailed presentation
of return values and error conditions, although they didn't invent it.
(Just to be equitable about insulting everyone, I should add that this is
one of the very few USG inventions that is genuinely good and useful.)

> Efforts at improvement such as this should
> be commended, not sneered at.

Note the commendation in the previous paragraph.  The change of lseek's
return value to "int" is still sneer-worthy, regardless.

See also the more recent article from me which contains a semi-apology
for the harsh wording of the original note.
-- 
				Henry Spencer @ U of Toronto Zoology
				{allegra,ihnp4,linus,decvax}!utzoo!henry