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

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


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

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

This should fail safe, but it is still ugly.
(cherry picked from commit b517ac74d7a2d7b8c104ec3f3ee1f6d56f78581d)

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

 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 18f59f2..5afdc15 100644
--- a/modules/access/dtv/linux.c
+++ b/modules/access/dtv/linux.c
@@ -543,7 +543,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.;
 }
@@ -552,7 +553,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