summaryrefslogtreecommitdiff
path: root/serialclient.c
diff options
context:
space:
mode:
Diffstat (limited to 'serialclient.c')
-rw-r--r--serialclient.c18
1 files changed, 9 insertions, 9 deletions
diff --git a/serialclient.c b/serialclient.c
index 538df13..cee4ec5 100644
--- a/serialclient.c
+++ b/serialclient.c
@@ -50,7 +50,7 @@ int process_data(int src_fd, int dest_fd)
return ret;
log_printf(DEBUG, "read %d bytes from fd (%d)", ret, src_fd);
-
+
int len = ret;
int offset = 0;
for(;;) {
@@ -89,8 +89,8 @@ int main_loop(int serial_fd, int cmd_fd, options_t* opt)
int return_value = 0;
if(opt->type_) {
char* tmp;
- asprintf(&tmp, "type %s\n", opt->type_);
- if(!tmp) {
+ int len = asprintf(&tmp, "type %s\n", opt->type_);
+ if(len < 0) {
log_printf(ERROR, "memory error at init");
return_value = -2;
}
@@ -123,7 +123,7 @@ int main_loop(int serial_fd, int cmd_fd, options_t* opt)
if(FD_ISSET(sig_fd, &tmpfds))
if(signal_handle())
return_value = 1;
-
+
if(FD_ISSET(serial_fd, &tmpfds))
return_value = process_data(serial_fd, cmd_fd);
@@ -175,7 +175,7 @@ int main(int argc, char* argv[])
case -4: fprintf(stderr, "this log target is only allowed once: '%s', exitting\n", tmp->string_); break;
default: fprintf(stderr, "syntax error near: '%s', exitting\n", tmp->string_); break;
}
-
+
options_clear(&opt);
log_close();
exit(ret);
@@ -237,7 +237,7 @@ int main(int argc, char* argv[])
cmd_fd = connect_command_socket(opt.command_sock_);
if(cmd_fd < 0)
ret = 3;
- else {
+ else {
serial_fd = open(opt.serial_dev_, O_RDWR | O_NOCTTY);
if(serial_fd < 0)
ret = 2;
@@ -248,14 +248,14 @@ int main(int argc, char* argv[])
else
ret = main_loop(serial_fd, cmd_fd, &opt);
}
- }
+ }
if(ret == 2 || ret == 3) {
- if(ret == 2)
+ if(ret == 2)
log_printf(ERROR, "%s error, trying to reopen in 5 seconds..", opt.serial_dev_);
if(ret == 3)
log_printf(ERROR, "socket error, trying to reconnect in 5 seconds..");
-
+
if(cmd_fd > 0)
close(cmd_fd);
if(serial_fd > 0)