This is an automated email from the ASF dual-hosted git repository.

janc pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/mynewt-mcumgr.git


The following commit(s) were added to refs/heads/master by this push:
     new 62009e0  img_mgmt_state_set_pending: corrected error handling
62009e0 is described below

commit 62009e0ef131762f966e2f877bc467fb5743d35b
Author: Krzysztof Kopyściński <[email protected]>
AuthorDate: Mon Mar 15 09:59:05 2021 +0100

    img_mgmt_state_set_pending: corrected error handling
    
    Return codes were unused - they were overwritten at the beginning of
    `done` marker. Proper behavior should be logging these errors and
    returning them. img_mgmt_read_info should not overwrite errors.
    
    Signed-off-by: Krzysztof Kopyściński <[email protected]>
---
 cmd/img_mgmt/src/img_mgmt_state.c | 9 +++++----
 1 file changed, 5 insertions(+), 4 deletions(-)

diff --git a/cmd/img_mgmt/src/img_mgmt_state.c 
b/cmd/img_mgmt/src/img_mgmt_state.c
index 79d147b..3f291a4 100644
--- a/cmd/img_mgmt/src/img_mgmt_state.c
+++ b/cmd/img_mgmt/src/img_mgmt_state.c
@@ -143,18 +143,19 @@ img_mgmt_state_set_pending(int slot, int permanent)
 
 done:
     /* Log the image hash if we know it. */
-    rc = img_mgmt_read_info(slot, NULL, hash, NULL);
-    if (rc != 0) {
+    if (img_mgmt_read_info(slot, NULL, hash, NULL)) {
         hashp = NULL;
     } else {
         hashp = hash;
     }
 
     if (permanent) {
-        return img_mgmt_impl_log_confirm(rc, hashp);
+        (void) img_mgmt_impl_log_confirm(rc, hashp);
     } else {
-        return img_mgmt_impl_log_pending(rc, hashp);
+        (void) img_mgmt_impl_log_pending(rc, hashp);
     }
+
+    return rc;
 }
 
 /**

Reply via email to