diff options
author | Andi Shyti <andi.shyti@samsung.com> | 2016-11-03 18:05:39 +0000 |
---|---|---|
committer | Andi Shyti <andi.shyti@samsung.com> | 2016-11-03 18:05:39 +0000 |
commit | f8a95b23a153377020cbe698f5306094ad58193c (patch) | |
tree | faaa6fb3a6ce82540aa6ca24d627b24f16874ac2 | |
parent | b38324308b817f9f67c8d99324ae5fe14510b5c0 (diff) |
stmfts: exit in case of failure
Signed-off-by: Andi Shyti <andi.shyti@samsung.com>
-rw-r--r-- | stmfts.c | 16 |
1 files changed, 12 insertions, 4 deletions
@@ -44,10 +44,14 @@ int stmfts_read_event(int fd) while(1) { ret = read(fd, &sev.ev, sizeof(sev.ev)); - if (ret < 0) + if (ret < 0) { perror("unable to read from device"); - if (ret != sizeof(sev.ev)) + return -1; + } + if (ret != sizeof(sev.ev)) { error(0, EIO, "unable to read properly"); + return -1; + } switch(sev.ev.type) { case EV_SYN: @@ -169,12 +173,16 @@ int main(int argc, char *argv[]) } fd = stmfts_open_event(argv[1]); - if (fd < 0) + if (fd < 0) { error(0, ENODEV, "input event not found"); + return -1; + } fd = stmfts_read_event(fd); - if (fd) + if (fd) { fprintf(stderr, "something went wrong\n"); + return -1; + } return 0; } |