samples: flash_shell: Fix overwriting return value

Value of ret has been overwritten by flash_write_protection_set
before it could be returned from do_write_unaligned, which could
lead to reporting success when error code should have been returned.

Fixes #27641, Coverity-CID: 212142
Fixes #27642, Coverity-CID: 212143

Signed-off-by: Dominik Ermel <dominik.ermel@nordicsemi.no>
This commit is contained in:
Dominik Ermel 2020-08-18 23:41:27 +00:00 committed by Ioannis Glaropoulos
parent 9ef03bb54c
commit cefebbec39

View file

@ -372,11 +372,11 @@ free_buffers:
k_free(before_data); k_free(before_data);
k_free(after_data); k_free(after_data);
ret = flash_write_protection_set(flash_device, true); int ret1 = flash_write_protection_set(flash_device, true);
if (ret) { if (ret1) {
PR_ERROR(shell, "Failed to enable flash protection (err: %d)." PR_ERROR(shell, "Failed to enable flash protection (err: %d)."
"\n", ret); "\n", ret1);
return ret; return ret1;
} }
return ret; return ret;