forked from auracaster/openocd
openocd: fix simple cases of Yoda condition
There are ~900 Yoda conditions to be aligned to the coding style.
For recurrent Yoda conditions it's preferable using a trivial
script in order to minimize the review effort.
E.g. comparison of uppercase macro/enum with lowercase variable:
- ...(ERROR_OK == retval)...
+ ...(retval == ERROR_OK)...
Patch generated automatically with the command:
sed -i \
's/(\([A-Z][A-Z0-9_]*\) \([=!]=\) \([a-z][a-z0-9_]*\))/(\3 \2 \1)/g' \
$(find src/ -type f)
While there, remove the braces {} around a single statement block
to prevent warning from checkpatch.
Change-Id: If585b0a4b4578879c87b2dd74d9e0025e275ec6b
Signed-off-by: Antonio Borneo <borneo.antonio@gmail.com>
Reviewed-on: http://openocd.zylin.com/6354
Tested-by: jenkins
Reviewed-by: Xiang W <wxjstz@126.com>
This commit is contained in:
@@ -349,7 +349,7 @@ static int stm32x_protect_check(struct flash_bank *bank)
|
||||
uint32_t protection;
|
||||
|
||||
int retval = stm32x_check_operation_supported(bank);
|
||||
if (ERROR_OK != retval)
|
||||
if (retval != ERROR_OK)
|
||||
return retval;
|
||||
|
||||
/* medium density - each bit refers to a 4 sector protection block
|
||||
@@ -1197,7 +1197,7 @@ COMMAND_HANDLER(stm32x_handle_lock_command)
|
||||
|
||||
struct flash_bank *bank;
|
||||
int retval = CALL_COMMAND_HANDLER(flash_command_get_bank, 0, &bank);
|
||||
if (ERROR_OK != retval)
|
||||
if (retval != ERROR_OK)
|
||||
return retval;
|
||||
|
||||
stm32x_info = bank->driver_priv;
|
||||
@@ -1210,7 +1210,7 @@ COMMAND_HANDLER(stm32x_handle_lock_command)
|
||||
}
|
||||
|
||||
retval = stm32x_check_operation_supported(bank);
|
||||
if (ERROR_OK != retval)
|
||||
if (retval != ERROR_OK)
|
||||
return retval;
|
||||
|
||||
if (stm32x_erase_options(bank) != ERROR_OK) {
|
||||
@@ -1240,7 +1240,7 @@ COMMAND_HANDLER(stm32x_handle_unlock_command)
|
||||
|
||||
struct flash_bank *bank;
|
||||
int retval = CALL_COMMAND_HANDLER(flash_command_get_bank, 0, &bank);
|
||||
if (ERROR_OK != retval)
|
||||
if (retval != ERROR_OK)
|
||||
return retval;
|
||||
|
||||
target = bank->target;
|
||||
@@ -1251,7 +1251,7 @@ COMMAND_HANDLER(stm32x_handle_unlock_command)
|
||||
}
|
||||
|
||||
retval = stm32x_check_operation_supported(bank);
|
||||
if (ERROR_OK != retval)
|
||||
if (retval != ERROR_OK)
|
||||
return retval;
|
||||
|
||||
if (stm32x_erase_options(bank) != ERROR_OK) {
|
||||
@@ -1282,7 +1282,7 @@ COMMAND_HANDLER(stm32x_handle_options_read_command)
|
||||
|
||||
struct flash_bank *bank;
|
||||
int retval = CALL_COMMAND_HANDLER(flash_command_get_bank, 0, &bank);
|
||||
if (ERROR_OK != retval)
|
||||
if (retval != ERROR_OK)
|
||||
return retval;
|
||||
|
||||
stm32x_info = bank->driver_priv;
|
||||
@@ -1295,7 +1295,7 @@ COMMAND_HANDLER(stm32x_handle_options_read_command)
|
||||
}
|
||||
|
||||
retval = stm32x_check_operation_supported(bank);
|
||||
if (ERROR_OK != retval)
|
||||
if (retval != ERROR_OK)
|
||||
return retval;
|
||||
|
||||
retval = target_read_u32(target, STM32_FLASH_OBR_B0, &optionbyte);
|
||||
@@ -1349,7 +1349,7 @@ COMMAND_HANDLER(stm32x_handle_options_write_command)
|
||||
|
||||
struct flash_bank *bank;
|
||||
int retval = CALL_COMMAND_HANDLER(flash_command_get_bank, 0, &bank);
|
||||
if (ERROR_OK != retval)
|
||||
if (retval != ERROR_OK)
|
||||
return retval;
|
||||
|
||||
stm32x_info = bank->driver_priv;
|
||||
@@ -1362,11 +1362,11 @@ COMMAND_HANDLER(stm32x_handle_options_write_command)
|
||||
}
|
||||
|
||||
retval = stm32x_check_operation_supported(bank);
|
||||
if (ERROR_OK != retval)
|
||||
if (retval != ERROR_OK)
|
||||
return retval;
|
||||
|
||||
retval = stm32x_read_options(bank);
|
||||
if (ERROR_OK != retval)
|
||||
if (retval != ERROR_OK)
|
||||
return retval;
|
||||
|
||||
/* start with current options */
|
||||
@@ -1438,7 +1438,7 @@ COMMAND_HANDLER(stm32x_handle_options_load_command)
|
||||
|
||||
struct flash_bank *bank;
|
||||
int retval = CALL_COMMAND_HANDLER(flash_command_get_bank, 0, &bank);
|
||||
if (ERROR_OK != retval)
|
||||
if (retval != ERROR_OK)
|
||||
return retval;
|
||||
|
||||
struct stm32x_flash_bank *stm32x_info = bank->driver_priv;
|
||||
@@ -1457,7 +1457,7 @@ COMMAND_HANDLER(stm32x_handle_options_load_command)
|
||||
}
|
||||
|
||||
retval = stm32x_check_operation_supported(bank);
|
||||
if (ERROR_OK != retval)
|
||||
if (retval != ERROR_OK)
|
||||
return retval;
|
||||
|
||||
/* unlock option flash registers */
|
||||
@@ -1520,7 +1520,7 @@ COMMAND_HANDLER(stm32x_handle_mass_erase_command)
|
||||
|
||||
struct flash_bank *bank;
|
||||
int retval = CALL_COMMAND_HANDLER(flash_command_get_bank, 0, &bank);
|
||||
if (ERROR_OK != retval)
|
||||
if (retval != ERROR_OK)
|
||||
return retval;
|
||||
|
||||
retval = stm32x_mass_erase(bank);
|
||||
|
||||
Reference in New Issue
Block a user