diff options
Diffstat (limited to 'src')
-rw-r--r-- | src/ipcpd/broadcast/enroll.c | 6 | ||||
-rw-r--r-- | src/ipcpd/unicast/enroll.c | 6 | ||||
-rw-r--r-- | src/lib/dev.c | 5 | ||||
-rw-r--r-- | src/tools/obc/obc.c | 5 | ||||
-rw-r--r-- | src/tools/ocbr/ocbr_client.c | 2 | ||||
-rw-r--r-- | src/tools/oecho/oecho.c | 6 | ||||
-rw-r--r-- | src/tools/operf/operf_client.c | 4 | ||||
-rw-r--r-- | src/tools/oping/oping_client.c | 2 | ||||
-rw-r--r-- | src/tools/ovpn/ovpn.c | 2 |
9 files changed, 19 insertions, 19 deletions
diff --git a/src/ipcpd/broadcast/enroll.c b/src/ipcpd/broadcast/enroll.c index 36b82af1..511892b7 100644 --- a/src/ipcpd/broadcast/enroll.c +++ b/src/ipcpd/broadcast/enroll.c @@ -87,7 +87,7 @@ static int send_rcv_enroll_msg(int fd) clock_gettime(CLOCK_REALTIME, &t0); - if (flow_write(fd, buf, len)) { + if (flow_write(fd, buf, len) < 0) { log_dbg("Failed to send request message."); return -1; } @@ -222,7 +222,7 @@ static void * enroll_handle(void * o) log_dbg("Sending enrollment info (%zd bytes).", len); - if (flow_write(conn.flow_info.fd, reply, len)) { + if (flow_write(conn.flow_info.fd, reply, len) < 0) { log_err("Failed respond to enrollment request."); connmgr_dealloc(COMPID_ENROLL, &conn); free(reply); @@ -296,7 +296,7 @@ int enroll_done(struct conn * conn, enroll_msg__pack(&msg, buf); - if (flow_write(conn->flow_info.fd, buf, len)) { + if (flow_write(conn->flow_info.fd, buf, len) < 0) { log_dbg("Failed to send acknowledgment."); return -1; } diff --git a/src/ipcpd/unicast/enroll.c b/src/ipcpd/unicast/enroll.c index 6a612ff3..3b4a5a89 100644 --- a/src/ipcpd/unicast/enroll.c +++ b/src/ipcpd/unicast/enroll.c @@ -87,7 +87,7 @@ static int send_rcv_enroll_msg(int fd) clock_gettime(CLOCK_REALTIME, &t0); - if (flow_write(fd, buf, len)) { + if (flow_write(fd, buf, len) < 0) { log_dbg("Failed to send request message."); return -1; } @@ -238,7 +238,7 @@ static void * enroll_handle(void * o) log_dbg("Sending enrollment info (%zd bytes).", len); - if (flow_write(conn.flow_info.fd, reply, len)) { + if (flow_write(conn.flow_info.fd, reply, len) < 0) { log_err("Failed respond to enrollment request."); connmgr_dealloc(COMPID_ENROLL, &conn); free(reply); @@ -312,7 +312,7 @@ int enroll_done(struct conn * conn, enroll_msg__pack(&msg, buf); - if (flow_write(conn->flow_info.fd, buf, len)) { + if (flow_write(conn->flow_info.fd, buf, len) < 0) { log_dbg("Failed to send acknowledgment."); return -1; } diff --git a/src/lib/dev.c b/src/lib/dev.c index 8647bea9..80d7e9ad 100644 --- a/src/lib/dev.c +++ b/src/lib/dev.c @@ -1007,6 +1007,7 @@ ssize_t flow_write(int fd, if ((flags & FLOWFACCMODE) == FLOWFRDONLY) return -EPERM; + /* TODO: partial writes. */ if (flags & FLOWFWNOBLOCK) idx = shm_rdrbuff_alloc(ai.rdrb, count, @@ -1056,9 +1057,7 @@ ssize_t flow_write(int fd, pthread_rwlock_unlock(&ai.lock); - assert(ret <= 0); - - return ret; + return ret < 0 ? (ssize_t) ret : (ssize_t) count; } ssize_t flow_read(int fd, diff --git a/src/tools/obc/obc.c b/src/tools/obc/obc.c index eb5a42ce..256cb84e 100644 --- a/src/tools/obc/obc.c +++ b/src/tools/obc/obc.c @@ -88,7 +88,8 @@ static int reader_main(const char * dst) static int writer_main(const char * dst, const char * message) { - int fd = 0; + int fd = 0; + size_t len = strlen(message) + 1; fd = flow_join(dst, NULL, NULL); if (fd < 0) { @@ -96,7 +97,7 @@ static int writer_main(const char * dst, return -1; } - if (flow_write(fd, message, strlen(message) + 1) < 0) { + if (flow_write(fd, message, len) < 0) { printf("Failed to write packet.\n"); flow_dealloc(fd); return -1; diff --git a/src/tools/ocbr/ocbr_client.c b/src/tools/ocbr/ocbr_client.c index 6381a235..6120e1fd 100644 --- a/src/tools/ocbr/ocbr_client.c +++ b/src/tools/ocbr/ocbr_client.c @@ -135,7 +135,7 @@ int client_main(char * server, } else { /* flood */ while (!stop) { clock_gettime(CLOCK_REALTIME, &end); - if (flow_write(fd, buf, (size_t) size) < 0) { + if (flow_write(fd, buf, size) < 0) { stop = true; continue; } diff --git a/src/tools/oecho/oecho.c b/src/tools/oecho/oecho.c index f52f53de..a44b8b76 100644 --- a/src/tools/oecho/oecho.c +++ b/src/tools/oecho/oecho.c @@ -79,7 +79,7 @@ static int server_main(void) printf("Message from client is %.*s.\n", (int) count, buf); - if (flow_write(fd, buf, count) == -1) { + if (flow_write(fd, buf, count) < 0) { printf("Failed to write packet.\n"); flow_dealloc(fd); continue; @@ -93,10 +93,10 @@ static int server_main(void) static int client_main(void) { - int fd = 0; + int fd; char buf[BUF_SIZE]; char * message = "Client says hi!"; - ssize_t count = 0; + ssize_t count; fd = flow_alloc("oecho", NULL, NULL); if (fd < 0) { diff --git a/src/tools/operf/operf_client.c b/src/tools/operf/operf_client.c index 3b0ff2af..004a8965 100644 --- a/src/tools/operf/operf_client.c +++ b/src/tools/operf/operf_client.c @@ -141,7 +141,7 @@ void * writer(void * o) msg->id = client.sent; - if (flow_write(*fdp, buf, client.size) == -1) { + if (flow_write(*fdp, buf, client.size) < 0) { printf("Failed to send packet.\n"); flow_dealloc(*fdp); free(buf); @@ -204,7 +204,7 @@ int client_main(void) else printf("Doing a unidirectional test.\n"); - if (flow_write(fd, &client.conf, sizeof(client.conf))) { + if (flow_write(fd, &client.conf, sizeof(client.conf)) < 0) { printf("Failed to send configuration.\n"); flow_dealloc(fd); return -1; diff --git a/src/tools/oping/oping_client.c b/src/tools/oping/oping_client.c index aa92be53..d0255b7c 100644 --- a/src/tools/oping/oping_client.c +++ b/src/tools/oping/oping_client.c @@ -175,7 +175,7 @@ void * writer(void * o) msg->tv_sec = now.tv_sec; msg->tv_nsec = now.tv_nsec; - if (flow_write(*fdp, buf, client.size) == -1) { + if (flow_write(*fdp, buf, client.size) < 0) { printf("Failed to send packet.\n"); flow_dealloc(*fdp); free(buf); diff --git a/src/tools/ovpn/ovpn.c b/src/tools/ovpn/ovpn.c index a3dd2ec6..02501d52 100644 --- a/src/tools/ovpn/ovpn.c +++ b/src/tools/ovpn/ovpn.c @@ -163,7 +163,7 @@ void * t_reader(void * o) if (len <= 0) continue; - if (flow_write(o_fd, buf, len)) + if (flow_write(o_fd, buf, len) < 0) continue; } } |