summaryrefslogtreecommitdiffstats
path: root/libsysutils
diff options
context:
space:
mode:
authorMattias Falk <mattias.falk@sonyericsson.com>2011-05-13 16:25:38 +0200
committerHenrik Baard <henrik.baard@sonymobile.com>2012-05-29 14:19:06 +0200
commit2e5fcd08ac177e984ebf1fb05bab5dfcf296c5a4 (patch)
tree8e932ad0f6147550bc4d2b31d74076bfc8025e70 /libsysutils
parent1d5e7885698ca81241f10d06d475ef4e6075089b (diff)
downloadsystem_core-2e5fcd08ac177e984ebf1fb05bab5dfcf296c5a4.zip
system_core-2e5fcd08ac177e984ebf1fb05bab5dfcf296c5a4.tar.gz
system_core-2e5fcd08ac177e984ebf1fb05bab5dfcf296c5a4.tar.bz2
Add error handling to SocketClient::sendData
Return failure and set errno if mSocket isn't valid. Change-Id: I579114d435db46d0bb5682167ef34bebe061a8f8
Diffstat (limited to 'libsysutils')
-rw-r--r--libsysutils/src/SocketClient.cpp10
1 files changed, 5 insertions, 5 deletions
diff --git a/libsysutils/src/SocketClient.cpp b/libsysutils/src/SocketClient.cpp
index 722dcb2..69d165a 100644
--- a/libsysutils/src/SocketClient.cpp
+++ b/libsysutils/src/SocketClient.cpp
@@ -64,11 +64,6 @@ int SocketClient::sendMsg(int code, const char *msg, bool addErrno) {
}
int SocketClient::sendMsg(const char *msg) {
- if (mSocket < 0) {
- errno = EHOSTUNREACH;
- return -1;
- }
-
// Send the message including null character
if (sendData(msg, strlen(msg) + 1) != 0) {
SLOGW("Unable to send msg '%s'", msg);
@@ -82,6 +77,11 @@ int SocketClient::sendData(const void* data, int len) {
const char *p = (const char*) data;
int brtw = len;
+ if (mSocket < 0) {
+ errno = EHOSTUNREACH;
+ return -1;
+ }
+
if (len == 0) {
return 0;
}