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:
Antonio Borneo 2019-05-06 00:03:03 +02:00
parent 5df5e89cf3
commit 9b29cb58ac
18 changed files with 0 additions and 68 deletions

View File

@ -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;

View File

@ -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;
}

View File

@ -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;

View File

@ -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),

View File

@ -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),

View File

@ -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;

View File

@ -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;

View File

@ -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;
}
}

View File

@ -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));

View File

@ -2677,7 +2677,6 @@ static int stlink_speed(void *handle, int khz, bool query)
switch (h->transport) {
case HL_TRANSPORT_SWIM:
return stlink_speed_swim(handle, khz, query);
break;
case HL_TRANSPORT_SWD:
if (h->version.jtag_api == STLINK_JTAG_API_V3)
return stlink_speed_v3(handle, false, khz, query);

View File

@ -765,58 +765,40 @@ static const char *ulink_cmd_id_string(uint8_t id)
switch (id) {
case CMD_SCAN_IN:
return "CMD_SCAN_IN";
break;
case CMD_SLOW_SCAN_IN:
return "CMD_SLOW_SCAN_IN";
break;
case CMD_SCAN_OUT:
return "CMD_SCAN_OUT";
break;
case CMD_SLOW_SCAN_OUT:
return "CMD_SLOW_SCAN_OUT";
break;
case CMD_SCAN_IO:
return "CMD_SCAN_IO";
break;
case CMD_SLOW_SCAN_IO:
return "CMD_SLOW_SCAN_IO";
break;
case CMD_CLOCK_TMS:
return "CMD_CLOCK_TMS";
break;
case CMD_SLOW_CLOCK_TMS:
return "CMD_SLOW_CLOCK_TMS";
break;
case CMD_CLOCK_TCK:
return "CMD_CLOCK_TCK";
break;
case CMD_SLOW_CLOCK_TCK:
return "CMD_SLOW_CLOCK_TCK";
break;
case CMD_SLEEP_US:
return "CMD_SLEEP_US";
break;
case CMD_SLEEP_MS:
return "CMD_SLEEP_MS";
break;
case CMD_GET_SIGNALS:
return "CMD_GET_SIGNALS";
break;
case CMD_SET_SIGNALS:
return "CMD_SET_SIGNALS";
break;
case CMD_CONFIGURE_TCK_FREQ:
return "CMD_CONFIGURE_TCK_FREQ";
break;
case CMD_SET_LEDS:
return "CMD_SET_LEDS";
break;
case CMD_TEST:
return "CMD_TEST";
break;
default:
return "CMD_UNKNOWN";
break;
}
}

View File

@ -1310,7 +1310,6 @@ XXR_common:
case PIOMAP:
LOG_ERROR("PIO and PIOMAP are not supported");
return ERROR_FAIL;
break;
case RUNTEST:
/* RUNTEST [run_state] run_count run_clk [min_time SEC [MAXIMUM max_time
* SEC]] [ENDSTATE end_state] */
@ -1532,7 +1531,6 @@ XXR_common:
default:
LOG_ERROR("invalid svf command: %s", argus[0]);
return ERROR_FAIL;
break;
}
if (!svf_quiet) {

View File

@ -2309,7 +2309,6 @@ static int evaluate_data_proc_thumb(uint16_t opcode,
address, opcode);
}
return ERROR_OK;
break;
}
} else {
switch (op) {

View File

@ -212,7 +212,6 @@ int arm_dpm_read_reg(struct arm_dpm *dpm, struct reg *r, unsigned regnum)
break;
case ARM_VFP_V3_D0 ... ARM_VFP_V3_D31:
return dpm_read_reg_u64(dpm, r, regnum);
break;
case ARM_VFP_V3_FPSCR:
/* "VMRS r0, FPSCR"; then return via DCC */
retval = dpm->instr_read_data_r0(dpm,
@ -294,7 +293,6 @@ static int dpm_write_reg(struct arm_dpm *dpm, struct reg *r, unsigned regnum)
break;
case ARM_VFP_V3_D0 ... ARM_VFP_V3_D31:
return dpm_write_reg_u64(dpm, r, regnum);
break;
case ARM_VFP_V3_FPSCR:
/* move to r0 from DCC, then "VMSR FPSCR, r0" */
retval = dpm->instr_write_data_r0(dpm,

View File

@ -1223,7 +1223,6 @@ int arm_get_gdb_reg_list(struct target *target,
(*reg_list)[25] = arm->cpsr;
return ERROR_OK;
break;
case REG_CLASS_ALL:
switch (arm->core_type) {
@ -1273,12 +1272,10 @@ int arm_get_gdb_reg_list(struct target *target,
}
return ERROR_OK;
break;
default:
LOG_ERROR("not a valid register class type in query.");
return ERROR_FAIL;
break;
}
}

View File

@ -464,7 +464,6 @@ static int avr32_ap7k_read_memory(struct target *target, target_addr_t address,
break;
case 1:
return avr32_jtag_read_memory8(&ap7k->jtag, address, count, buffer);
break;
default:
break;
}
@ -505,7 +504,6 @@ static int avr32_ap7k_write_memory(struct target *target, target_addr_t address,
break;
case 1:
return avr32_jtag_write_memory8(&ap7k->jtag, address, count, buffer);
break;
default:
break;
}

View File

@ -666,10 +666,8 @@ uint32_t abstract_register_size(unsigned width)
return set_field(0, AC_ACCESS_REGISTER_SIZE, 2);
case 64:
return set_field(0, AC_ACCESS_REGISTER_SIZE, 3);
break;
case 128:
return set_field(0, AC_ACCESS_REGISTER_SIZE, 4);
break;
default:
LOG_ERROR("Unsupported register width: %d", width);
return 0;

View File

@ -290,7 +290,6 @@ static int jim_transport_select(Jim_Interp *interp, int argc, Jim_Obj * const *a
}
Jim_SetResultString(interp, session->name, -1);
return JIM_OK;
break;
case 2: /* assign */
if (session) {
if (!strcmp(session->name, argv[1]->bytes)) {
@ -327,7 +326,6 @@ static int jim_transport_select(Jim_Interp *interp, int argc, Jim_Obj * const *a
LOG_ERROR("Debug adapter doesn't support '%s' transport", argv[1]->bytes);
return JIM_ERR;
break;
default:
Jim_WrongNumArgs(interp, 1, argv, "[too many parameters]");
return JIM_ERR;