Skip to content

Commit

Permalink
Check return value from all ioctl use and print a complete error.
Browse files Browse the repository at this point in the history
Coverity 700232-700234
  • Loading branch information
stuartm committed Dec 18, 2012
1 parent d7ac0a9 commit a56e288
Showing 1 changed file with 18 additions and 7 deletions.
25 changes: 18 additions & 7 deletions mythtv/libs/libmythbase/mythcdrom-linux.cpp
Expand Up @@ -203,7 +203,7 @@ bool MythCDROMLinux::hasWritableMedia()
if (ioctl(m_DeviceHandle, CDROM_SEND_PACKET, &cgc) < 0)
{
LOG(VB_MEDIA, LOG_ERR, LOC +
":hasWritableMedia() - failed to send packet to " + m_DevicePath);
":hasWritableMedia() - failed to send packet to " + m_DevicePath + ENO);
return false;
}

Expand Down Expand Up @@ -262,7 +262,7 @@ int MythCDROMLinux::SCSIstatus()
|| (es->notification_class != 0x4)) // notification class mismatch
{
LOG(VB_MEDIA, LOG_ERR, LOC +
":SCSIstatus() - failed to send SCSI packet to " + m_DevicePath);
":SCSIstatus() - failed to send SCSI packet to " + m_DevicePath + ENO);
return CDS_TRAY_OPEN;
}

Expand Down Expand Up @@ -300,7 +300,10 @@ MythMediaError MythCDROMLinux::eject(bool open_close)
else
{
// If the tray is empty, this will fail (Input/Output error)
ioctl(m_DeviceHandle, CDROMCLOSETRAY);
int res = ioctl(m_DeviceHandle, CDROMCLOSETRAY);

if (res < 0)
LOG(VB_MEDIA, LOG_DEBUG, "CDROMCLOSETRAY ioctl failed" + ENO);

// This allows us to catch any drives that the OS has problems
// detecting the status of (some always report OPEN when empty)
Expand Down Expand Up @@ -616,7 +619,12 @@ MythMediaError MythCDROMLinux::lock()
{
MythMediaError ret = MythMediaDevice::lock();
if (ret == MEDIAERR_OK)
ioctl(m_DeviceHandle, CDROM_LOCKDOOR, 1);
{
int res = ioctl(m_DeviceHandle, CDROM_LOCKDOOR, 1);

if (res < 0)
LOG(VB_MEDIA, LOG_WARNING, "lock() - CDROM_LOCKDOOR ioctl failed" + ENO);
}

return ret;
}
Expand All @@ -626,7 +634,10 @@ MythMediaError MythCDROMLinux::unlock()
if (isDeviceOpen() || openDevice())
{
LOG(VB_MEDIA, LOG_DEBUG, LOC + ":unlock - Unlocking CDROM door");
ioctl(m_DeviceHandle, CDROM_LOCKDOOR, 0);
int res = ioctl(m_DeviceHandle, CDROM_LOCKDOOR, 0);

if (res < 0)
LOG(VB_MEDIA, LOG_WARNING, "unlock() - CDROM_LOCKDOOR ioctl failed" + ENO);
}
else
{
Expand Down Expand Up @@ -763,7 +774,7 @@ void MythCDROMLinux::setDeviceSpeed(const char *device, int speed)

if (ioctl(fd, SG_IO, &sghdr) < 0)
{
LOG(VB_MEDIA, LOG_ERR, LOC + " Limit CD/DVD Speed Failed");
LOG(VB_MEDIA, LOG_ERR, LOC + " Limit CD/DVD Speed Failed" + ENO);
}
else
{
Expand All @@ -772,7 +783,7 @@ void MythCDROMLinux::setDeviceSpeed(const char *device, int speed)
if (ioctl(fd, CDROM_SELECT_SPEED, speed) < 0)
{
LOG(VB_MEDIA, LOG_ERR, LOC +
" Limit CD/DVD CDROM_SELECT_SPEED Failed");
" Limit CD/DVD CDROM_SELECT_SPEED Failed" + ENO);
}
LOG(VB_MEDIA, LOG_INFO, LOC +
":setDeviceSpeed() - CD/DVD Speed Set Successful");
Expand Down

0 comments on commit a56e288

Please sign in to comment.