coding style: remove useless break after a goto or return
In a switch/case statement, a break placed after a goto or return
is never executed.
The script checkpatch available in Linux kernel v5.1 issues a
warning for such unused break statements.
In the process of reviewing the new checkpatch for its inclusion
in OpenOCD, let's get rid of these warnings.
The script checkpatch is unable to fixup automatically this case.
Thanks to having "break" command using a single code line, this
patch has been generated using the script below:
find src/ -type f -exec ./tools/scripts/checkpatch.pl -q \
--types UNNECESSARY_BREAK -f {} \; \
| sed -n '/^#/{s/^.*FILE: //;s/:$//;s/:/ /;p}' \
| awk 'function P() {print "sed -i '\''"b"'\'' "a};
{
if ($1!=a) {
if (a) {P()};
a=$1;
b=$2"{d}";
} else {
b=b";"$2"{d}"
}
};
END {P()}'
Change-Id: I56ca098faa5fe8d1e3f712dc0a029a3f10559d99
Signed-off-by: Antonio Borneo <borneo.antonio@gmail.com>
Reviewed-on: http://openocd.zylin.com/5617
Reviewed-by: Andreas Fritiofson <andreas.fritiofson@gmail.com>
Tested-by: jenkins
This commit is contained in:
@@ -685,7 +685,6 @@ static int do_data_output(struct nand_device *nand)
|
||||
case 2 << 2:
|
||||
LOG_DEBUG("main area readed with more than 1 (incorrectable) error");
|
||||
return ERROR_NAND_OPERATION_FAILED;
|
||||
break;
|
||||
}
|
||||
switch (ecc_status & 0x0003) {
|
||||
case 1:
|
||||
@@ -694,7 +693,6 @@ static int do_data_output(struct nand_device *nand)
|
||||
case 2:
|
||||
LOG_DEBUG("main area readed with more than 1 (incorrectable) error");
|
||||
return ERROR_NAND_OPERATION_FAILED;
|
||||
break;
|
||||
}
|
||||
}
|
||||
break;
|
||||
|
||||
@@ -874,7 +874,6 @@ int ecc_status_v1(struct nand_device *nand)
|
||||
case 2 << 2:
|
||||
LOG_INFO("main area read with more than 1 (incorrectable) error");
|
||||
return ERROR_NAND_OPERATION_FAILED;
|
||||
break;
|
||||
}
|
||||
switch (ecc_status & 0x0003) {
|
||||
case 1:
|
||||
@@ -883,7 +882,6 @@ int ecc_status_v1(struct nand_device *nand)
|
||||
case 2:
|
||||
LOG_INFO("main area read with more than 1 (incorrectable) error");
|
||||
return ERROR_NAND_OPERATION_FAILED;
|
||||
break;
|
||||
}
|
||||
return ERROR_OK;
|
||||
}
|
||||
|
||||
@@ -434,10 +434,8 @@ static int aducm360_write_block(struct flash_bank *bank,
|
||||
switch (choice) {
|
||||
case 0:
|
||||
return aducm360_write_block_sync(bank, buffer, offset, count);
|
||||
break;
|
||||
case 1:
|
||||
return aducm360_write_block_async(bank, buffer, offset, count);
|
||||
break;
|
||||
default:
|
||||
LOG_ERROR("aducm360_write_block was cancelled (no writing method was chosen)!");
|
||||
return ERROR_TARGET_RESOURCE_NOT_AVAILABLE;
|
||||
|
||||
@@ -3068,7 +3068,6 @@ FLASH_BANK_COMMAND_HANDLER(sam3_flash_bank_command)
|
||||
((unsigned int)(FLASH_BANK1_BASE_256K_AX)),
|
||||
((unsigned int)(FLASH_BANK1_BASE_512K_AX)));
|
||||
return ERROR_FAIL;
|
||||
break;
|
||||
|
||||
/* at91sam3s and at91sam3n series only has bank 0*/
|
||||
/* at91sam3u and at91sam3ax series has the same address for bank 0*/
|
||||
@@ -3621,10 +3620,8 @@ COMMAND_HANDLER(sam3_handle_gpnvm_command)
|
||||
switch (CMD_ARGC) {
|
||||
default:
|
||||
return ERROR_COMMAND_SYNTAX_ERROR;
|
||||
break;
|
||||
case 0:
|
||||
goto showall;
|
||||
break;
|
||||
case 1:
|
||||
who = -1;
|
||||
break;
|
||||
@@ -3708,7 +3705,6 @@ COMMAND_HANDLER(sam3_handle_slowclk_command)
|
||||
/* error */
|
||||
command_print(CMD, "Too many parameters");
|
||||
return ERROR_COMMAND_SYNTAX_ERROR;
|
||||
break;
|
||||
}
|
||||
command_print(CMD, "Slowclk freq: %d.%03dkhz",
|
||||
(int)(pChip->cfg.slow_freq / 1000),
|
||||
|
||||
@@ -2482,7 +2482,6 @@ FLASH_BANK_COMMAND_HANDLER(sam4_flash_bank_command)
|
||||
((unsigned int)(bank->base)),
|
||||
((unsigned int)(FLASH_BANK_BASE_S)));
|
||||
return ERROR_FAIL;
|
||||
break;
|
||||
|
||||
/* at91sam4s series only has bank 0*/
|
||||
/* at91sam4sd series has the same address for bank 0 (FLASH_BANK0_BASE_SD)*/
|
||||
@@ -3101,10 +3100,8 @@ COMMAND_HANDLER(sam4_handle_gpnvm_command)
|
||||
switch (CMD_ARGC) {
|
||||
default:
|
||||
return ERROR_COMMAND_SYNTAX_ERROR;
|
||||
break;
|
||||
case 0:
|
||||
goto showall;
|
||||
break;
|
||||
case 1:
|
||||
who = -1;
|
||||
break;
|
||||
@@ -3188,7 +3185,6 @@ COMMAND_HANDLER(sam4_handle_slowclk_command)
|
||||
/* error */
|
||||
command_print(CMD, "Too many parameters");
|
||||
return ERROR_COMMAND_SYNTAX_ERROR;
|
||||
break;
|
||||
}
|
||||
command_print(CMD, "Slowclk freq: %d.%03dkhz",
|
||||
(int)(pChip->cfg.slow_freq / 1000),
|
||||
|
||||
@@ -375,7 +375,6 @@ static int samv_probe(struct flash_bank *bank)
|
||||
default:
|
||||
LOG_ERROR("unrecognized flash size code: %d", nvm_size_code);
|
||||
return ERROR_FAIL;
|
||||
break;
|
||||
}
|
||||
|
||||
struct samv_flash_bank *samv_info = bank->driver_priv;
|
||||
@@ -645,7 +644,6 @@ COMMAND_HANDLER(samv_handle_gpnvm_command)
|
||||
switch (CMD_ARGC) {
|
||||
case 0:
|
||||
goto showall;
|
||||
break;
|
||||
case 1:
|
||||
who = -1;
|
||||
break;
|
||||
@@ -660,7 +658,6 @@ COMMAND_HANDLER(samv_handle_gpnvm_command)
|
||||
break;
|
||||
default:
|
||||
return ERROR_COMMAND_SYNTAX_ERROR;
|
||||
break;
|
||||
}
|
||||
|
||||
uint32_t v;
|
||||
|
||||
@@ -989,10 +989,8 @@ int cfi_erase(struct flash_bank *bank, int first, int last)
|
||||
case 1:
|
||||
case 3:
|
||||
return cfi_intel_erase(bank, first, last);
|
||||
break;
|
||||
case 2:
|
||||
return cfi_spansion_erase(bank, first, last);
|
||||
break;
|
||||
default:
|
||||
LOG_ERROR("cfi primary command set %i unsupported", cfi_info->pri_id);
|
||||
break;
|
||||
@@ -1128,7 +1126,6 @@ int cfi_protect(struct flash_bank *bank, int set, int first, int last)
|
||||
case 1:
|
||||
case 3:
|
||||
return cfi_intel_protect(bank, set, first, last);
|
||||
break;
|
||||
default:
|
||||
LOG_WARNING("protect: cfi primary command set %i unsupported", cfi_info->pri_id);
|
||||
return ERROR_OK;
|
||||
@@ -1144,13 +1141,10 @@ static uint32_t cfi_command_val(struct flash_bank *bank, uint8_t cmd)
|
||||
switch (bank->bus_width) {
|
||||
case 1:
|
||||
return buf[0];
|
||||
break;
|
||||
case 2:
|
||||
return target_buffer_get_u16(target, buf);
|
||||
break;
|
||||
case 4:
|
||||
return target_buffer_get_u32(target, buf);
|
||||
break;
|
||||
default:
|
||||
LOG_ERROR("Unsupported bank buswidth %d, can't do block memory writes",
|
||||
bank->bus_width);
|
||||
@@ -2222,10 +2216,8 @@ int cfi_write_word(struct flash_bank *bank, uint8_t *word, uint32_t address)
|
||||
case 1:
|
||||
case 3:
|
||||
return cfi_intel_write_word(bank, word, address);
|
||||
break;
|
||||
case 2:
|
||||
return cfi_spansion_write_word(bank, word, address);
|
||||
break;
|
||||
default:
|
||||
LOG_ERROR("cfi primary command set %i unsupported", cfi_info->pri_id);
|
||||
break;
|
||||
@@ -2249,10 +2241,8 @@ static int cfi_write_words(struct flash_bank *bank, const uint8_t *word,
|
||||
case 1:
|
||||
case 3:
|
||||
return cfi_intel_write_words(bank, word, wordcount, address);
|
||||
break;
|
||||
case 2:
|
||||
return cfi_spansion_write_words(bank, word, wordcount, address);
|
||||
break;
|
||||
default:
|
||||
LOG_ERROR("cfi primary command set %i unsupported", cfi_info->pri_id);
|
||||
break;
|
||||
@@ -2998,10 +2988,8 @@ int cfi_protect_check(struct flash_bank *bank)
|
||||
case 1:
|
||||
case 3:
|
||||
return cfi_intel_protect_check(bank);
|
||||
break;
|
||||
case 2:
|
||||
return cfi_spansion_protect_check(bank);
|
||||
break;
|
||||
default:
|
||||
LOG_ERROR("cfi primary command set %i unsupported", cfi_info->pri_id);
|
||||
break;
|
||||
|
||||
@@ -481,20 +481,15 @@ static const char *protection_to_str(uint8_t protection)
|
||||
switch (protection) {
|
||||
case PROTECTION_VIRGIN:
|
||||
return "VIRGIN";
|
||||
break;
|
||||
case PROTECTION_NORMAL:
|
||||
return "NORMAL";
|
||||
break;
|
||||
case PROTECTION_SECURE:
|
||||
return "SECURE";
|
||||
break;
|
||||
case PROTECTION_DEAD:
|
||||
return "DEAD";
|
||||
break;
|
||||
case PROTECTION_UNKNOWN:
|
||||
default:
|
||||
return "UNKNOWN";
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -625,7 +625,6 @@ static int xcf_probe(struct flash_bank *bank)
|
||||
default:
|
||||
LOG_ERROR("Unknown flash device ID 0x%X", id);
|
||||
return ERROR_FAIL;
|
||||
break;
|
||||
}
|
||||
|
||||
bank->sectors = malloc(bank->num_sectors * sizeof(struct flash_sector));
|
||||
|
||||
Reference in New Issue
Block a user