spiFlash: Fix return value checking polarity and error reporting in protect_flash() and unprotect_flash()
The return value fro flash.enable_protection is an integer, where 0 means success. So it must be compared to 0 to result in a true value for ret. If flash.disable_protect() returns non-zero, then ret will be false, so there's no point in doing a std::to_string on ret. You would need an integer intermediate value if you wanted to print the error value.
This commit is contained in:
parent
de5aff7a96
commit
c36eb1d0a8
|
|
@ -39,8 +39,8 @@ bool SPIInterface::protect_flash(uint32_t len)
|
||||||
SPIFlash flash(this, false, _spif_verbose);
|
SPIFlash flash(this, false, _spif_verbose);
|
||||||
|
|
||||||
/* configure flash protection */
|
/* configure flash protection */
|
||||||
ret = flash.enable_protection(len) != 0;
|
ret = (flash.enable_protection(len) == 0);
|
||||||
if (ret != 0)
|
if (!ret)
|
||||||
printError("Fail");
|
printError("Fail");
|
||||||
else
|
else
|
||||||
printSuccess("Done");
|
printSuccess("Done");
|
||||||
|
|
@ -72,7 +72,7 @@ bool SPIInterface::unprotect_flash()
|
||||||
printInfo("unprotect_flash: ", false);
|
printInfo("unprotect_flash: ", false);
|
||||||
ret = (flash.disable_protection() == 0);
|
ret = (flash.disable_protection() == 0);
|
||||||
if (!ret)
|
if (!ret)
|
||||||
printError("Fail " + std::to_string(ret));
|
printError("Fail");
|
||||||
else
|
else
|
||||||
printSuccess("Done");
|
printSuccess("Done");
|
||||||
} catch (std::exception &e) {
|
} catch (std::exception &e) {
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue