There are a few calls to ioctl()/fcntl() in fgPlatformJoystickOpen() that lacks error handling. The attached patch adds this. I attempted to follow your coding style. Let me know what you think and whether I can do anything to get this merged quicker. :)
I don't see what good returning at this point does. First of all
JSIOCGAXES
andJSIOCGBUTTONS
ioctl can't fail. The code in the kernel is simply:But even if it could fail, we don't want to return there, we'd want to just avoid clobbering the
num_axes
/num_buttons
variables with the undefined value inu
.JSIOCGNAME
can fail, but in that case we certainly don't wont to just return and skip the rest of the function. Simply leaving a default name, is absolutely fine. We just need to make sure there's always a sane default there too.Setting the
O_NONBLOCK
flag withfcntl(... F_SETFL, O_NONBLOCK)
also can't possibly fail if we do it correctly. Here we're not doing it correctly.O_NONBLOCK
should be or-ed with the current flags, not override them completely. But still it won't fail.I'm leaving this open for now, to remember to fix these issues I identified while looking into it.