mirror of
https://github.com/jtgans/g13gui.git
synced 2025-06-20 08:23:50 -04:00
g13d: Handle errors in writes
The original code was just throwing away error conditions for write calls to an fd. Obviously this is bad, but really, we should probably be using an ostream instead of a raw file handle here. For now, deal with the warning by checking the result for errors, at least, and later we'll refactor to use ostream properly.
This commit is contained in:
parent
516423ae16
commit
ae055495cc
15
g13d/g13.cc
15
g13d/g13.cc
@ -32,11 +32,22 @@ void G13_Device::send_event(int type, int code, int val) {
|
|||||||
_event.type = type;
|
_event.type = type;
|
||||||
_event.code = code;
|
_event.code = code;
|
||||||
_event.value = val;
|
_event.value = val;
|
||||||
write(_uinput_fid, &_event, sizeof(_event));
|
|
||||||
|
// TODO(jtgans): Make this actually verify it writes all bytes
|
||||||
|
auto result = write(_uinput_fid, &_event, sizeof(_event));
|
||||||
|
if (result < 0) {
|
||||||
|
G13_LOG(error, "Unable to send event: " << strerror(errno));
|
||||||
|
exit(1);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void G13_Device::write_output_pipe(const std::string &out) {
|
void G13_Device::write_output_pipe(const std::string &out) {
|
||||||
write(_output_pipe_fid, out.c_str(), out.size());
|
// TODO(jtgans): Make this actually verify it writes all bytes
|
||||||
|
auto result = write(_output_pipe_fid, out.c_str(), out.size());
|
||||||
|
if (result < 0) {
|
||||||
|
G13_LOG(error, "Unable to write to output pipe: " << strerror(errno));
|
||||||
|
exit(1);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void G13_Device::set_mode_leds(int leds) {
|
void G13_Device::set_mode_leds(int leds) {
|
||||||
|
Loading…
Reference in New Issue
Block a user