Skip to content

Commit 9cc5ac0

Browse files
hid: define easy error data setter function
Sets all error data, including an optional contextual error message which is supposed to be a non-freeable constant string such as a string literal. Contextual error messages are meant to be used in the cases the libusb documentation goes into detail as to what happened. Passing NULL will produce a message with just the libusb_error_name and the libusb_strerror results. Passing a string literal will produce a message that contains the additional context in addition to the error name and message.
1 parent 277cac9 commit 9cc5ac0

File tree

1 file changed

+5
-0
lines changed

1 file changed

+5
-0
lines changed

libusb/hid.c

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -422,6 +422,11 @@ static wchar_t *libusb_strerror_wchar(int error) {
422422
return libusb_error_wchar(error, libusb_strerror);
423423
}
424424

425+
static void set_error(hid_device *dev, int error, const char *error_context)
426+
{
427+
dev->error = error;
428+
dev->error_context = error_context;
429+
}
425430

426431
/* This function returns a newly allocated wide string containing the USB
427432
device string numbered by the index. The returned string must be freed

0 commit comments

Comments
 (0)