Incorrect drmIoctl() return value and code check in drmmode_show_cursor()
When drmModeSetCursor2()
call was replaced with bare drmIoctl()
call in 92df7097, a bug was introduced. Previously, return value from drmIoctl()
was mangled: negative return values were replaced with -errno
by the following wrapper function as defined in the xf86drmMode.c
:
static inline int DRM_IOCTL(int fd, unsigned long cmd, void *arg)
{
int ret = drmIoctl(fd, cmd, arg);
return ret < 0 ? -errno : ret;
}
Now, this mangling no longer happens, and the check if (ret == -EINVAL)
after the drmIoctl()
call is wrong. It should be replaced with if (ret == -1 && errno == EINVAL)
, which is both correct and follows POSIX semantics for ioctl(2)
-type functions.
The bug can manifest itself as HW cursor becoming invisible after update from version 18.1.0. See this FreeBSD bug report for details and discussion.