Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

hidraw: only print errors when DEBUG_PRINTF is defined #351

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 10 additions & 4 deletions linux/hid.c
Original file line number Diff line number Diff line change
Expand Up @@ -54,6 +54,12 @@
#define HIDIOCGFEATURE(len) _IOC(_IOC_WRITE|_IOC_READ, 'H', 0x07, len)
#endif

#ifdef DEBUG_PRINTF
#define DEBUG_PERROR(...) perror(__VA_ARGS__)
#else
#define DEBUG_PERROR(...) do {} while(0)
#endif


/* USB HID device property names */
const char *device_string_names[] = {
Expand Down Expand Up @@ -640,14 +646,14 @@ hid_device * HID_API_EXPORT hid_open_path(const char *path)
/* Get Report Descriptor Size */
res = ioctl(dev->device_handle, HIDIOCGRDESCSIZE, &desc_size);
if (res < 0)
perror("HIDIOCGRDESCSIZE");
DEBUG_PERROR("HIDIOCGRDESCSIZE");


/* Get Report Descriptor */
rpt_desc.size = desc_size;
res = ioctl(dev->device_handle, HIDIOCGRDESC, &rpt_desc);
if (res < 0) {
perror("HIDIOCGRDESC");
DEBUG_PERROR("HIDIOCGRDESC");
} else {
/* Determine if this device uses numbered reports. */
dev->uses_numbered_reports =
Expand Down Expand Up @@ -743,7 +749,7 @@ int HID_API_EXPORT hid_send_feature_report(hid_device *dev, const unsigned char

res = ioctl(dev->device_handle, HIDIOCSFEATURE(length), data);
if (res < 0)
perror("ioctl (SFEATURE)");
DEBUG_PERROR("ioctl (SFEATURE)");

return res;
}
Expand All @@ -754,7 +760,7 @@ int HID_API_EXPORT hid_get_feature_report(hid_device *dev, unsigned char *data,

res = ioctl(dev->device_handle, HIDIOCGFEATURE(length), data);
if (res < 0)
perror("ioctl (GFEATURE)");
DEBUG_PERROR("ioctl (GFEATURE)");


return res;
Expand Down