]> git.ipfire.org Git - thirdparty/util-linux.git/commitdiff
eject: return proper 0/1 from eject_cdrom()
authorDave Reisner <dreisner@archlinux.org>
Mon, 6 Aug 2012 15:16:12 +0000 (11:16 -0400)
committerKarel Zak <kzak@redhat.com>
Mon, 13 Aug 2012 13:45:47 +0000 (15:45 +0200)
main() expects this method to return 0 for failure and 1 for success, as
the other eject_*() methods do. Add the missing comparison of ioctl() >= 0

Signed-off-by: Dave Reisner <dreisner@archlinux.org>
Signed-off-by: Karel Zak <kzak@redhat.com>
sys-utils/eject.c

index 08af08e0c5d7fd66b5c6b17e21f7add7e27e2883..2097961ef2c859fda6bd78d188a296e83bb3253c 100644 (file)
@@ -398,13 +398,13 @@ static void close_tray(int fd)
 static int eject_cdrom(int fd)
 {
 #if defined(CDROMEJECT)
-       return ioctl(fd, CDROMEJECT);
+       return ioctl(fd, CDROMEJECT) >= 0;
 #elif defined(CDIOCEJECT)
-       return ioctl(fd, CDIOCEJECT);
+       return ioctl(fd, CDIOCEJECT) >= 0;
 #else
        warnx(_("CD-ROM eject unsupported"));
        errno = ENOSYS;
-       return -1;
+       return 0;
 #endif
 }
 
@@ -432,7 +432,7 @@ static void toggle_tray(int fd)
 
        case CDS_NO_DISC:
        case CDS_DISC_OK:
-               if (eject_cdrom(fd))
+               if (!eject_cdrom(fd))
                        err(EXIT_FAILURE, _("CD-ROM eject command failed"));
                return;
        case CDS_NO_INFO:
@@ -453,7 +453,7 @@ static void toggle_tray(int fd)
        gettimeofday(&time_start, NULL);
 
        /* Send the CDROMEJECT command to the device. */
-       if (eject_cdrom(fd) < 0)
+       if (!eject_cdrom(fd))
                err(EXIT_FAILURE, _("CD-ROM eject command failed"));
 
        /* Get the second timestamp, to measure the time needed to open