From d3f765105f7fcd79d3e2501c58288c1abf32e41f Mon Sep 17 00:00:00 2001 From: =?utf8?q?Ji=C5=99=C3=AD=20Mat=C4=9Bj=C3=A1k?= Date: Fri, 27 Apr 2018 10:58:52 +0200 Subject: [PATCH] safer error checking and more doc --- mt_rfid.h | 1 + mt_server.c | 2 +- mt_server.h | 1 + 3 files changed, 3 insertions(+), 1 deletion(-) diff --git a/mt_rfid.h b/mt_rfid.h index 7dfa6c9..fad9390 100644 --- a/mt_rfid.h +++ b/mt_rfid.h @@ -24,6 +24,7 @@ typedef struct mt_rfid_t { } mt_rfid_t; // connect to the reader, add self to loop and make it write to fd +// return 0 on success, negative number otherwise int mt_rfid_init(mt_rfid_t *self, struct ev_loop *loop, int fd); // disconnect from reader diff --git a/mt_server.c b/mt_server.c index 51b5b60..220b6bf 100644 --- a/mt_server.c +++ b/mt_server.c @@ -192,7 +192,7 @@ int main(int argc, const char **argv) set_signal_exit(loop); - if (mt_server_init(&server, loop, STDIN_FILENO) == -1) { + if (mt_server_init(&server, loop, STDIN_FILENO) != 0) { return -1; } diff --git a/mt_server.h b/mt_server.h index 98fd5d1..bf7c6e2 100644 --- a/mt_server.h +++ b/mt_server.h @@ -29,6 +29,7 @@ typedef struct mt_server_t { } mt_server_t; // init self, add it to loop and make it read data from fd +// return 0 on success, -1 otherwise int mt_server_init(mt_server_t *self, struct ev_loop *loop, int fd); // gett drunc an kil sellf -- 2.39.2