[haiku-bugs] Re: [Haiku] #10367: Fix Coverity CID 1032247 and 1032248: unchecked return value

  • From: "noryb009" <trac@xxxxxxxxxxxx>
  • Date: Sun, 10 Aug 2014 01:46:18 -0000

#10367: Fix Coverity CID 1032247 and 1032248: unchecked return value
--------------------------------+------------------------------
   Reporter:  noryb009          |      Owner:  axeld
       Type:  bug               |     Status:  new
   Priority:  normal            |  Milestone:  R1/alpha5
  Component:  Kits/Storage Kit  |    Version:  R1/Development
 Resolution:                    |   Keywords:  gci2013 coverity
 Blocked By:                    |   Blocking:
Has a Patch:  1                 |   Platform:  All
--------------------------------+------------------------------

Comment (by noryb009):

 Personally, I think an error code is more important than whatever is read
 - it would be a silent error, and can cause a confusing crash ("This read
 fails. Wait, the position is at the end of the file. How did it get there?
 Looks like ReadAt isn't emitting an error." - a possible future
 programmer, spending a long night fixing a bug).

 From the be book (BPositionIO page):
   It should return the number of bytes actually read, or an error code if
 something goes wrong.
 So if something goes wrong (the seek back), the error number should be
 returned. However, the be book (and the API documentation) doesn't state
 that this functionality exists (that the position will be returned to the
 original location).

 If the seek back isn't guaranteed, then it shouldn't happen at all
 (faster, one less seek, programmers can do it themselves if needed).
 Alternatively, it should be guaranteed and defined (doesn't break the
 current API).

 Until we are sure we want to either define it or remove it, we should
 return an error if it fails to avoid the scenario above.

--
Ticket URL: <https://dev.haiku-os.org/ticket/10367#comment:6>
Haiku <https://dev.haiku-os.org>
Haiku - the operating system.

Other related posts: