From a74d2faf3a99d95b2faa4fcf2b590c9e4b8ec562 Mon Sep 17 00:00:00 2001 From: Vadim Zeitlin Date: Thu, 12 Feb 2015 21:56:36 +0000 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. git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@78481 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775 --- 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 77847dd985..28635e402f 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);