[DVDnav-discuss] [PATCH] Only -1 as open() return value indicates error

Reimar Döffinger Reimar.Doeffinger at gmx.de
Tue Nov 6 19:21:27 CET 2012


Hello,
mostly purely theoretical, but we might get 0 as fd from open.
I used the exact -1 check, because e.g. WinCE will also use other
negative value as file descriptors (it basically just uses memory
pointers cast to int as far as I know) and I don't see a good reason
to check for >= 0 instead.

Index: vm/vm.c
===================================================================
--- vm/vm.c	(revision 1243)
+++ vm/vm.c	(working copy)
@@ -172,7 +172,7 @@
 
     /* Read DVD name */
     fd = open(device, O_RDONLY);
-    if (fd > 0) {
+    if (fd != -1) {
       off = lseek( fd, 32 * (off_t) DVD_VIDEO_LB_LEN, SEEK_SET );
       if( off == ( 32 * (off_t) DVD_VIDEO_LB_LEN ) ) {
         off = read( fd, data, DVD_VIDEO_LB_LEN );



More information about the DVDnav-discuss mailing list