aboutsummaryrefslogtreecommitdiff
path: root/src/flash/nor
diff options
context:
space:
mode:
authorAntonio Borneo <borneo.antonio@gmail.com>2021-07-03 18:18:57 +0200
committerAntonio Borneo <borneo.antonio@gmail.com>2021-07-20 14:55:43 +0100
commit20b29b7767097f999fe2eb4f7fb6c2917e9f66a6 (patch)
treef6f060f100e0aae122b6e0fdbae2f342036bd7f7 /src/flash/nor
parent28c24a5c41c47a66e9310912f88148814f730a25 (diff)
downloadriscv-openocd-20b29b7767097f999fe2eb4f7fb6c2917e9f66a6.zip
riscv-openocd-20b29b7767097f999fe2eb4f7fb6c2917e9f66a6.tar.gz
riscv-openocd-20b29b7767097f999fe2eb4f7fb6c2917e9f66a6.tar.bz2
openocd: manually fix Yoda conditions
Fix the remaining Yoda conditions, detected by checkpatch but not fixed automatically. While there, apply minor style changes. Change-Id: I6e1978b89c4d56a20aceaeb2b52968eb6384432a Signed-off-by: Antonio Borneo <borneo.antonio@gmail.com> Reviewed-on: http://openocd.zylin.com/6356 Tested-by: jenkins Reviewed-by: Oleksij Rempel <linux@rempel-privat.de> Reviewed-by: Xiang W <wxjstz@126.com>
Diffstat (limited to 'src/flash/nor')
-rw-r--r--src/flash/nor/at91sam3.c10
-rw-r--r--src/flash/nor/at91sam4.c10
-rw-r--r--src/flash/nor/max32xxx.c8
-rw-r--r--src/flash/nor/msp432.c28
-rw-r--r--src/flash/nor/tms470.c4
5 files changed, 30 insertions, 30 deletions
diff --git a/src/flash/nor/at91sam3.c b/src/flash/nor/at91sam3.c
index 15ca296..4a7c1cd 100644
--- a/src/flash/nor/at91sam3.c
+++ b/src/flash/nor/at91sam3.c
@@ -3626,7 +3626,7 @@ COMMAND_HANDLER(sam3_handle_gpnvm_command)
who = -1;
break;
case 2:
- if ((0 == strcmp(CMD_ARGV[0], "show")) && (0 == strcmp(CMD_ARGV[1], "all")))
+ if ((strcmp(CMD_ARGV[0], "show") == 0) && (strcmp(CMD_ARGV[1], "all") == 0))
who = -1;
else {
uint32_t v32;
@@ -3636,7 +3636,7 @@ COMMAND_HANDLER(sam3_handle_gpnvm_command)
break;
}
- if (0 == strcmp("show", CMD_ARGV[0])) {
+ if (strcmp("show", CMD_ARGV[0]) == 0) {
if (who == -1) {
showall:
r = ERROR_OK;
@@ -3664,10 +3664,10 @@ showall:
return ERROR_COMMAND_SYNTAX_ERROR;
}
- if (0 == strcmp("set", CMD_ARGV[0]))
+ if (strcmp("set", CMD_ARGV[0]) == 0)
r = flashd_set_gpnvm(&(chip->details.bank[0]), who);
- else if ((0 == strcmp("clr", CMD_ARGV[0])) ||
- (0 == strcmp("clear", CMD_ARGV[0]))) /* quietly accept both */
+ else if ((strcmp("clr", CMD_ARGV[0]) == 0) ||
+ (strcmp("clear", CMD_ARGV[0]) == 0)) /* quietly accept both */
r = flashd_clr_gpnvm(&(chip->details.bank[0]), who);
else {
command_print(CMD, "Unknown command: %s", CMD_ARGV[0]);
diff --git a/src/flash/nor/at91sam4.c b/src/flash/nor/at91sam4.c
index b45cf07..958ec5e 100644
--- a/src/flash/nor/at91sam4.c
+++ b/src/flash/nor/at91sam4.c
@@ -3173,7 +3173,7 @@ COMMAND_HANDLER(sam4_handle_gpnvm_command)
who = -1;
break;
case 2:
- if ((0 == strcmp(CMD_ARGV[0], "show")) && (0 == strcmp(CMD_ARGV[1], "all")))
+ if ((strcmp(CMD_ARGV[0], "show") == 0) && (strcmp(CMD_ARGV[1], "all") == 0))
who = -1;
else {
uint32_t v32;
@@ -3183,7 +3183,7 @@ COMMAND_HANDLER(sam4_handle_gpnvm_command)
break;
}
- if (0 == strcmp("show", CMD_ARGV[0])) {
+ if (strcmp("show", CMD_ARGV[0]) == 0) {
if (who == -1) {
showall:
r = ERROR_OK;
@@ -3211,10 +3211,10 @@ showall:
return ERROR_COMMAND_SYNTAX_ERROR;
}
- if (0 == strcmp("set", CMD_ARGV[0]))
+ if (strcmp("set", CMD_ARGV[0]) == 0)
r = flashd_set_gpnvm(&(chip->details.bank[0]), who);
- else if ((0 == strcmp("clr", CMD_ARGV[0])) ||
- (0 == strcmp("clear", CMD_ARGV[0]))) /* quietly accept both */
+ else if ((strcmp("clr", CMD_ARGV[0]) == 0) ||
+ (strcmp("clear", CMD_ARGV[0]) == 0)) /* quietly accept both */
r = flashd_clr_gpnvm(&(chip->details.bank[0]), who);
else {
command_print(CMD, "Unknown command: %s", CMD_ARGV[0]);
diff --git a/src/flash/nor/max32xxx.c b/src/flash/nor/max32xxx.c
index a1bb668..1327da6 100644
--- a/src/flash/nor/max32xxx.c
+++ b/src/flash/nor/max32xxx.c
@@ -801,7 +801,7 @@ COMMAND_HANDLER(max32xxx_handle_protection_set_command)
info = bank->driver_priv;
/* Convert the range to the page numbers */
- if (1 != sscanf(CMD_ARGV[1], "0x%"SCNx32, &addr)) {
+ if (sscanf(CMD_ARGV[1], "0x%"SCNx32, &addr) != 1) {
LOG_WARNING("Error parsing address");
command_print(CMD, "max32xxx protection_set <bank> <addr> <size>");
return ERROR_FAIL;
@@ -809,7 +809,7 @@ COMMAND_HANDLER(max32xxx_handle_protection_set_command)
/* Mask off the top portion on the address */
addr = (addr & 0x0FFFFFFF);
- if (1 != sscanf(CMD_ARGV[2], "0x%"SCNx32, &len)) {
+ if (sscanf(CMD_ARGV[2], "0x%"SCNx32, &len) != 1) {
LOG_WARNING("Error parsing length");
command_print(CMD, "max32xxx protection_set <bank> <addr> <size>");
return ERROR_FAIL;
@@ -857,7 +857,7 @@ COMMAND_HANDLER(max32xxx_handle_protection_clr_command)
info = bank->driver_priv;
/* Convert the range to the page numbers */
- if (1 != sscanf(CMD_ARGV[1], "0x%"SCNx32, &addr)) {
+ if (sscanf(CMD_ARGV[1], "0x%"SCNx32, &addr) != 1) {
LOG_WARNING("Error parsing address");
command_print(CMD, "max32xxx protection_clr <bank> <addr> <size>");
return ERROR_FAIL;
@@ -865,7 +865,7 @@ COMMAND_HANDLER(max32xxx_handle_protection_clr_command)
/* Mask off the top portion on the address */
addr = (addr & 0x0FFFFFFF);
- if (1 != sscanf(CMD_ARGV[2], "0x%"SCNx32, &len)) {
+ if (sscanf(CMD_ARGV[2], "0x%"SCNx32, &len) != 1) {
LOG_WARNING("Error parsing length");
command_print(CMD, "max32xxx protection_clr <bank> <addr> <size>");
return ERROR_FAIL;
diff --git a/src/flash/nor/msp432.c b/src/flash/nor/msp432.c
index b418bf1..81c94b6 100644
--- a/src/flash/nor/msp432.c
+++ b/src/flash/nor/msp432.c
@@ -315,8 +315,8 @@ static int msp432_init(struct flash_bank *bank)
}
/* Issue warnings if this is a device we may not be able to flash */
- if (MSP432P401X_GUESS == msp432_bank->device_type ||
- MSP432P411X_GUESS == msp432_bank->device_type) {
+ if (msp432_bank->device_type == MSP432P401X_GUESS ||
+ msp432_bank->device_type == MSP432P411X_GUESS) {
/* Explicit device type check failed. Report this. */
LOG_WARNING(
"msp432: Unrecognized MSP432P4 Device ID and Hardware "
@@ -489,9 +489,9 @@ COMMAND_HANDLER(msp432_mass_erase_command)
all = false;
} else if (2 == CMD_ARGC) {
/* Check argument for how much to erase */
- if (0 == strcmp(CMD_ARGV[1], "main"))
+ if (strcmp(CMD_ARGV[1], "main") == 0)
all = false;
- else if (0 == strcmp(CMD_ARGV[1], "all"))
+ else if (strcmp(CMD_ARGV[1], "all") == 0)
all = true;
else
return ERROR_COMMAND_SYNTAX_ERROR;
@@ -543,9 +543,9 @@ COMMAND_HANDLER(msp432_bsl_command)
}
if (2 == CMD_ARGC) {
- if (0 == strcmp(CMD_ARGV[1], "lock"))
+ if (strcmp(CMD_ARGV[1], "lock") == 0)
msp432_bank->unlock_bsl = false;
- else if (0 == strcmp(CMD_ARGV[1], "unlock"))
+ else if (strcmp(CMD_ARGV[1], "unlock") == 0)
msp432_bank->unlock_bsl = true;
else
return ERROR_COMMAND_SYNTAX_ERROR;
@@ -597,8 +597,8 @@ static int msp432_erase(struct flash_bank *bank, unsigned int first,
struct msp432_bank *msp432_bank = bank->driver_priv;
struct msp432_algo_params algo_params;
- bool is_main = FLASH_BASE == bank->base;
- bool is_info = P4_FLASH_INFO_BASE == bank->base;
+ bool is_main = bank->base == FLASH_BASE;
+ bool is_info = bank->base == P4_FLASH_INFO_BASE;
int retval;
@@ -676,7 +676,7 @@ static int msp432_write(struct flash_bank *bank, const uint8_t *buffer,
long long start_ms;
long long elapsed_ms;
- bool is_info = P4_FLASH_INFO_BASE == bank->base;
+ bool is_info = bank->base == P4_FLASH_INFO_BASE;
int retval;
@@ -812,8 +812,8 @@ static int msp432_probe(struct flash_bank *bank)
uint32_t size;
unsigned int num_sectors;
- bool is_main = FLASH_BASE == bank->base;
- bool is_info = P4_FLASH_INFO_BASE == bank->base;
+ bool is_main = bank->base == FLASH_BASE;
+ bool is_info = bank->base == P4_FLASH_INFO_BASE;
int retval;
@@ -960,8 +960,8 @@ static int msp432_auto_probe(struct flash_bank *bank)
{
struct msp432_bank *msp432_bank = bank->driver_priv;
- bool is_main = FLASH_BASE == bank->base;
- bool is_info = P4_FLASH_INFO_BASE == bank->base;
+ bool is_main = bank->base == FLASH_BASE;
+ bool is_info = bank->base == P4_FLASH_INFO_BASE;
int retval = ERROR_OK;
@@ -1030,7 +1030,7 @@ static int msp432_protect_check(struct flash_bank *bank)
static void msp432_flash_free_driver_priv(struct flash_bank *bank)
{
- bool is_main = FLASH_BASE == bank->base;
+ bool is_main = bank->base == FLASH_BASE;
/* A single private struct is shared between main and info banks */
/* Only free it on the call for main bank */
diff --git a/src/flash/nor/tms470.c b/src/flash/nor/tms470.c
index f1eba9c..5078314 100644
--- a/src/flash/nor/tms470.c
+++ b/src/flash/nor/tms470.c
@@ -296,9 +296,9 @@ COMMAND_HANDLER(tms470_handle_flash_keyset_command)
int i;
for (i = 0; i < 4; i++) {
- int start = (0 == strncmp(CMD_ARGV[i], "0x", 2)) ? 2 : 0;
+ int start = (strncmp(CMD_ARGV[i], "0x", 2) == 0) ? 2 : 0;
- if (1 != sscanf(&CMD_ARGV[i][start], "%" SCNx32 "", &flash_keys[i])) {
+ if (sscanf(&CMD_ARGV[i][start], "%" SCNx32 "", &flash_keys[i]) != 1) {
command_print(CMD, "could not process flash key %s",
CMD_ARGV[i]);
LOG_ERROR("could not process flash key %s", CMD_ARGV[i]);