Commit 21368290 authored by Varun Wadekar's avatar Varun Wadekar
Browse files

Tegra: bpmp_ipc: improve cyclomatic complexity



Code complexity is a good indication of maintainability versus
testability of a piece of software.

ISO26262 introduces the following thresholds:

    complexity < 10 is accepted
    10 <= complexity < 20 has to be justified
    complexity >= 20 cannot be accepted

Rationale is that number of test cases to fully test a piece of
software can (depending on the coverage metrics) grow exponentially
with the number of branches in the software.

This patch removes redundant conditionals from 'ipc_send_req_atomic'
handler to reduce the McCabe Cyclomatic Complexity for this function

Change-Id: I20fef79a771301e1c824aea72a45ff83f97591d5
Signed-off-by: default avatarVarun Wadekar <vwadekar@nvidia.com>
parent 6f47acdb
......@@ -175,11 +175,9 @@ static int32_t tegra_bpmp_ipc_send_req_atomic(uint32_t mrq, void *p_out,
if ((p_out == NULL) || (size_out > IVC_DATA_SZ_BYTES) ||
(frame == NULL)) {
ERROR("%s: invalid parameters, exiting\n", __func__);
ret = -EINVAL;
return -EINVAL;
}
if (ret == 0) {
/* prepare the command frame */
frame->mrq = mrq;
frame->flags = FLAG_DO_ACK;
......@@ -191,13 +189,13 @@ static int32_t tegra_bpmp_ipc_send_req_atomic(uint32_t mrq, void *p_out,
/* wait for slave to ack */
ret = tegra_bpmp_wait_for_slave_ack();
if (ret != 0) {
ERROR("failed waiting for the slave to ack\n");
if (ret < 0) {
ERROR("%s: wait for slave failed (%d)\n", __func__, ret);
return ret;
}
/* retrieve the response frame */
if ((size_in <= IVC_DATA_SZ_BYTES) && (p_in != NULL) &&
(ret == 0)) {
if ((size_in <= IVC_DATA_SZ_BYTES) && (p_in != NULL)) {
f_in = tegra_bpmp_get_cur_in_frame();
if (f_in != NULL) {
......@@ -207,12 +205,9 @@ static int32_t tegra_bpmp_ipc_send_req_atomic(uint32_t mrq, void *p_out,
}
}
if (ret == 0) {
ret = tegra_bpmp_free_master();
if (ret != 0) {
ERROR("Failed to free master\n");
}
}
if (ret < 0) {
ERROR("%s: free master failed (%d)\n", __func__, ret);
}
return ret;
......
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