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 <krzysztof.kopyscinski@codecoup.pl>
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 @@
 
 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;
 }
 
 /**