Fix forgotten errno return in evdev C code

This commit is contained in:
Kristóf Tóth 2021-10-15 20:55:41 +02:00
parent 98ed8d9a29
commit 771ddc8ce3
2 changed files with 4 additions and 3 deletions

View File

@ -1,10 +1,11 @@
#include <errno.h>
#include "evdev.h"
int block_until_keypress(const char* keyboardPath) {
int keyboardFd = open(keyboardPath, O_RDONLY);
if (keyboardFd < 0) {
return keyboardFd;
return errno;
}
int eventSize = sizeof(struct input_event);
@ -15,7 +16,7 @@ int block_until_keypress(const char* keyboardPath) {
while(readEvents) {
bytesRead = read(keyboardFd, events, eventSize * NUM_EVENTS);
if (bytesRead < 0) {
return bytesRead;
return errno;
}
for(int i = 0; i < (bytesRead / eventSize); ++i) {

View File

@ -20,7 +20,7 @@ func (Evdev) BlockUntilKeypress(devicePath string) error {
defer C.free(unsafe.Pointer(path))
ret := C.block_until_keypress(path)
if ret < 0 {
if ret != 0 {
return syscall.Errno(ret)
}