Skip to content

hid_open_path seems to ignore errors #384

Closed

Description

@lwahonen

In hid.c, function
hid_device * HID_API_EXPORT hid_open_path(const char *path) it looks like an error code is checked and printed - and then ignored?

`

	/* Get Report Descriptor Size */
	res = ioctl(dev->device_handle, HIDIOCGRDESCSIZE, &desc_size);
	if (res < 0)
		register_device_error_format(dev, "ioctl (GRDESCSIZE): %s", strerror(errno));

	/* Get Report Descriptor */
	rpt_desc.size = desc_size;
	res = ioctl(dev->device_handle, HIDIOCGRDESC, &rpt_desc);
	if (res < 0) {
		register_device_error_format(dev, "ioctl (GRDESC): %s", strerror(errno));
	} else {
		/* Determine if this device uses numbered reports. */
		dev->uses_numbered_reports =
			uses_numbered_reports(rpt_desc.value,
			                      rpt_desc.size);
	}

`

I'm not sure what register_device_error_format does, but it does not seem to be diverting execution, so the desc_size is used even if reading it failed?

Activity

  1. Youw commented on Feb 21, 2022

    @Youw
    Member

    Good catch.
    Agree, it should be handled properly.
    The fact is - I don't believe this functionality needed at all for device to function. I'll clean it up next time I'll get to that code.

  2. added
    hidraw
    on Feb 21, 2022
  3. added a commit that references this issue on Sep 25, 2024
    4e63d6d
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    hidraw

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions