mraa_gpio_wait_interrupt needs to check fd before using it
Signed-off-by: Jon Trulson <jtrulson@ics.com>
Signed-off-by: Brendan Le Foll <brendan.le.foll@intel.com>
unsigned char c;
struct pollfd pfd;
+ if (fd <= 0) {
+ return MRAA_ERROR_INVALID_RESOURCE;
+ }
+
// setup poll on POLLPRI
pfd.fd = fd;
pfd.events = POLLPRI;
lseek (fd, 0, SEEK_SET);
read (fd, &c, 1);
- if (fd <= 0) {
- return MRAA_ERROR_INVALID_RESOURCE;
- }
-
// Wait for it forever or until pthread_cancel
// poll is a cancelable point like sleep()
int x = poll (&pfd, 1, -1);