Imported Upstream version 2.6.1

This commit is contained in:
Arnaud Quette 2011-06-01 22:31:49 +02:00
parent 459aaf9392
commit a367d9bc54
178 changed files with 4651 additions and 3279 deletions

View file

@ -141,7 +141,6 @@ static int refresh_report_buffer(reportbuf_t *rbuf, hid_dev_handle_t udev, HIDDa
{
int id = pData->ReportID;
int r;
unsigned char buf[SMALLBUF];
if (rbuf->ts[id] + age > time(NULL)) {
/* buffered report is still good; nothing to do */
@ -149,17 +148,14 @@ static int refresh_report_buffer(reportbuf_t *rbuf, hid_dev_handle_t udev, HIDDa
return 0;
}
r = comm_driver->get_report(udev, id, buf, sizeof(buf));
r = comm_driver->get_report(udev, id, rbuf->data[id], rbuf->len[id]);
if (r <= 0) {
return -1;
}
/* broken report descriptors are common, so store whatever we can */
memcpy(rbuf->data[id], buf, (r < rbuf->len[id]) ? r : rbuf->len[id]);
if (rbuf->len[id] != r) {
upsdebugx(2, "%s: expected %d bytes, but got %d instead", __func__, rbuf->len[id], r);
upsdebug_hex(3, "Report[err]", buf, r);
upsdebug_hex(3, "Report[err]", rbuf->data[id], r);
} else {
upsdebug_hex(3, "Report[get]", rbuf->data[id], rbuf->len[id]);
}
@ -399,7 +395,7 @@ char *HIDGetIndexString(hid_dev_handle_t udev, const int Index, char *buf, size_
if (comm_driver->get_string(udev, Index, buf, buflen) < 1)
buf[0] = '\0';
return buf;
return rtrim(buf, '\n');
}
/* Return pointer to indexed string from HID path (empty if not found)