aboutsummaryrefslogtreecommitdiff
path: root/src/flash/nor/xcf.c
diff options
context:
space:
mode:
authorAntonio Borneo <borneo.antonio@gmail.com>2021-07-03 16:47:35 +0200
committerAntonio Borneo <borneo.antonio@gmail.com>2021-07-20 14:55:24 +0100
commit28c24a5c41c47a66e9310912f88148814f730a25 (patch)
tree803cf52a0c8f5a0687f5c7fef402b08cf337ebac /src/flash/nor/xcf.c
parentbba48b057cdc4f26721e06a5310652dcf0e55873 (diff)
downloadriscv-openocd-28c24a5c41c47a66e9310912f88148814f730a25.zip
riscv-openocd-28c24a5c41c47a66e9310912f88148814f730a25.tar.gz
riscv-openocd-28c24a5c41c47a66e9310912f88148814f730a25.tar.bz2
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>
Diffstat (limited to 'src/flash/nor/xcf.c')
-rw-r--r--src/flash/nor/xcf.c22
1 files changed, 11 insertions, 11 deletions
diff --git a/src/flash/nor/xcf.c b/src/flash/nor/xcf.c
index 1220a1e..1a37e9c 100644
--- a/src/flash/nor/xcf.c
+++ b/src/flash/nor/xcf.c
@@ -475,7 +475,7 @@ static int read_write_data(struct flash_bank *bank, const uint8_t *w_buffer,
w_buffer += len;
sector_bytes -= len;
ret = isc_program_data_page(bank, page_buf);
- if (ERROR_OK != ret)
+ if (ret != ERROR_OK)
goto EXIT;
else {
LOG_DEBUG("written %d bytes from %d", dbg_written, dbg_count);
@@ -494,7 +494,7 @@ static int read_write_data(struct flash_bank *bank, const uint8_t *w_buffer,
if (write_flag) {
for (unsigned int i = 0; i < bank->num_sectors; i++) {
ret = isc_set_data_done(bank, i);
- if (ERROR_OK != ret)
+ if (ret != ERROR_OK)
goto EXIT;
}
}
@@ -755,7 +755,7 @@ COMMAND_HANDLER(xcf_handle_ccb_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;
uint16_t ccb = 0xFFFF;
@@ -800,29 +800,29 @@ COMMAND_HANDLER(xcf_handle_ccb_command) {
sector = gucr_num(bank);
isc_clear_protect(bank, sector, sector);
int ret = isc_erase_sectors(bank, sector, sector);
- if (ERROR_OK != ret)
+ if (ret != ERROR_OK)
goto EXIT;
ret = isc_program_ccb(bank, ccb);
- if (ERROR_OK != ret)
+ if (ret != ERROR_OK)
goto EXIT;
ret = isc_program_single_revision_btc(bank);
- if (ERROR_OK != ret)
+ if (ret != ERROR_OK)
goto EXIT;
ret = isc_set_data_done(bank, sector);
- if (ERROR_OK != ret)
+ if (ret != ERROR_OK)
goto EXIT;
/* SUCR sector */
sector = sucr_num(bank);
isc_clear_protect(bank, sector, sector);
ret = isc_erase_sectors(bank, sector, sector);
- if (ERROR_OK != ret)
+ if (ret != ERROR_OK)
goto EXIT;
ret = isc_program_singe_revision_sucr(bank);
- if (ERROR_OK != ret)
+ if (ret != ERROR_OK)
goto EXIT;
ret = isc_set_data_done(bank, sector);
- if (ERROR_OK != ret)
+ if (ret != ERROR_OK)
goto EXIT;
EXIT:
@@ -838,7 +838,7 @@ COMMAND_HANDLER(xcf_handle_configure_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;
return fpga_configure(bank);