diff options
| author | Robert Greenwalt <rgreenwalt@google.com> | 2012-03-09 15:12:34 -0800 |
|---|---|---|
| committer | Android (Google) Code Review <android-gerrit@google.com> | 2012-03-09 15:12:34 -0800 |
| commit | 63d84d049a4673517b389188366ef61f840e9c2d (patch) | |
| tree | 121057ddda153e6f7b1535df7ff822520ff758ca /libsysutils/src | |
| parent | 6ff1bee167234aeb5281ac1a0acc6ce0720bedd1 (diff) | |
| parent | 7599bfcf13cf022333338b7a87aaddae69c48d73 (diff) | |
| download | core-63d84d049a4673517b389188366ef61f840e9c2d.tar.gz core-63d84d049a4673517b389188366ef61f840e9c2d.tar.bz2 core-63d84d049a4673517b389188366ef61f840e9c2d.zip | |
Merge "Fix pointer arith."
Diffstat (limited to 'libsysutils/src')
| -rw-r--r-- | libsysutils/src/SocketClient.cpp | 16 |
1 files changed, 8 insertions, 8 deletions
diff --git a/libsysutils/src/SocketClient.cpp b/libsysutils/src/SocketClient.cpp index d9713a624..4a7c82d6a 100644 --- a/libsysutils/src/SocketClient.cpp +++ b/libsysutils/src/SocketClient.cpp @@ -79,16 +79,16 @@ int SocketClient::sendMsg(int code, const char *msg, bool addErrno, bool useCmdN return ret; } - +/** send 3-digit code, null, binary-length, binary data */ int SocketClient::sendBinaryMsg(int code, const void *data, int len) { - /* 5 bytes for the code & space + 4 bytes for the len */ - char buf[9]; + /* 4 bytes for the code & null + 4 bytes for the len */ + char buf[8]; /* Write the code */ - snprintf(buf, 5, "%.3d ", code); + snprintf(buf, 4, "%.3d", code); /* Write the len */ uint32_t tmp = htonl(len); - memcpy(buf + 5, &tmp, sizeof(uint32_t)); + memcpy(buf + 4, &tmp, sizeof(uint32_t)); pthread_mutex_lock(&mWriteMutex); int result = sendDataLocked(buf, sizeof(buf)); @@ -102,9 +102,9 @@ int SocketClient::sendBinaryMsg(int code, const void *data, int len) { // Sends the code (c-string null-terminated). int SocketClient::sendCode(int code) { - char buf[5]; - snprintf(buf, 5, "%.3d ", code); - return sendData(buf, 5); + char buf[4]; + snprintf(buf, sizeof(buf), "%.3d", code); + return sendData(buf, sizeof(buf)); } int SocketClient::sendMsg(const char *msg) { |
