home *** CD-ROM | disk | FTP | other *** search
/ NetNews Usenet Archive 1992 #20 / NN_1992_20.iso / spool / comp / unix / wizards / 3819 < prev    next >
Encoding:
Internet Message Format  |  1992-09-08  |  1.5 KB

  1. Path: sparky!uunet!decwrl!bu.edu!Shiva.COM!world!bzs
  2. From: bzs@ussr.std.com (Barry Shein)
  3. Newsgroups: comp.unix.wizards
  4. Subject: Re: A few UNIX questions
  5. Message-ID: <BZS.92Sep7015040@ussr.std.com>
  6. Date: 7 Sep 92 06:50:40 GMT
  7. References: <32176@adm.brl.mil>
  8. Sender: usenet@world.std.com (Mr USENET himself)
  9. Organization: The World
  10. Lines: 29
  11. In-Reply-To: mike@BRL.MIL's message of 24 Aug 92 19:27:42 GMT
  12. Nntp-Posting-Host: ussr.std.com
  13.  
  14.  
  15. >> Can *anyone* tell me why the file size is a signed integer.  Surely there
  16. >> is no need for negative sized files!!
  17. >
  18. >Because lseek() needs to be able to return -1 on error, and not have it
  19. >look like a valid file offset.
  20.  
  21. That assumes that you need to test (lseek() < 0), one probably should
  22. test (lseek() == -1) which steals only one value from the entire
  23. address space. Granted that has to be casted if it were unsigned to
  24. something more like (lseek() == ((unsigned long)-1)) but no great
  25. problem.
  26.  
  27. This situation already exists with the brk() system call and shmget()
  28. (probably others) which can both return the same bit patterns as
  29. appear to be negative values on most machines Unix runs on, but
  30. exactly -1 on return is magic.
  31.  
  32. If there's any concern one can of course set errno = 0 and then check
  33. it after the call so still, with some care, distinguish the peculiar
  34. legal -1 case (as these are all system calls.)
  35.  
  36. Sort of a botch, but there ya have it.
  37.  
  38. --
  39.         -Barry Shein
  40.  
  41. Software Tool & Die    | bzs@world.std.com          | uunet!world!bzs
  42. Purveyors to the Trade | Voice: 617-739-0202        | Login: 617-739-WRLD
  43.