forked from auracaster/openocd
target: prepare for aligning switch and case statements
To prepare for aligning switch and case statements, fix in advance some checkpatch error due to existing code: - remove useless parenthesis; - remove useless 'break'; - join spit lines; - add space around operators; - remove 'else' after exit() and return. Change-Id: I8a87a0ea104205d087dcb8cbf4c67ff13a47742f Signed-off-by: Antonio Borneo <borneo.antonio@gmail.com> Reviewed-on: https://review.openocd.org/c/openocd/+/9050 Tested-by: jenkins Reviewed-by: zapb <dev@zapb.de>
This commit is contained in:
@@ -452,7 +452,8 @@ int semihosting_common(struct target *target)
|
||||
retval = semihosting_read_fields(target, 1, fields);
|
||||
if (retval != ERROR_OK)
|
||||
return retval;
|
||||
else {
|
||||
|
||||
{
|
||||
int fd = semihosting_get_field(target, 0, fields);
|
||||
/* Do not allow to close OpenOCD's own standard streams */
|
||||
if (fd == 0 || fd == 1 || fd == 2) {
|
||||
@@ -554,49 +555,43 @@ int semihosting_common(struct target *target)
|
||||
retval = semihosting_read_fields(target, 2, fields);
|
||||
if (retval != ERROR_OK)
|
||||
return retval;
|
||||
else {
|
||||
int type = semihosting_get_field(target, 0, fields);
|
||||
int code = semihosting_get_field(target, 1, fields);
|
||||
|
||||
if (type == ADP_STOPPED_APPLICATION_EXIT) {
|
||||
if (!gdb_get_actual_connections())
|
||||
exit(code);
|
||||
else {
|
||||
fprintf(stderr,
|
||||
"semihosting: *** application exited with %d ***\n",
|
||||
code);
|
||||
}
|
||||
} else {
|
||||
fprintf(stderr,
|
||||
"semihosting: application exception %#x\n",
|
||||
type);
|
||||
}
|
||||
int type = semihosting_get_field(target, 0, fields);
|
||||
int code = semihosting_get_field(target, 1, fields);
|
||||
|
||||
if (type == ADP_STOPPED_APPLICATION_EXIT) {
|
||||
if (!gdb_get_actual_connections())
|
||||
exit(code);
|
||||
|
||||
fprintf(stderr,
|
||||
"semihosting: *** application exited with %d ***\n",
|
||||
code);
|
||||
} else {
|
||||
fprintf(stderr,
|
||||
"semihosting: application exception %#x\n", type);
|
||||
}
|
||||
} else {
|
||||
if (semihosting->param == ADP_STOPPED_APPLICATION_EXIT) {
|
||||
if (!gdb_get_actual_connections())
|
||||
exit(0);
|
||||
else {
|
||||
fprintf(stderr,
|
||||
"semihosting: *** application exited normally ***\n");
|
||||
}
|
||||
|
||||
fprintf(stderr,
|
||||
"semihosting: *** application exited normally ***\n");
|
||||
} else if (semihosting->param == ADP_STOPPED_RUN_TIME_ERROR) {
|
||||
/* Chosen more or less arbitrarily to have a nicer message,
|
||||
* otherwise all other return the same exit code 1. */
|
||||
if (!gdb_get_actual_connections())
|
||||
exit(1);
|
||||
else {
|
||||
fprintf(stderr,
|
||||
"semihosting: *** application exited with error ***\n");
|
||||
}
|
||||
|
||||
fprintf(stderr,
|
||||
"semihosting: *** application exited with error ***\n");
|
||||
} else {
|
||||
if (!gdb_get_actual_connections())
|
||||
exit(1);
|
||||
else {
|
||||
fprintf(stderr,
|
||||
"semihosting: application exception %#x\n",
|
||||
(unsigned) semihosting->param);
|
||||
}
|
||||
|
||||
fprintf(stderr,
|
||||
"semihosting: application exception %#x\n",
|
||||
(unsigned int)semihosting->param);
|
||||
}
|
||||
}
|
||||
if (!semihosting->has_resumable_exit) {
|
||||
@@ -645,21 +640,20 @@ int semihosting_common(struct target *target)
|
||||
retval = semihosting_read_fields(target, 2, fields);
|
||||
if (retval != ERROR_OK)
|
||||
return retval;
|
||||
else {
|
||||
|
||||
{
|
||||
int type = semihosting_get_field(target, 0, fields);
|
||||
int code = semihosting_get_field(target, 1, fields);
|
||||
|
||||
if (type == ADP_STOPPED_APPLICATION_EXIT) {
|
||||
if (!gdb_get_actual_connections())
|
||||
exit(code);
|
||||
else {
|
||||
fprintf(stderr,
|
||||
"semihosting: *** application exited with %d ***\n",
|
||||
code);
|
||||
}
|
||||
|
||||
fprintf(stderr,
|
||||
"semihosting: *** application exited with %d ***\n",
|
||||
code);
|
||||
} else {
|
||||
fprintf(stderr, "semihosting: exception %#x\n",
|
||||
type);
|
||||
fprintf(stderr, "semihosting: exception %#x\n", type);
|
||||
}
|
||||
}
|
||||
if (!semihosting->has_resumable_exit) {
|
||||
@@ -691,7 +685,8 @@ int semihosting_common(struct target *target)
|
||||
retval = semihosting_read_fields(target, 1, fields);
|
||||
if (retval != ERROR_OK)
|
||||
return retval;
|
||||
else {
|
||||
|
||||
{
|
||||
int fd = semihosting_get_field(target, 0, fields);
|
||||
struct stat buf;
|
||||
semihosting->result = fstat(fd, &buf);
|
||||
@@ -736,16 +731,16 @@ int semihosting_common(struct target *target)
|
||||
retval = semihosting_read_fields(target, 2, fields);
|
||||
if (retval != ERROR_OK)
|
||||
return retval;
|
||||
else {
|
||||
|
||||
{
|
||||
uint64_t addr = semihosting_get_field(target, 0, fields);
|
||||
size_t size = semihosting_get_field(target, 1, fields);
|
||||
|
||||
char *arg = semihosting->cmdline ?
|
||||
semihosting->cmdline : "";
|
||||
char *arg = semihosting->cmdline ? semihosting->cmdline : "";
|
||||
uint32_t len = strlen(arg) + 1;
|
||||
if (len > size)
|
||||
if (len > size) {
|
||||
semihosting->result = -1;
|
||||
else {
|
||||
} else {
|
||||
semihosting_set_field(target, len, 1, fields);
|
||||
retval = target_write_buffer(target, addr, len,
|
||||
(uint8_t *)arg);
|
||||
@@ -784,7 +779,8 @@ int semihosting_common(struct target *target)
|
||||
retval = semihosting_read_fields(target, 1, fields);
|
||||
if (retval != ERROR_OK)
|
||||
return retval;
|
||||
else {
|
||||
|
||||
{
|
||||
uint64_t addr = semihosting_get_field(target, 0, fields);
|
||||
/* tell the remote we have no idea */
|
||||
memset(fields, 0, 4 * semihosting->word_size_bytes);
|
||||
@@ -908,7 +904,8 @@ int semihosting_common(struct target *target)
|
||||
retval = semihosting_read_fields(target, 3, fields);
|
||||
if (retval != ERROR_OK)
|
||||
return retval;
|
||||
else {
|
||||
|
||||
{
|
||||
uint64_t addr = semihosting_get_field(target, 0, fields);
|
||||
uint32_t mode = semihosting_get_field(target, 1, fields);
|
||||
size_t len = semihosting_get_field(target, 2, fields);
|
||||
@@ -1038,7 +1035,8 @@ int semihosting_common(struct target *target)
|
||||
retval = semihosting_read_fields(target, 3, fields);
|
||||
if (retval != ERROR_OK)
|
||||
return retval;
|
||||
else {
|
||||
|
||||
{
|
||||
int fd = semihosting_get_field(target, 0, fields);
|
||||
uint64_t addr = semihosting_get_field(target, 1, fields);
|
||||
size_t len = semihosting_get_field(target, 2, fields);
|
||||
@@ -1117,7 +1115,8 @@ int semihosting_common(struct target *target)
|
||||
retval = semihosting_read_fields(target, 2, fields);
|
||||
if (retval != ERROR_OK)
|
||||
return retval;
|
||||
else {
|
||||
|
||||
{
|
||||
uint64_t addr = semihosting_get_field(target, 0, fields);
|
||||
size_t len = semihosting_get_field(target, 1, fields);
|
||||
if (semihosting->is_fileio) {
|
||||
@@ -1131,9 +1130,7 @@ int semihosting_common(struct target *target)
|
||||
semihosting->result = -1;
|
||||
semihosting->sys_errno = ENOMEM;
|
||||
} else {
|
||||
retval =
|
||||
target_read_memory(target, addr, 1, len,
|
||||
fn);
|
||||
retval = target_read_memory(target, addr, 1, len, fn);
|
||||
if (retval != ERROR_OK) {
|
||||
free(fn);
|
||||
return retval;
|
||||
@@ -1171,7 +1168,8 @@ int semihosting_common(struct target *target)
|
||||
retval = semihosting_read_fields(target, 4, fields);
|
||||
if (retval != ERROR_OK)
|
||||
return retval;
|
||||
else {
|
||||
|
||||
{
|
||||
uint64_t addr1 = semihosting_get_field(target, 0, fields);
|
||||
size_t len1 = semihosting_get_field(target, 1, fields);
|
||||
uint64_t addr2 = semihosting_get_field(target, 2, fields);
|
||||
@@ -1192,15 +1190,13 @@ int semihosting_common(struct target *target)
|
||||
semihosting->result = -1;
|
||||
semihosting->sys_errno = ENOMEM;
|
||||
} else {
|
||||
retval = target_read_memory(target, addr1, 1, len1,
|
||||
fn1);
|
||||
retval = target_read_memory(target, addr1, 1, len1, fn1);
|
||||
if (retval != ERROR_OK) {
|
||||
free(fn1);
|
||||
free(fn2);
|
||||
return retval;
|
||||
}
|
||||
retval = target_read_memory(target, addr2, 1, len2,
|
||||
fn2);
|
||||
retval = target_read_memory(target, addr2, 1, len2, fn2);
|
||||
if (retval != ERROR_OK) {
|
||||
free(fn1);
|
||||
free(fn2);
|
||||
@@ -1208,8 +1204,7 @@ int semihosting_common(struct target *target)
|
||||
}
|
||||
fn1[len1] = 0;
|
||||
fn2[len2] = 0;
|
||||
semihosting->result = rename((char *)fn1,
|
||||
(char *)fn2);
|
||||
semihosting->result = rename((char *)fn1, (char *)fn2);
|
||||
// rename() on Windows returns nonzero on error
|
||||
if (semihosting->result != 0)
|
||||
semihosting->sys_errno = errno;
|
||||
@@ -1246,7 +1241,8 @@ int semihosting_common(struct target *target)
|
||||
retval = semihosting_read_fields(target, 2, fields);
|
||||
if (retval != ERROR_OK)
|
||||
return retval;
|
||||
else {
|
||||
|
||||
{
|
||||
int fd = semihosting_get_field(target, 0, fields);
|
||||
off_t pos = semihosting_get_field(target, 1, fields);
|
||||
if (semihosting->is_fileio) {
|
||||
@@ -1292,7 +1288,8 @@ int semihosting_common(struct target *target)
|
||||
retval = semihosting_read_fields(target, 2, fields);
|
||||
if (retval != ERROR_OK)
|
||||
return retval;
|
||||
else {
|
||||
|
||||
{
|
||||
uint64_t addr = semihosting_get_field(target, 0, fields);
|
||||
size_t len = semihosting_get_field(target, 1, fields);
|
||||
if (semihosting->is_fileio) {
|
||||
@@ -1314,12 +1311,10 @@ int semihosting_common(struct target *target)
|
||||
if (retval != ERROR_OK) {
|
||||
free(cmd);
|
||||
return retval;
|
||||
} else {
|
||||
cmd[len] = 0;
|
||||
semihosting->result = system(
|
||||
(const char *)cmd);
|
||||
LOG_DEBUG("system('%s')=%" PRId64, cmd, semihosting->result);
|
||||
}
|
||||
cmd[len] = 0;
|
||||
semihosting->result = system((const char *)cmd);
|
||||
LOG_DEBUG("system('%s')=%" PRId64, cmd, semihosting->result);
|
||||
|
||||
free(cmd);
|
||||
}
|
||||
@@ -1374,7 +1369,8 @@ int semihosting_common(struct target *target)
|
||||
retval = semihosting_read_fields(target, 3, fields);
|
||||
if (retval != ERROR_OK)
|
||||
return retval;
|
||||
else {
|
||||
|
||||
{
|
||||
int fd = semihosting_get_field(target, 0, fields);
|
||||
uint64_t addr = semihosting_get_field(target, 1, fields);
|
||||
size_t len = semihosting_get_field(target, 2, fields);
|
||||
@@ -1634,7 +1630,7 @@ int semihosting_common(struct target *target)
|
||||
|
||||
default:
|
||||
fprintf(stderr, "semihosting: unsupported call %#x\n",
|
||||
(unsigned) semihosting->op);
|
||||
(unsigned int)semihosting->op);
|
||||
semihosting->result = -1;
|
||||
semihosting->sys_errno = ENOTSUP;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user