Commit 9178d095 authored by Rémi Denis-Courmont's avatar 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)
parent c9c04bd3
...@@ -543,7 +543,8 @@ float dvb_get_signal_strength (dvb_device_t *d) ...@@ -543,7 +543,8 @@ float dvb_get_signal_strength (dvb_device_t *d)
{ {
uint16_t strength; 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 0.;
return strength / 65535.; return strength / 65535.;
} }
...@@ -552,7 +553,7 @@ float dvb_get_snr (dvb_device_t *d) ...@@ -552,7 +553,7 @@ float dvb_get_snr (dvb_device_t *d)
{ {
uint16_t snr; 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 0.;
return snr / 65535.; return snr / 65535.;
} }
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment