Commit 10e6660c authored by Andy Hung's avatar Andy Hung
Browse files

Make IEffect command more robust (second try)

See reverted commit 320bd569.

Change-Id: If30cfa535ad51521053706fc40fc98d893db5bc7
parent 3f335768
......@@ -85,13 +85,15 @@ public:
data.writeInt32(size);
status_t status = remote()->transact(COMMAND, data, &reply);
if (status == NO_ERROR) {
status = reply.readInt32();
}
if (status != NO_ERROR) {
if (pReplySize != NULL)
*pReplySize = 0;
return status;
}
status = reply.readInt32();
size = reply.readInt32();
if (size != 0 && pReplyData != NULL && pReplySize != NULL) {
reply.read(pReplyData, size);
......@@ -155,6 +157,10 @@ status_t BnEffect::onTransact(
char *cmd = NULL;
if (cmdSize) {
cmd = (char *)calloc(cmdSize, 1);
if (cmd == NULL) {
reply->writeInt32(NO_MEMORY);
return NO_ERROR;
}
data.read(cmd, cmdSize);
}
uint32_t replySize = data.readInt32();
......@@ -162,15 +168,22 @@ status_t BnEffect::onTransact(
char *resp = NULL;
if (replySize) {
resp = (char *)calloc(replySize, 1);
if (resp == NULL) {
free(cmd);
reply->writeInt32(NO_MEMORY);
return NO_ERROR;
}
}
status_t status = command(cmdCode, cmdSize, cmd, &replySz, resp);
reply->writeInt32(status);
if (replySz < replySize) {
replySize = replySz;
}
reply->writeInt32(replySize);
if (replySize) {
reply->write(resp, replySize);
if (status == NO_ERROR) {
if (replySz < replySize) {
replySize = replySz;
}
reply->writeInt32(replySize);
if (replySize) {
reply->write(resp, replySize);
}
}
if (cmd) {
free(cmd);
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment