subsys/mgmt/hawkbit: Improve hawkbit_probe readability
After the firmware is downloaded in hawkbit_probe, a series of operations are done by using the fact that the conditions of an if-else statement will be ran until a match. This patches separate these condition into individual if-condition for better readability Signed-off-by: Yong Cong Sin <yongcong.sin@gmail.com>
This commit is contained in:
parent
c128a89690
commit
77d829e31e
1 changed files with 12 additions and 7 deletions
|
@ -1264,20 +1264,25 @@ enum hawkbit_response hawkbit_probe(void)
|
||||||
if (!hb_context.final_data_received) {
|
if (!hb_context.final_data_received) {
|
||||||
LOG_ERR("Download is not complete");
|
LOG_ERR("Download is not complete");
|
||||||
hb_context.code_status = HAWKBIT_DOWNLOAD_ERROR;
|
hb_context.code_status = HAWKBIT_DOWNLOAD_ERROR;
|
||||||
} else if (memcmp(response_hash, hb_context.dl.file_hash,
|
goto free_md;
|
||||||
mbedtls_md_get_size(hash_info)) != 0) {
|
}
|
||||||
|
|
||||||
|
if (memcmp(response_hash, hb_context.dl.file_hash, mbedtls_md_get_size(hash_info)) != 0) {
|
||||||
LOG_ERR("Hash mismatch");
|
LOG_ERR("Hash mismatch");
|
||||||
LOG_HEXDUMP_DBG(response_hash, sizeof(response_hash), "resp");
|
LOG_HEXDUMP_DBG(response_hash, sizeof(response_hash), "resp");
|
||||||
LOG_HEXDUMP_DBG(hb_context.dl.file_hash,
|
LOG_HEXDUMP_DBG(hb_context.dl.file_hash, sizeof(hb_context.dl.file_hash), "file");
|
||||||
sizeof(hb_context.dl.file_hash), "file");
|
|
||||||
hb_context.code_status = HAWKBIT_DOWNLOAD_ERROR;
|
hb_context.code_status = HAWKBIT_DOWNLOAD_ERROR;
|
||||||
} else if (boot_request_upgrade(BOOT_UPGRADE_TEST)) {
|
goto free_md;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (boot_request_upgrade(BOOT_UPGRADE_TEST)) {
|
||||||
LOG_ERR("Failed to mark the image in slot 1 as pending");
|
LOG_ERR("Failed to mark the image in slot 1 as pending");
|
||||||
hb_context.code_status = HAWKBIT_DOWNLOAD_ERROR;
|
hb_context.code_status = HAWKBIT_DOWNLOAD_ERROR;
|
||||||
} else {
|
goto free_md;
|
||||||
|
}
|
||||||
|
|
||||||
hb_context.code_status = HAWKBIT_UPDATE_INSTALLED;
|
hb_context.code_status = HAWKBIT_UPDATE_INSTALLED;
|
||||||
hawkbit_device_acid_update(hb_context.json_action_id);
|
hawkbit_device_acid_update(hb_context.json_action_id);
|
||||||
}
|
|
||||||
|
|
||||||
hb_context.dl.http_content_size = 0;
|
hb_context.dl.http_content_size = 0;
|
||||||
|
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue