Be consistent and check for errors first

This commit is contained in:
Daniel Lublin 2022-09-21 10:56:15 +02:00
parent c0334a77da
commit df67966d8f
No known key found for this signature in database
GPG Key ID: 75BD0FEB8D3E7830

View File

@ -205,14 +205,14 @@ int main()
case FW_CMD_RUN_APP:
puts("request: run-app\n");
if (hdr.len != 1) {
// Bad length
if (hdr.len != 1 || *app_size == 0 || *app_addr == 0) {
// Bad cmd length, or app_size and app_addr are
// not both set
rsp[0] = STATUS_BAD;
fwreply(hdr, FW_RSP_RUN_APP, rsp);
break;
}
if (*app_size > 0 && *app_addr != 0) {
rsp[0] = STATUS_OK;
fwreply(hdr, FW_RSP_RUN_APP, rsp);
@ -238,11 +238,7 @@ int main()
"jalr x0,0(a0);"
::: "memory");
// clang-format on
}
rsp[0] = STATUS_BAD;
fwreply(hdr, FW_RSP_RUN_APP, rsp);
break;
break; // This is never reached!
case FW_CMD_GET_APP_DIGEST:
puts("request: get-app-digest\n");