diff options
author | Peter Wu <lekensteyn@gmail.com> | 2013-09-02 10:57:03 +0200 |
---|---|---|
committer | Peter Wu <lekensteyn@gmail.com> | 2013-09-02 11:45:34 +0200 |
commit | c3f1f2e85575c45128c054f128f0ec21bd3e377b (patch) | |
tree | 63ca9b6f69918b80cd94b06b9999e36627539a16 | |
parent | 52332dd53b108d9e47355a497d94ec81d1cec1af (diff) | |
download | upower-c3f1f2e85575c45128c054f128f0ec21bd3e377b.tar.gz |
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.c | 21 |
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; } |