[libdvdnav-devel] Pointless Checking For Errors On Close

Petri Hintukainen phintuka at gmail.com
Thu Sep 17 14:03:50 CEST 2015


On to, 2015-09-17 at 15:00 +1200, Lawrence D'Oliveiro wrote:
> On Fri, 11 Sep 2015 19:50:29 +1200, I wrote:
> 
> > Data loss is _not_ possible on closing an input file.
> 
> See also <http://lwn.net/Articles/576478/>. The conclusion seems quite
> clear: apart from EBADF (indicating a program bug), close(2) should
> never return any errors.

... in linux. And, even if it would return an error, there's nothing we
can do (in linux). It simply can't be called again, that could
potentially close incorrect file if fd has been reused. But there are
other systems where close() can return an error and should be retried.
=> close() returning -1 is a can of worms we don't really want to
open ...

The checks should be removed also because of failed close() causes memory leak
in dvdinput.c. dvdinput_close() is never called again. And it can't be called
again, because of css_close() (and close() in linux) can't be called again.




More information about the libdvdnav-devel mailing list