From 771ddc8ce381d25b1c6bcc48b11152e82ac53468 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Krist=C3=B3f=20T=C3=B3th?= Date: Fri, 15 Oct 2021 20:55:41 +0200 Subject: [PATCH] Fix forgotten errno return in evdev C code --- xdg/keypressdetector/evdev.c | 5 +++-- xdg/keypressdetector/evdev.go | 2 +- 2 files changed, 4 insertions(+), 3 deletions(-) diff --git a/xdg/keypressdetector/evdev.c b/xdg/keypressdetector/evdev.c index cc3f956..e440a87 100644 --- a/xdg/keypressdetector/evdev.c +++ b/xdg/keypressdetector/evdev.c @@ -1,10 +1,11 @@ +#include #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) { diff --git a/xdg/keypressdetector/evdev.go b/xdg/keypressdetector/evdev.go index 56f94ef..e4a443c 100644 --- a/xdg/keypressdetector/evdev.go +++ b/xdg/keypressdetector/evdev.go @@ -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) }