summaryrefslogtreecommitdiffstats
path: root/libsysutils
diff options
context:
space:
mode:
authorSan Mehat <san@google.com>2009-05-20 15:27:14 -0700
committerSan Mehat <san@google.com>2009-05-20 17:16:05 -0700
commitdb017545796747115b8797f03e662b0f398a7c7b (patch)
tree56c78aebe652c2d718a7007381cc3c770eb8ad0d /libsysutils
parent2fd9c5897aba37847879033dd1cffd345ced93fc (diff)
downloadcore-db017545796747115b8797f03e662b0f398a7c7b.tar.gz
core-db017545796747115b8797f03e662b0f398a7c7b.tar.bz2
core-db017545796747115b8797f03e662b0f398a7c7b.zip
libsysutils: const correctness fixes + remove some debugging
Signed-off-by: San Mehat <san@google.com>
Diffstat (limited to 'libsysutils')
-rw-r--r--libsysutils/src/FrameworkClient.cpp5
-rw-r--r--libsysutils/src/SocketClient.cpp21
-rw-r--r--libsysutils/src/SocketListener.cpp4
3 files changed, 15 insertions, 15 deletions
diff --git a/libsysutils/src/FrameworkClient.cpp b/libsysutils/src/FrameworkClient.cpp
index 237bb60f9..16869961d 100644
--- a/libsysutils/src/FrameworkClient.cpp
+++ b/libsysutils/src/FrameworkClient.cpp
@@ -13,8 +13,7 @@ FrameworkClient::FrameworkClient(int socket) {
pthread_mutex_init(&mWriteMutex, NULL);
}
-int FrameworkClient::sendMsg(char *msg) {
- LOGD("FrameworkClient::sendMsg(%s)", msg);
+int FrameworkClient::sendMsg(const char *msg) {
if (mSocket < 0) {
errno = EHOSTUNREACH;
return -1;
@@ -28,7 +27,7 @@ int FrameworkClient::sendMsg(char *msg) {
return 0;
}
-int FrameworkClient::sendMsg(char *msg, char *data) {
+int FrameworkClient::sendMsg(const char *msg, const char *data) {
char *buffer = (char *) alloca(strlen(msg) + strlen(data) + 1);
if (!buffer) {
errno = -ENOMEM;
diff --git a/libsysutils/src/SocketClient.cpp b/libsysutils/src/SocketClient.cpp
index ab020ca7b..b229627ff 100644
--- a/libsysutils/src/SocketClient.cpp
+++ b/libsysutils/src/SocketClient.cpp
@@ -14,7 +14,7 @@ SocketClient::SocketClient(int socket) {
pthread_mutex_init(&mWriteMutex, NULL);
}
-int SocketClient::sendMsg(int code, char *msg, bool addErrno) {
+int SocketClient::sendMsg(int code, const char *msg, bool addErrno) {
char *buf;
if (addErrno) {
@@ -27,23 +27,24 @@ int SocketClient::sendMsg(int code, char *msg, bool addErrno) {
return sendMsg(buf);
}
-int SocketClient::sendMsg(char *msg) {
+int SocketClient::sendMsg(const char *msg) {
if (mSocket < 0) {
errno = EHOSTUNREACH;
return -1;
}
- char *bp;
-
+ char *tmp;
+ const char *bp = msg;
+
if (msg[strlen(msg)] != '\n') {
- bp = (char *) alloca(strlen(msg) + 1);
- strcpy(bp, msg);
- strcat(bp, "\n");
- } else
- bp = msg;
+ tmp = (char *) alloca(strlen(msg) + 1);
+ strcpy(tmp, msg);
+ strcat(tmp, "\n");
+ bp = tmp;
+ }
int rc = 0;
- char *p = bp;
+ const char *p = bp;
int brtw = strlen(bp);
pthread_mutex_lock(&mWriteMutex);
diff --git a/libsysutils/src/SocketListener.cpp b/libsysutils/src/SocketListener.cpp
index acc4a67df..cb7dd808f 100644
--- a/libsysutils/src/SocketListener.cpp
+++ b/libsysutils/src/SocketListener.cpp
@@ -173,7 +173,7 @@ void SocketListener::runListener() {
}
}
-void SocketListener::sendBroadcast(int code, char *msg, bool addErrno) {
+void SocketListener::sendBroadcast(int code, const char *msg, bool addErrno) {
pthread_mutex_lock(&mClientsLock);
SocketClientCollection::iterator i;
@@ -185,7 +185,7 @@ void SocketListener::sendBroadcast(int code, char *msg, bool addErrno) {
pthread_mutex_unlock(&mClientsLock);
}
-void SocketListener::sendBroadcast(char *msg) {
+void SocketListener::sendBroadcast(const char *msg) {
pthread_mutex_lock(&mClientsLock);
SocketClientCollection::iterator i;