[vlc-commits] Linux DVB: do not run ioctl() on fd == -1

Rémi Denis-Courmont git at videolan.org
Tue Mar 13 17:18:42 CET 2012


vlc | branch: master | Rémi Denis-Courmont <remi at remlab.net> | Tue Mar 13 18:14:57 2012 +0200| [b517ac74d7a2d7b8c104ec3f3ee1f6d56f78581d] | committer: Rémi Denis-Courmont

Linux DVB: do not run ioctl() on fd == -1

This should fail safe, but it is still ugly.

> http://git.videolan.org/gitweb.cgi/vlc.git/?a=commit;h=b517ac74d7a2d7b8c104ec3f3ee1f6d56f78581d
---

 modules/access/dtv/linux.c |    5 +++--
 1 files changed, 3 insertions(+), 2 deletions(-)

diff --git a/modules/access/dtv/linux.c b/modules/access/dtv/linux.c
index b4615f9..b7ad3e1 100644
--- a/modules/access/dtv/linux.c
+++ b/modules/access/dtv/linux.c
@@ -632,7 +632,8 @@ float dvb_get_signal_strength (dvb_device_t *d)
 {
     uint16_t strength;
 
-    if (ioctl (d->frontend, FE_READ_SIGNAL_STRENGTH, &strength) < 0)
+    if (d->frontend == -1
+     || ioctl (d->frontend, FE_READ_SIGNAL_STRENGTH, &strength) < 0)
         return 0.;
     return strength / 65535.;
 }
@@ -641,7 +642,7 @@ float dvb_get_snr (dvb_device_t *d)
 {
     uint16_t snr;
 
-    if (ioctl (d->frontend, FE_READ_SNR, &snr) < 0)
+    if (d->frontend == -1 || ioctl (d->frontend, FE_READ_SNR, &snr) < 0)
         return 0.;
     return snr / 65535.;
 }



More information about the vlc-commits mailing list