libsysutils: const correctness fixes + remove some debugging

Signed-off-by: San Mehat <san@google.com>
This commit is contained in:
San Mehat 2009-05-20 15:27:14 -07:00
parent 2fd9c5897a
commit db01754579
6 changed files with 21 additions and 21 deletions

View File

@ -13,8 +13,8 @@ public:
FrameworkClient(int sock);
virtual ~FrameworkClient() {}
int sendMsg(char *msg);
int sendMsg(char *msg, char *data);
int sendMsg(const char *msg);
int sendMsg(const char *msg, const char *data);
};
typedef android::List<FrameworkClient *> FrameworkClientCollection;

View File

@ -15,8 +15,8 @@ public:
int getSocket() { return mSocket; }
int sendMsg(int code, char *msg, bool addErrno);
int sendMsg(char *msg);
int sendMsg(int code, const char *msg, bool addErrno);
int sendMsg(const char *msg);
};
typedef android::List<SocketClient *> SocketClientCollection;

View File

@ -37,8 +37,8 @@ public:
int startListener();
int stopListener();
void sendBroadcast(int code, char *msg, bool addErrno);
void sendBroadcast(char *msg);
void sendBroadcast(int code, const char *msg, bool addErrno);
void sendBroadcast(const char *msg);
protected:
virtual bool onDataAvailable(SocketClient *c) = 0;

View File

@ -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;

View File

@ -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);

View File

@ -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;