home *** CD-ROM | disk | FTP | other *** search
/ NetNews Usenet Archive 1992 #20 / NN_1992_20.iso / spool / comp / unix / wizards / 3841 < prev    next >
Encoding:
Text File  |  1992-09-08  |  2.0 KB  |  56 lines

  1. Newsgroups: comp.unix.wizards
  2. Path: sparky!uunet!mcsun!Germany.EU.net!murignis!ap542!D012S436!frank
  3. From: frank@D012S436.sniap.mchp.sni.de ()
  4. Subject: Re: A few UNIX questions
  5. Message-ID: <1992Sep8.164706.9819@sniap.mchp.sni.de>
  6. Sender: news@sniap.mchp.sni.de (News Admin)
  7. Organization: Siemens-Nixdorf AG
  8. References: <169@sc.sni.ie>
  9. Date: Tue, 8 Sep 92 16:47:06 GMT
  10. Lines: 44
  11.  
  12. bsullivn@sc.sni.ie (Bryan O'Sullivan) writes:
  13. : frank@D012S436.sniap.mchp.sni.de writes:
  14. : ::Because lseek() needs to be able to return -1 on error, and not have it
  15. : ::look like a valid file offset.
  16. : :Umm, and a *signed* file size helps, does it?
  17. : RTFM.  Lseek(2) returns the current position in the file, or -1 on
  18. : error.  If you can think of any way to produce -1 by using unsigned
  19. : values, well ...
  20.  
  21. UYFH (Use Your F****** Head :-)
  22.  
  23. Hint: The manual describes things as they are, not as they have to be.
  24.  
  25. Firstly, There are other ways to signal the error:
  26.  
  27. 1: (unsigned long) -1   works fine, and you only lose one value, instead of
  28. half the value space.
  29.  
  30. 2: If casting upsets you, you can define an ERROR constant as being
  31. the maximum unsigned, for example, and have the same thing going 
  32. for you.
  33.  
  34. 3: 'errno' can be used to signal the error.
  35.  
  36. Secondly, even if there were no other way to signal the error,
  37. there is no need to considere the file offset stored *on the
  38. disk* as being signed - it's not - a file's size is never negative.
  39.  
  40. :     -- Bryan
  41. : -- 
  42. : Bryan O'Sullivan                                             +353-1-767551 x225
  43. : Siemens-Nixdorf Informationssysteme AG                          bryan@sc.sni.ie
  44. : Software Development Centre                    "Theory like mist on eyeglasses.
  45. : Dublin                                          Obscure facts." -- Charlie Chan
  46. --
  47. Frank O'Dwyer                           Disclaimer: 
  48. Siemens-Nixdorf AG                             I will deny everything
  49. Tel.  : +49 (89) 636-40639                      Fax.  : +49 (89) 636-45860
  50. e-mail: Frank.ODwyer@sniap.mchp.sni.de <--Use this, reply-to is broken
  51.