am 03f0d27f: libsysutils: Fix command argument passing bug + whitespace cleanup

Merge commit '03f0d27f6c49530a91402ed42f8ca4b2fda04b9f'

* commit '03f0d27f6c49530a91402ed42f8ca4b2fda04b9f':
  libsysutils: Fix command argument passing bug + whitespace cleanup
This commit is contained in:
San Mehat 2009-06-01 09:35:15 -07:00 committed by The Android Open Source Project
commit ae41f613b8
4 changed files with 10 additions and 9 deletions

View file

@ -59,9 +59,11 @@ void FrameworkListener::registerCmd(FrameworkCommand *cmd) {
}
void FrameworkListener::dispatchCommand(SocketClient *cli, char *cmd) {
char *cm, *last;
char *next = cmd;
char *cm;
char *arg;
if (!(cm = strtok_r(cmd, ":", &last))) {
if (!(cm = strsep(&next, ":"))) {
cli->sendMsg(500, "Malformatted message", false);
return;
}
@ -72,8 +74,7 @@ void FrameworkListener::dispatchCommand(SocketClient *cli, char *cmd) {
FrameworkCommand *c = *i;
if (!strcmp(cm, c->getCommand())) {
cm += strlen(cm) +1;
if (c->runCommand(cli, cm)) {
if (c->runCommand(cli, next)) {
LOGW("Handler '%s' error (%s)", c->getCommand(), strerror(errno));
}
return;

View file

@ -67,9 +67,9 @@ bool NetlinkEvent::decode(char *buffer, int size) {
mAction = NlActionRemove;
else if (!strcmp(a, "change"))
mAction = NlActionChange;
} else if (!strncmp(s, "SEQNUM=", strlen("SEQNUM=")))
} else if (!strncmp(s, "SEQNUM=", strlen("SEQNUM=")))
mSeq = atoi(s + strlen("SEQNUM="));
else if (!strncmp(s, "SUBSYSTEM=", strlen("SUBSYSTEM=")))
else if (!strncmp(s, "SUBSYSTEM=", strlen("SUBSYSTEM=")))
mSubsystem = strdup(s + strlen("SUBSYSTEM="));
else
mParams[param_idx++] = strdup(s);

View file

@ -16,7 +16,7 @@ SocketClient::SocketClient(int socket) {
int SocketClient::sendMsg(int code, const char *msg, bool addErrno) {
char *buf;
if (addErrno) {
buf = (char *) alloca(strlen(msg) + strlen(strerror(errno)) + 8);
sprintf(buf, "%.3d %s (%s)", code, msg, strerror(errno));
@ -42,7 +42,7 @@ int SocketClient::sendMsg(const char *msg) {
strcat(tmp, "\n");
bp = tmp;
}
int rc = 0;
const char *p = bp;
int brtw = strlen(bp);

View file

@ -125,7 +125,7 @@ void SocketListener::runListener() {
max = (*it)->getSocket();
}
pthread_mutex_unlock(&mClientsLock);
if ((rc = select(max + 1, &read_fds, NULL, NULL, NULL)) < 0) {
LOGE("select failed (%s)", strerror(errno));
sleep(1);