target/semihosting: drop type casting from semihosting->result

Also used type helper (PRId64) to specify format of int64_t

Signed-off-by: Erhan Kurubas <erhan.kurubas@espressif.com>
Change-Id: I594863eab594aff621c26fefcc69a1872e9730ee
Reviewed-on: https://review.openocd.org/c/openocd/+/7111
Tested-by: jenkins
Reviewed-by: Antonio Borneo <borneo.antonio@gmail.com>
This commit is contained in:
Erhan Kurubas 2022-08-11 01:32:25 +02:00 committed by Antonio Borneo
parent 9cd714cd14
commit c271958850
1 changed files with 18 additions and 29 deletions

View File

@ -406,7 +406,7 @@ int semihosting_common(struct target *target)
} else {
semihosting->result = close(fd);
semihosting->sys_errno = errno;
LOG_DEBUG("close(%d)=%d", fd, (int)semihosting->result);
LOG_DEBUG("close(%d)=%" PRId64, fd, semihosting->result);
}
}
break;
@ -631,10 +631,10 @@ int semihosting_common(struct target *target)
semihosting->result = fstat(fd, &buf);
if (semihosting->result == -1) {
semihosting->sys_errno = errno;
LOG_DEBUG("fstat(%d)=%d", fd, (int)semihosting->result);
LOG_DEBUG("fstat(%d)=%" PRId64, fd, semihosting->result);
break;
}
LOG_DEBUG("fstat(%d)=%d", fd, (int)semihosting->result);
LOG_DEBUG("fstat(%d)=%" PRId64, fd, semihosting->result);
semihosting->result = buf.st_size;
}
break;
@ -691,8 +691,7 @@ int semihosting_common(struct target *target)
if (retval != ERROR_OK)
return retval;
}
LOG_DEBUG("SYS_GET_CMDLINE=[%s],%d", arg,
(int)semihosting->result);
LOG_DEBUG("SYS_GET_CMDLINE=[%s], %" PRId64, arg, semihosting->result);
}
break;
@ -784,7 +783,7 @@ int semihosting_common(struct target *target)
int fd = semihosting_get_field(target, 0, fields);
semihosting->result = isatty(fd);
semihosting->sys_errno = errno;
LOG_DEBUG("isatty(%d)=%d", fd, (int)semihosting->result);
LOG_DEBUG("isatty(%d)=%" PRId64, fd, semihosting->result);
}
break;
@ -902,22 +901,19 @@ int semihosting_common(struct target *target)
semihosting->result = fd;
semihosting->stdin_fd = fd;
semihosting->sys_errno = errno;
LOG_DEBUG("dup(STDIN)=%d",
(int)semihosting->result);
LOG_DEBUG("dup(STDIN)=%" PRId64, semihosting->result);
} else if (mode < 8) {
int fd = dup(STDOUT_FILENO);
semihosting->result = fd;
semihosting->stdout_fd = fd;
semihosting->sys_errno = errno;
LOG_DEBUG("dup(STDOUT)=%d",
(int)semihosting->result);
LOG_DEBUG("dup(STDOUT)=%" PRId64, semihosting->result);
} else {
int fd = dup(STDERR_FILENO);
semihosting->result = fd;
semihosting->stderr_fd = fd;
semihosting->sys_errno = errno;
LOG_DEBUG("dup(STDERR)=%d",
(int)semihosting->result);
LOG_DEBUG("dup(STDERR)=%" PRId64, semihosting->result);
}
} else {
/* cygwin requires the permission setting
@ -927,8 +923,7 @@ int semihosting_common(struct target *target)
open_host_modeflags[mode],
0644);
semihosting->sys_errno = errno;
LOG_DEBUG("open('%s')=%d", fn,
(int)semihosting->result);
LOG_DEBUG("open('%s')=%" PRId64, fn, semihosting->result);
}
}
free(fn);
@ -991,11 +986,11 @@ int semihosting_common(struct target *target)
semihosting->sys_errno = ENOMEM;
} else {
semihosting->result = semihosting_read(semihosting, fd, buf, len);
LOG_DEBUG("read(%d, 0x%" PRIx64 ", %zu)=%d",
LOG_DEBUG("read(%d, 0x%" PRIx64 ", %zu)=%" PRId64,
fd,
addr,
len,
(int)semihosting->result);
semihosting->result);
if (semihosting->result >= 0) {
retval = target_write_buffer(target, addr,
semihosting->result,
@ -1031,7 +1026,7 @@ int semihosting_common(struct target *target)
return ERROR_FAIL;
}
semihosting->result = semihosting_getchar(semihosting, semihosting->stdin_fd);
LOG_DEBUG("getchar()=%d", (int)semihosting->result);
LOG_DEBUG("getchar()=%" PRId64, semihosting->result);
break;
case SEMIHOSTING_SYS_REMOVE: /* 0x0E */
@ -1077,8 +1072,7 @@ int semihosting_common(struct target *target)
fn[len] = 0;
semihosting->result = remove((char *)fn);
semihosting->sys_errno = errno;
LOG_DEBUG("remove('%s')=%d", fn,
(int)semihosting->result);
LOG_DEBUG("remove('%s')=%" PRId64, fn, semihosting->result);
free(fn);
}
@ -1147,9 +1141,7 @@ int semihosting_common(struct target *target)
semihosting->result = rename((char *)fn1,
(char *)fn2);
semihosting->sys_errno = errno;
LOG_DEBUG("rename('%s', '%s')=%d", fn1, fn2,
(int)semihosting->result);
LOG_DEBUG("rename('%s', '%s')=%" PRId64 " %d", fn1, fn2, semihosting->result, errno);
free(fn1);
free(fn2);
}
@ -1194,8 +1186,7 @@ int semihosting_common(struct target *target)
} else {
semihosting->result = lseek(fd, pos, SEEK_SET);
semihosting->sys_errno = errno;
LOG_DEBUG("lseek(%d, %d)=%d", fd, (int)pos,
(int)semihosting->result);
LOG_DEBUG("lseek(%d, %d)=%" PRId64, fd, (int)pos, semihosting->result);
if (semihosting->result == pos)
semihosting->result = 0;
}
@ -1254,9 +1245,7 @@ int semihosting_common(struct target *target)
cmd[len] = 0;
semihosting->result = system(
(const char *)cmd);
LOG_DEBUG("system('%s')=%d",
cmd,
(int)semihosting->result);
LOG_DEBUG("system('%s')=%" PRId64, cmd, semihosting->result);
}
free(cmd);
@ -1335,11 +1324,11 @@ int semihosting_common(struct target *target)
}
semihosting->result = semihosting_write(semihosting, fd, buf, len);
semihosting->sys_errno = errno;
LOG_DEBUG("write(%d, 0x%" PRIx64 ", %zu)=%d",
LOG_DEBUG("write(%d, 0x%" PRIx64 ", %zu)=%" PRId64,
fd,
addr,
len,
(int)semihosting->result);
semihosting->result);
if (semihosting->result >= 0) {
/* The number of bytes that are NOT written.
* */