helper: align switch and case statements

The coding style requires the 'case' to be at the same indentation
level of its 'switch' statement.

Align the code accordingly.

No changes are reported by
	git log -p -w --ignore-blank-lines --patience

Change-Id: Iea3b60b3f01afbe31c495e8ea4ddc2b4c8efa936
Signed-off-by: Antonio Borneo <borneo.antonio@gmail.com>
Reviewed-on: https://review.openocd.org/c/openocd/+/9010
Tested-by: jenkins
This commit is contained in:
Antonio Borneo
2025-06-28 14:27:15 +02:00
parent d10c839596
commit d123cfdc58
3 changed files with 101 additions and 101 deletions
+45 -45
View File
@@ -401,16 +401,16 @@ static bool command_can_run(struct command_context *cmd_ctx, struct command *c,
/* Many commands may be run only before/after 'init' */ /* Many commands may be run only before/after 'init' */
const char *when; const char *when;
switch (c->mode) { switch (c->mode) {
case COMMAND_CONFIG: case COMMAND_CONFIG:
when = "before"; when = "before";
break; break;
case COMMAND_EXEC: case COMMAND_EXEC:
when = "after"; when = "after";
break; break;
/* handle the impossible with humor; it guarantees a bug report! */ /* handle the impossible with humor; it guarantees a bug report! */
default: default:
when = "if Cthulhu is summoned by"; when = "if Cthulhu is summoned by";
break; break;
} }
LOG_ERROR("The '%s' command must be used %s 'init'.", LOG_ERROR("The '%s' command must be used %s 'init'.",
full_name ? full_name : c->name, when); full_name ? full_name : c->name, when);
@@ -732,16 +732,16 @@ static COMMAND_HELPER(command_help_show, struct help_entry *c,
const char *stage_msg = ""; const char *stage_msg = "";
switch (mode) { switch (mode) {
case COMMAND_CONFIG: case COMMAND_CONFIG:
stage_msg = " (configuration command)"; stage_msg = " (configuration command)";
break; break;
case COMMAND_ANY: case COMMAND_ANY:
stage_msg = " (command valid any time)"; stage_msg = " (command valid any time)";
break; break;
case COMMAND_UNKNOWN: case COMMAND_UNKNOWN:
default: default:
stage_msg = " (?mode error?)"; stage_msg = " (?mode error?)";
break; break;
} }
msg = alloc_printf("%s%s", c->help ? c->help : "", stage_msg); msg = alloc_printf("%s%s", c->help ? c->help : "", stage_msg);
} else } else
@@ -902,19 +902,19 @@ COMMAND_HANDLER(handle_command_mode)
const char *mode_str; const char *mode_str;
switch (mode) { switch (mode) {
case COMMAND_ANY: case COMMAND_ANY:
mode_str = "any"; mode_str = "any";
break; break;
case COMMAND_CONFIG: case COMMAND_CONFIG:
mode_str = "config"; mode_str = "config";
break; break;
case COMMAND_EXEC: case COMMAND_EXEC:
mode_str = "exec"; mode_str = "exec";
break; break;
case COMMAND_UNKNOWN: case COMMAND_UNKNOWN:
default: default:
mode_str = "unknown"; mode_str = "unknown";
break; break;
} }
command_print(CMD, "%s", mode_str); command_print(CMD, "%s", mode_str);
return ERROR_OK; return ERROR_OK;
@@ -1319,19 +1319,19 @@ COMMAND_HELPER(command_parse_str_to_buf, const char *str, void *buf, unsigned in
COMMAND_HELPER(handle_command_parse_bool, bool *out, const char *label) COMMAND_HELPER(handle_command_parse_bool, bool *out, const char *label)
{ {
switch (CMD_ARGC) { switch (CMD_ARGC) {
case 1: { case 1: {
const char *in = CMD_ARGV[0]; const char *in = CMD_ARGV[0];
if (command_parse_bool_arg(in, out) != ERROR_OK) { if (command_parse_bool_arg(in, out) != ERROR_OK) {
LOG_ERROR("%s: argument '%s' is not valid", CMD_NAME, in); LOG_ERROR("%s: argument '%s' is not valid", CMD_NAME, in);
return ERROR_COMMAND_SYNTAX_ERROR;
}
}
/* fallthrough */
case 0:
LOG_INFO("%s is %s", label, *out ? "enabled" : "disabled");
break;
default:
return ERROR_COMMAND_SYNTAX_ERROR; return ERROR_COMMAND_SYNTAX_ERROR;
}
}
/* fallthrough */
case 0:
LOG_INFO("%s is %s", label, *out ? "enabled" : "disabled");
break;
default:
return ERROR_COMMAND_SYNTAX_ERROR;
} }
return ERROR_OK; return ERROR_OK;
} }
+18 -18
View File
@@ -49,24 +49,24 @@ static inline int fileio_open_local(struct fileio *fileio)
ssize_t file_size; ssize_t file_size;
switch (fileio->access) { switch (fileio->access) {
case FILEIO_READ: case FILEIO_READ:
strcpy(file_access, "r"); strcpy(file_access, "r");
break; break;
case FILEIO_WRITE: case FILEIO_WRITE:
strcpy(file_access, "w"); strcpy(file_access, "w");
break; break;
case FILEIO_READWRITE: case FILEIO_READWRITE:
strcpy(file_access, "w+"); strcpy(file_access, "w+");
break; break;
case FILEIO_APPEND: case FILEIO_APPEND:
strcpy(file_access, "a"); strcpy(file_access, "a");
break; break;
case FILEIO_APPENDREAD: case FILEIO_APPENDREAD:
strcpy(file_access, "a+"); strcpy(file_access, "a+");
break; break;
default: default:
LOG_ERROR("BUG: access neither read, write nor readwrite"); LOG_ERROR("BUG: access neither read, write nor readwrite");
return ERROR_COMMAND_SYNTAX_ERROR; return ERROR_COMMAND_SYNTAX_ERROR;
} }
/* win32 always opens in binary mode */ /* win32 always opens in binary mode */
+38 -38
View File
@@ -277,44 +277,44 @@ int parse_cmdline_args(struct command_context *cmd_ctx, int argc, char *argv[])
break; break;
switch (c) { switch (c) {
case 0: case 0:
break; break;
case 'h': /* --help | -h */ case 'h': /* --help | -h */
help_flag = 1; help_flag = 1;
break; break;
case 'v': /* --version | -v */ case 'v': /* --version | -v */
version_flag = 1; version_flag = 1;
break; break;
case 'f': /* --file | -f */ case 'f': /* --file | -f */
{ {
char *command = alloc_printf("script {%s}", optarg); char *command = alloc_printf("script {%s}", optarg);
add_config_command(command); add_config_command(command);
free(command); free(command);
break; break;
} }
case 's': /* --search | -s */ case 's': /* --search | -s */
add_script_search_dir(optarg); add_script_search_dir(optarg);
break; break;
case 'd': /* --debug | -d */ case 'd': /* --debug | -d */
{ {
int retval = command_run_linef(cmd_ctx, "debug_level %s", optarg ? optarg : "3"); int retval = command_run_linef(cmd_ctx, "debug_level %s", optarg ? optarg : "3");
if (retval != ERROR_OK) if (retval != ERROR_OK)
return retval; return retval;
break; break;
} }
case 'l': /* --log_output | -l */ case 'l': /* --log_output | -l */
{ {
int retval = command_run_linef(cmd_ctx, "log_output %s", optarg); int retval = command_run_linef(cmd_ctx, "log_output %s", optarg);
if (retval != ERROR_OK) if (retval != ERROR_OK)
return retval; return retval;
break; break;
} }
case 'c': /* --command | -c */ case 'c': /* --command | -c */
add_config_command(optarg); add_config_command(optarg);
break; break;
default: /* '?' */ default: /* '?' */
/* getopt will emit an error message, all we have to do is bail. */ /* getopt will emit an error message, all we have to do is bail. */
return ERROR_FAIL; return ERROR_FAIL;
} }
} }