summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorPeter Wu <lekensteyn@gmail.com>2013-09-02 10:57:03 +0200
committerMartin Pitt <martinpitt@gnome.org>2013-09-03 08:31:28 +0200
commit8113cab7ffe185f9efd841c8f8749b2f05df50e3 (patch)
treef11518dac0d436715b05c1492588c6d0e59e4110
parent16544c135590d8c653cb83eec3f8e4395687a4d8 (diff)
hidpp: drop read_msg, print correct buffer
Since "hidpp: split request read/write functions", the request buffer is not used anymore while reading the response. Therefore the additional buffer read_msg that was used for preserving the request buffer can be discarded. This patch also fixes printing the wrong response buffer (response would always yield zeroes until the functions exits). Reported-by: Martin Pitt <martin.pitt@ubuntu.com> Signed-off-by: Peter Wu <lekensteyn@gmail.com>
-rw-r--r--src/linux/hidpp-device.c21
1 files changed, 9 insertions, 12 deletions
diff --git a/src/linux/hidpp-device.c b/src/linux/hidpp-device.c
index 899b0f3..f517b8d 100644
--- a/src/linux/hidpp-device.c
+++ b/src/linux/hidpp-device.c
@@ -389,7 +389,6 @@ hidpp_device_read_resp (HidppDevice *device,
.events = G_IO_IN | G_IO_OUT | G_IO_ERR,
},
};
- HidppMessage read_msg = { 0 };
guint64 begin_time;
gint remaining_time;
guchar error_code;
@@ -424,7 +423,7 @@ hidpp_device_read_resp (HidppDevice *device,
goto out;
}
- r = read (priv->fd, &read_msg, sizeof (*response));
+ r = read (priv->fd, response, sizeof (*response));
if (r <= 0) {
if (r == -1 && errno == EINTR)
continue;
@@ -439,27 +438,27 @@ hidpp_device_read_resp (HidppDevice *device,
hidpp_device_print_buffer (device, response);
/* validate response */
- if (read_msg.type != HIDPP_MSG_TYPE_SHORT &&
- read_msg.type != HIDPP_MSG_TYPE_LONG) {
+ if (response->type != HIDPP_MSG_TYPE_SHORT &&
+ response->type != HIDPP_MSG_TYPE_LONG) {
/* ignore key presses, mouse motions, etc. */
continue;
}
/* not our device */
- if (read_msg.device_idx != device_index) {
+ if (response->device_idx != device_index) {
continue;
}
/* yep, this is our request */
- if (read_msg.feature_idx == feature_index &&
- read_msg.function_idx == function_index) {
+ if (response->feature_idx == feature_index &&
+ response->function_idx == function_index) {
break;
}
/* recognize HID++ 1.0 errors */
- if (hidpp_is_error(&read_msg, &error_code) &&
- read_msg.function_idx == feature_index &&
- read_msg.s.params[0] == function_index) {
+ if (hidpp_is_error(response, &error_code) &&
+ response->function_idx == feature_index &&
+ response->s.params[0] == function_index) {
g_set_error (error, 1, 0,
"Unable to satisfy request, HID++ error %02x", error_code);
ret = FALSE;
@@ -470,8 +469,6 @@ hidpp_device_read_resp (HidppDevice *device,
}
out:
- /* allow caller to check for protocol errors */
- memcpy (response, &read_msg, sizeof (read_msg));
return ret;
}