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

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' */
const char *when;
switch (c->mode) {
case COMMAND_CONFIG:
when = "before";
break;
case COMMAND_EXEC:
when = "after";
break;
/* handle the impossible with humor; it guarantees a bug report! */
default:
when = "if Cthulhu is summoned by";
break;
case COMMAND_CONFIG:
when = "before";
break;
case COMMAND_EXEC:
when = "after";
break;
/* handle the impossible with humor; it guarantees a bug report! */
default:
when = "if Cthulhu is summoned by";
break;
}
LOG_ERROR("The '%s' command must be used %s 'init'.",
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 = "";
switch (mode) {
case COMMAND_CONFIG:
stage_msg = " (configuration command)";
break;
case COMMAND_ANY:
stage_msg = " (command valid any time)";
break;
case COMMAND_UNKNOWN:
default:
stage_msg = " (?mode error?)";
break;
case COMMAND_CONFIG:
stage_msg = " (configuration command)";
break;
case COMMAND_ANY:
stage_msg = " (command valid any time)";
break;
case COMMAND_UNKNOWN:
default:
stage_msg = " (?mode error?)";
break;
}
msg = alloc_printf("%s%s", c->help ? c->help : "", stage_msg);
} else
@@ -902,19 +902,19 @@ COMMAND_HANDLER(handle_command_mode)
const char *mode_str;
switch (mode) {
case COMMAND_ANY:
mode_str = "any";
break;
case COMMAND_CONFIG:
mode_str = "config";
break;
case COMMAND_EXEC:
mode_str = "exec";
break;
case COMMAND_UNKNOWN:
default:
mode_str = "unknown";
break;
case COMMAND_ANY:
mode_str = "any";
break;
case COMMAND_CONFIG:
mode_str = "config";
break;
case COMMAND_EXEC:
mode_str = "exec";
break;
case COMMAND_UNKNOWN:
default:
mode_str = "unknown";
break;
}
command_print(CMD, "%s", mode_str);
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)
{
switch (CMD_ARGC) {
case 1: {
const char *in = CMD_ARGV[0];
if (command_parse_bool_arg(in, out) != ERROR_OK) {
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:
case 1: {
const char *in = CMD_ARGV[0];
if (command_parse_bool_arg(in, out) != ERROR_OK) {
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_OK;
}

View File

@@ -49,24 +49,24 @@ static inline int fileio_open_local(struct fileio *fileio)
ssize_t file_size;
switch (fileio->access) {
case FILEIO_READ:
strcpy(file_access, "r");
break;
case FILEIO_WRITE:
strcpy(file_access, "w");
break;
case FILEIO_READWRITE:
strcpy(file_access, "w+");
break;
case FILEIO_APPEND:
strcpy(file_access, "a");
break;
case FILEIO_APPENDREAD:
strcpy(file_access, "a+");
break;
default:
LOG_ERROR("BUG: access neither read, write nor readwrite");
return ERROR_COMMAND_SYNTAX_ERROR;
case FILEIO_READ:
strcpy(file_access, "r");
break;
case FILEIO_WRITE:
strcpy(file_access, "w");
break;
case FILEIO_READWRITE:
strcpy(file_access, "w+");
break;
case FILEIO_APPEND:
strcpy(file_access, "a");
break;
case FILEIO_APPENDREAD:
strcpy(file_access, "a+");
break;
default:
LOG_ERROR("BUG: access neither read, write nor readwrite");
return ERROR_COMMAND_SYNTAX_ERROR;
}
/* win32 always opens in binary mode */

View File

@@ -277,44 +277,44 @@ int parse_cmdline_args(struct command_context *cmd_ctx, int argc, char *argv[])
break;
switch (c) {
case 0:
break;
case 'h': /* --help | -h */
help_flag = 1;
break;
case 'v': /* --version | -v */
version_flag = 1;
break;
case 'f': /* --file | -f */
{
char *command = alloc_printf("script {%s}", optarg);
add_config_command(command);
free(command);
break;
}
case 's': /* --search | -s */
add_script_search_dir(optarg);
break;
case 'd': /* --debug | -d */
{
int retval = command_run_linef(cmd_ctx, "debug_level %s", optarg ? optarg : "3");
if (retval != ERROR_OK)
return retval;
break;
}
case 'l': /* --log_output | -l */
{
int retval = command_run_linef(cmd_ctx, "log_output %s", optarg);
if (retval != ERROR_OK)
return retval;
break;
}
case 'c': /* --command | -c */
add_config_command(optarg);
break;
default: /* '?' */
/* getopt will emit an error message, all we have to do is bail. */
return ERROR_FAIL;
case 0:
break;
case 'h': /* --help | -h */
help_flag = 1;
break;
case 'v': /* --version | -v */
version_flag = 1;
break;
case 'f': /* --file | -f */
{
char *command = alloc_printf("script {%s}", optarg);
add_config_command(command);
free(command);
break;
}
case 's': /* --search | -s */
add_script_search_dir(optarg);
break;
case 'd': /* --debug | -d */
{
int retval = command_run_linef(cmd_ctx, "debug_level %s", optarg ? optarg : "3");
if (retval != ERROR_OK)
return retval;
break;
}
case 'l': /* --log_output | -l */
{
int retval = command_run_linef(cmd_ctx, "log_output %s", optarg);
if (retval != ERROR_OK)
return retval;
break;
}
case 'c': /* --command | -c */
add_config_command(optarg);
break;
default: /* '?' */
/* getopt will emit an error message, all we have to do is bail. */
return ERROR_FAIL;
}
}