From 69cf735e393962bd4b01a6f4b64862c6c1a9c25d Mon Sep 17 00:00:00 2001 From: akoszewski Date: Mon, 18 Sep 2017 14:22:45 +0200 Subject: [PATCH] Fix error checking for socket fd This is needed for cases when socket fd is equal to 0 Change-Id: Idb5926594f47cfad21fb8c6cc36a3b815ef667a0 --- TEECLib/src/teec_connection.c | 4 ++-- ssflib/src/ssf_client.cpp | 4 ++-- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/TEECLib/src/teec_connection.c b/TEECLib/src/teec_connection.c index 889ee82..af623ea 100644 --- a/TEECLib/src/teec_connection.c +++ b/TEECLib/src/teec_connection.c @@ -116,7 +116,7 @@ static uint32_t sendCommandtoDaemon(int32_t sockfd, char* fdata, size_t size) { ssize_t nwrite = 0; size_t nbytes = 0; - if (sockfd > 0) { + if (sockfd >= 0) { // send size number of bytes to Simulator Daemon do { nwrite = send(sockfd, fdata + nbytes, size - nbytes, 0); @@ -145,7 +145,7 @@ static uint32_t receiveResponse(int32_t sockfd, char* fdata, size_t size) { ssize_t nread = 0; size_t nbytes = 0; - if (sockfd > 0) { + if (sockfd >= 0) { // receive size number of bytes to Simulator Daemon do { nread = recv(sockfd, fdata + nbytes, size - nbytes, 0); diff --git a/ssflib/src/ssf_client.cpp b/ssflib/src/ssf_client.cpp index 14b7f8d..00b07e4 100644 --- a/ssflib/src/ssf_client.cpp +++ b/ssflib/src/ssf_client.cpp @@ -101,7 +101,7 @@ static uint32_t sendCommandtoDaemon(int32_t sockfd, char* fdata, size_t size) { LOGD(SSF_LIB, "Entry"); ssize_t nwrite = 0; size_t nbytes = 0; - if (sockfd > 0) { + if (sockfd >= 0) { do { nwrite = send(sockfd, fdata + nbytes, size - nbytes, 0); } while ((nwrite == -1 && errno == EINTR) || (nwrite > 0 && ((nbytes += @@ -124,7 +124,7 @@ static uint32_t receiveResponse(int32_t sockfd, char* fdata, size_t size) { LOGD(SSF_LIB, "Entry"); ssize_t nread = 0; size_t nbytes = 0; - if (sockfd > 0) { + if (sockfd >= 0) { do { nread = recv(sockfd, fdata + nbytes, size - nbytes, 0); } while ((nread == -1 && errno == EINTR) -- 2.34.1