summaryrefslogtreecommitdiffhomepage
path: root/proto-libevdev
diff options
context:
space:
mode:
authorStanislaw Halik <sthalik@misaki.pl>2019-05-05 01:33:26 +0200
committerStanislaw Halik <sthalik@misaki.pl>2019-05-05 01:33:26 +0200
commitace14a9b7d713bf5f413abd257829cb6fb1c027b (patch)
treeb6cf3b843ff52cc2369245f7e4d7dccb21beff94 /proto-libevdev
parent5a76a77a9651dd52560578bb509c917abba1d83c (diff)
proto/libevdev: fix error handling code harder
Issue: #944
Diffstat (limited to 'proto-libevdev')
-rw-r--r--proto-libevdev/ftnoir_protocol_libevdev.cpp18
1 files changed, 15 insertions, 3 deletions
diff --git a/proto-libevdev/ftnoir_protocol_libevdev.cpp b/proto-libevdev/ftnoir_protocol_libevdev.cpp
index 27b73f2d..612f5b27 100644
--- a/proto-libevdev/ftnoir_protocol_libevdev.cpp
+++ b/proto-libevdev/ftnoir_protocol_libevdev.cpp
@@ -1,3 +1,8 @@
+// strerror_r(3)
+#ifndef _POSIX_C_SOURCE
+# define _POSIX_C_SOURCE 200112L
+#endif
+
#include "ftnoir_protocol_libevdev.h"
#include "api/plugin-api.hpp"
#include "compat/math.hpp"
@@ -120,10 +125,17 @@ module_status evdev::initialize()
{
if (error_code)
{
+ const char* msg;
char buf[128] {};
- (void)strerror_r(error_code, buf, sizeof(buf));
- return error(QStringLiteral("libevdev call '%1' failed with error '%2' (%3)")
- .arg(!error_expr ? "<NULL>" : error_expr, buf).arg(error_code));
+
+ if (!(msg = strerror_r(error_code, buf, sizeof(buf))))
+ {
+ snprintf(buf, sizeof(buf), "%d", error_code);
+ msg = buf;
+ }
+
+ return error(QStringLiteral("libevdev call '%1' failed with error '%2'")
+ .arg(!error_expr ? "<NULL>" : error_expr, msg));
}
else
return {};