summaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
Diffstat (limited to 'src')
-rw-r--r--src/plugins/generic/evdevkeyboard/qevdevkeyboardhandler.cpp18
-rw-r--r--src/plugins/generic/evdevmouse/qevdevmousehandler.cpp18
-rw-r--r--src/plugins/generic/evdevtouch/qevdevtouch.cpp34
3 files changed, 41 insertions, 29 deletions
diff --git a/src/plugins/generic/evdevkeyboard/qevdevkeyboardhandler.cpp b/src/plugins/generic/evdevkeyboard/qevdevkeyboardhandler.cpp
index 73aa6419d3..eb29b853e7 100644
--- a/src/plugins/generic/evdevkeyboard/qevdevkeyboardhandler.cpp
+++ b/src/plugins/generic/evdevkeyboard/qevdevkeyboardhandler.cpp
@@ -168,16 +168,20 @@ void QEvdevKeyboardHandler::readKeycode()
int n = 0;
forever {
- n = qt_safe_read(m_fd, reinterpret_cast<char *>(buffer) + n, sizeof(buffer) - n);
+ int result = qt_safe_read(m_fd, reinterpret_cast<char *>(buffer) + n, sizeof(buffer) - n);
- if (n == 0) {
+ if (result == 0) {
qWarning("Got EOF from the input device.");
return;
- } else if (n < 0 && (errno != EINTR && errno != EAGAIN)) {
- qWarning("Could not read from input device: %s", strerror(errno));
- return;
- } else if (n % sizeof(buffer[0]) == 0) {
- break;
+ } else if (result < 0) {
+ if (errno != EINTR && errno != EAGAIN) {
+ qWarning("Could not read from input device: %s", strerror(errno));
+ return;
+ }
+ } else {
+ n += result;
+ if (n % sizeof(buffer[0]) == 0)
+ break;
}
}
diff --git a/src/plugins/generic/evdevmouse/qevdevmousehandler.cpp b/src/plugins/generic/evdevmouse/qevdevmousehandler.cpp
index 7c05e9ff11..5e2911a806 100644
--- a/src/plugins/generic/evdevmouse/qevdevmousehandler.cpp
+++ b/src/plugins/generic/evdevmouse/qevdevmousehandler.cpp
@@ -145,16 +145,20 @@ void QEvdevMouseHandler::readMouseData()
bool pendingMouseEvent = false;
int eventCompressCount = 0;
forever {
- n = QT_READ(m_fd, reinterpret_cast<char *>(buffer) + n, sizeof(buffer) - n);
+ int result = QT_READ(m_fd, reinterpret_cast<char *>(buffer) + n, sizeof(buffer) - n);
- if (n == 0) {
+ if (result == 0) {
qWarning("Got EOF from the input device.");
return;
- } else if (n < 0 && (errno != EINTR && errno != EAGAIN)) {
- qWarning("Could not read from input device: %s", strerror(errno));
- return;
- } else if (n % sizeof(buffer[0]) == 0) {
- break;
+ } else if (result < 0) {
+ if (errno != EINTR && errno != EAGAIN) {
+ qWarning("Could not read from input device: %s", strerror(errno));
+ return;
+ }
+ } else {
+ n += result;
+ if (n % sizeof(buffer[0]) == 0)
+ break;
}
}
diff --git a/src/plugins/generic/evdevtouch/qevdevtouch.cpp b/src/plugins/generic/evdevtouch/qevdevtouch.cpp
index c9c49839d6..1c3e8952e9 100644
--- a/src/plugins/generic/evdevtouch/qevdevtouch.cpp
+++ b/src/plugins/generic/evdevtouch/qevdevtouch.cpp
@@ -253,26 +253,30 @@ void QTouchScreenHandler::readData()
int n = 0;
for (; ;) {
#ifdef USE_MTDEV
- n = mtdev_get(m_mtdev, m_fd, buffer, sizeof(buffer) / sizeof(::input_event));
- if (n > 0)
- n *= sizeof(::input_event);
+ int result = mtdev_get(m_mtdev, m_fd, buffer, sizeof(buffer) / sizeof(::input_event));
+ if (result > 0)
+ result *= sizeof(::input_event);
#else
- n = QT_READ(m_fd, reinterpret_cast<char*>(buffer) + n, sizeof(buffer) - n);
+ int result = QT_READ(m_fd, reinterpret_cast<char*>(buffer) + n, sizeof(buffer) - n);
#endif
- if (!n) {
+ if (!result) {
qWarning("Got EOF from input device");
return;
- } else if (n < 0 && (errno != EINTR && errno != EAGAIN)) {
- qWarning("Could not read from input device: %s", strerror(errno));
- if (errno == ENODEV) { // device got disconnected -> stop reading
- delete m_notify;
- m_notify = 0;
- QT_CLOSE(m_fd);
- m_fd = -1;
+ } else if (result < 0) {
+ if (errno != EINTR && errno != EAGAIN) {
+ qWarning("Could not read from input device: %s", strerror(errno));
+ if (errno == ENODEV) { // device got disconnected -> stop reading
+ delete m_notify;
+ m_notify = 0;
+ QT_CLOSE(m_fd);
+ m_fd = -1;
+ }
+ return;
}
- return;
- } else if (n % sizeof(::input_event) == 0) {
- break;
+ } else {
+ n += result;
+ if (n % sizeof(::input_event) == 0)
+ break;
}
}