The original Jabra code returned a boolean from doListDev(), but I made it
return the fd. Which means returning zero for ENOENT probably isn't a good
idea any more. Make it return -1 for that case too.
char name[128];
int version;
char name[128];
int version;
- if ((fd = open(path, O_RDONLY)) != -1) {
- if (ioctl(fd, HIDIOCGDEVINFO, &devinfo) == -1) {
- perror("ioctl HIDIOCGDEVINFO");
- close(fd);
- return -1;
- }
- if (ioctl(fd, HIDIOCGNAME(sizeof(name)), name) == -1) {
- perror("ioctl HIDIOCGNAME");
- close(fd);
- return -1;
- }
- if (ioctl(fd, HIDIOCGVERSION, &version) == -1) {
- perror("ioctl HIDIOCGVERSION");
- close(fd);
- return -1;
- }
- if (devinfo.vendor != JABRA_VID &&
- devinfo.vendor != PLANTRONICS_VID) {
- close(fd);
- return -1;
- }
+ fd = open(path, O_RDONLY);
+ if (fd == -1)
- if (errno == ENOENT) {
- return 0;
+ if (ioctl(fd, HIDIOCGDEVINFO, &devinfo) == -1) {
+ perror("ioctl HIDIOCGDEVINFO");
+ close(fd);
+ return -1;
+ }
+ if (ioctl(fd, HIDIOCGNAME(sizeof(name)), name) == -1) {
+ perror("ioctl HIDIOCGNAME");
+ close(fd);
+ return -1;
+ }
+ if (ioctl(fd, HIDIOCGVERSION, &version) == -1) {
+ perror("ioctl HIDIOCGVERSION");
+ close(fd);
+ return -1;
+ }
+ if (devinfo.vendor != JABRA_VID &&
+ devinfo.vendor != PLANTRONICS_VID) {
+ close(fd);
+ return -1;
- perror("ioctl HIDIOCGVERSION");
- return -1;
}
static void writeUsage(int fd, unsigned report_type, unsigned page, unsigned code, __s32 value) {
}
static void writeUsage(int fd, unsigned report_type, unsigned page, unsigned code, __s32 value) {