target/semihosting: drop type casting from semihosting->result 11/7111/3
authorErhan Kurubas <erhan.kurubas@espressif.com>
Wed, 10 Aug 2022 23:32:25 +0000 (01:32 +0200)
committerAntonio Borneo <borneo.antonio@gmail.com>
Sat, 20 Aug 2022 15:27:46 +0000 (15:27 +0000)
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>
src/target/semihosting_common.c

index e31ff6fd4a6fde99a3e7ae0af99adc051ab64e01..c449b0539687c45de57566487ffe9a962bdd0590 100644 (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.
                                                         * */

Linking to existing account procedure

If you already have an account and want to add another login method you MUST first sign in with your existing account and then change URL to read https://review.openocd.org/login/?link to get to this page again but this time it'll work for linking. Thank you.

SSH host keys fingerprints

1024 SHA256:YKx8b7u5ZWdcbp7/4AeXNaqElP49m6QrwfXaqQGJAOk gerrit-code-review@openocd.zylin.com (DSA)
384 SHA256:jHIbSQa4REvwCFG4cq5LBlBLxmxSqelQPem/EXIrxjk gerrit-code-review@openocd.org (ECDSA)
521 SHA256:UAOPYkU9Fjtcao0Ul/Rrlnj/OsQvt+pgdYSZ4jOYdgs gerrit-code-review@openocd.org (ECDSA)
256 SHA256:A13M5QlnozFOvTllybRZH6vm7iSt0XLxbA48yfc2yfY gerrit-code-review@openocd.org (ECDSA)
256 SHA256:spYMBqEYoAOtK7yZBrcwE8ZpYt6b68Cfh9yEVetvbXg gerrit-code-review@openocd.org (ED25519)
+--[ED25519 256]--+
|=..              |
|+o..   .         |
|*.o   . .        |
|+B . . .         |
|Bo. = o S        |
|Oo.+ + =         |
|oB=.* = . o      |
| =+=.+   + E     |
|. .=o   . o      |
+----[SHA256]-----+
2048 SHA256:0Onrb7/PHjpo6iVZ7xQX2riKN83FJ3KGU0TvI0TaFG4 gerrit-code-review@openocd.zylin.com (RSA)