From cb4124123af748f6cbf787b6fbea8aa675c507dc Mon Sep 17 00:00:00 2001 From: Kars Mulder Date: Sun, 28 Apr 2024 11:17:51 +0000 Subject: [PATCH] Add #ifdef guards around UI_GET_SYSNAME (#218) If the C code is built with a kernel header that does not provide UI_GET_SYSNAME, then ui_get_sysname() will always raise OSError. (Unless incorrect arguments are provided to the function, in which case the function still behaves as it otherwise would.) --- evdev/uinput.c | 2 ++ 1 file changed, 2 insertions(+) diff --git a/evdev/uinput.c b/evdev/uinput.c index 2e2d8e5..3494705 100644 --- a/evdev/uinput.c +++ b/evdev/uinput.c @@ -106,10 +106,12 @@ uinput_get_sysname(PyObject *self, PyObject *args) int ret = PyArg_ParseTuple(args, "i", &fd); if (!ret) return NULL; + #ifdef UI_GET_SYSNAME if (ioctl(fd, UI_GET_SYSNAME(sizeof(sysname)), &sysname) < 0) goto on_err; return Py_BuildValue("s", &sysname); + #endif on_err: PyErr_SetFromErrno(PyExc_OSError);