From feef92f3e2be4043352d30f9e632685d666a4181 Mon Sep 17 00:00:00 2001 From: Vadim Zeitlin Date: Fri, 17 Apr 2015 13:34:36 +0200 Subject: [PATCH] Avoid warnings about not checking read() result in wxJoystick code. Explicitly ignore errors if we can't read from the associated FD. This is mostly done to avoid -Wunused-result warning about not checking read() return value under Ubuntu. This is the backport of a74d2faf3a99d95b2faa4fcf2b590c9e4b8ec562 from master. --- src/unix/joystick.cpp | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/src/unix/joystick.cpp b/src/unix/joystick.cpp index cf9cc33b3e..19b300b445 100644 --- a/src/unix/joystick.cpp +++ b/src/unix/joystick.cpp @@ -129,7 +129,12 @@ void* wxJoystickThread::Entry() if (wxFD_ISSET(m_device, &read_fds)) { memset(&j_evt, 0, sizeof(j_evt)); - read(m_device, &j_evt, sizeof(j_evt)); + if ( read(m_device, &j_evt, sizeof(j_evt)) == -1 ) + { + // We can hardly do anything other than ignoring the error and + // hope that we read the next event successfully. + continue; + } //printf("time: %d\t value: %d\t type: %d\t number: %d\n", // j_evt.time, j_evt.value, j_evt.type, j_evt.number);