return fd;
new_device->fd_is_managed = 1;
- } else if (fd < 0)
+ } else if (fd < 0) {
+ log_bug("Invalid fd %d\n", fd);
return -EBADF;
+ }
memset(&uidev, 0, sizeof(uidev));
new_device->fd = fd;
if (fetch_syspath_and_devnode(new_device) == -1) {
+ log_error("unable to fetch syspath or device node.\n");
errno = ENODEV;
goto error;
}
LIBEVDEV_EXPORT int
libevdev_change_fd(struct libevdev *dev, int fd)
{
- if (dev->fd == -1)
+ if (dev->fd == -1) {
+ log_bug("device not initialized. call libevdev_set_fd() first\n");
return -1;
+ }
dev->fd = fd;
return 0;
}
int i;
char buf[256];
- if (dev->fd != -1)
+ if (dev->fd != -1) {
+ log_bug("device already initialized.\n");
return -EBADF;
+ }
rc = ioctl(fd, EVIOCGBIT(0, sizeof(dev->bits)), dev->bits);
if (rc < 0)
{
int rc = 0;
- if (dev->fd < 0)
+ if (dev->fd < 0) {
+ log_bug("device not initialized. call libevdev_set_fd() first\n");
return -EBADF;
+ }
- if (!(flags & (LIBEVDEV_READ_NORMAL|LIBEVDEV_READ_SYNC|LIBEVDEV_FORCE_SYNC)))
+ if (!(flags & (LIBEVDEV_READ_NORMAL|LIBEVDEV_READ_SYNC|LIBEVDEV_FORCE_SYNC))) {
+ log_bug("invalid flags %#x\n.\n", flags);
return -EINVAL;
+ }
if (flags & LIBEVDEV_READ_SYNC) {
if (dev->sync_state == SYNC_NEEDED) {
struct pollfd fds = { dev->fd, POLLIN, 0 };
int rc;
- if (dev->fd < 0)
+ if (dev->fd < 0) {
+ log_bug("device not initialized. call libevdev_set_fd() first\n");
return -EBADF;
+ }
if (queue_num_elements(dev) != 0)
return 1;
{
int rc;
- if (dev->fd < 0)
+ if (dev->fd < 0) {
+ log_bug("device not initialized. call libevdev_set_fd() first\n");
return -EBADF;
+ }
if (code > ABS_MAX)
return -EINVAL;
{
int rc = 0;
- if (dev->fd < 0)
+ if (dev->fd < 0) {
+ log_bug("device not initialized. call libevdev_set_fd() first\n");
return -EBADF;
+ }
- if (grab != LIBEVDEV_GRAB && grab != LIBEVDEV_UNGRAB)
+ if (grab != LIBEVDEV_GRAB && grab != LIBEVDEV_UNGRAB) {
+ log_bug("invalid grab parameter %#x\n", grab);
return -EINVAL;
+ }
if (grab == dev->grabbed)
return 0;
int rc = 0;
size_t nleds = 0;
- if (dev->fd < 0)
+ if (dev->fd < 0) {
+ log_bug("device not initialized. call libevdev_set_fd() first\n");
return -EBADF;
+ }
memset(ev, 0, sizeof(ev));