diff --git a/src/gdb_hostio.c b/src/gdb_hostio.c index 20fb8f4b..82ff0a6d 100644 --- a/src/gdb_hostio.c +++ b/src/gdb_hostio.c @@ -29,25 +29,26 @@ int gdb_main_loop(struct target_controller *, bool in_syscall); int hostio_reply(struct target_controller *tc, char *pbuf, int len) { (void)len; - int retcode, items; + int retcode, items, errno_; char c, *p; if (pbuf[1] == '-') p = &pbuf[2]; else p = &pbuf[1]; - items = sscanf(p, "%x,%x,%c", &retcode, &tc->errno_, &c); + items = sscanf(p, "%x,%x,%c", &retcode, &errno_, &c); if (pbuf[1] == '-') retcode = -retcode; /* if break is requested */ tc->interrupted = items == 3 && c == 'C'; + tc->errno_ = errno_; return retcode; } /* Interface to host system calls */ int hostio_open(struct target_controller *tc, - target_addr path, unsigned path_len, + target_addr path, size_t path_len, enum target_open_flags flags, mode_t mode) { gdb_putpacket_f("Fopen,%08X/%X,%08X,%08X", path, path_len, flags, mode);;;; @@ -82,8 +83,8 @@ long hostio_lseek(struct target_controller *tc, } int hostio_rename(struct target_controller *tc, - target_addr oldpath, unsigned old_len, - target_addr newpath, unsigned new_len) + target_addr oldpath, size_t old_len, + target_addr newpath, size_t new_len) { gdb_putpacket_f("Frename,%08X/%X,%08X/%X", oldpath, old_len, newpath, new_len); @@ -91,14 +92,14 @@ int hostio_rename(struct target_controller *tc, } int hostio_unlink(struct target_controller *tc, - target_addr path, unsigned path_len) + target_addr path, size_t path_len) { gdb_putpacket_f("Funlink,%08X/%X", path, path_len); return gdb_main_loop(tc, true); } int hostio_stat(struct target_controller *tc, - target_addr path, unsigned path_len, target_addr buf) + target_addr path, size_t path_len, target_addr buf) { gdb_putpacket_f("Fstat,%08X/%X,%08X", path, path_len, buf); return gdb_main_loop(tc, true); @@ -124,7 +125,7 @@ int hostio_isatty(struct target_controller *tc, int fd) } int hostio_system(struct target_controller *tc, - target_addr cmd, unsigned cmd_len) + target_addr cmd, size_t cmd_len) { gdb_putpacket_f("Fsystem,%08X/%X", cmd, cmd_len); return gdb_main_loop(tc, true); diff --git a/src/gdb_hostio.h b/src/gdb_hostio.h index eaa97bd7..f95f707f 100644 --- a/src/gdb_hostio.h +++ b/src/gdb_hostio.h @@ -26,7 +26,7 @@ int hostio_reply(struct target_controller *tc, char *packet, int len); /* Interface to host system calls */ int hostio_open(struct target_controller *, - target_addr path, unsigned path_len, + target_addr path, size_t path_len, enum target_open_flags flags, mode_t mode); int hostio_close(struct target_controller *, int fd); int hostio_read(struct target_controller *, @@ -36,18 +36,18 @@ int hostio_write(struct target_controller *, long hostio_lseek(struct target_controller *, int fd, long offset, enum target_seek_flag flag); int hostio_rename(struct target_controller *, - target_addr oldpath, unsigned old_len, - target_addr newpath, unsigned new_len); + target_addr oldpath, size_t old_len, + target_addr newpath, size_t new_len); int hostio_unlink(struct target_controller *, - target_addr path, unsigned path_len); + target_addr path, size_t path_len); int hostio_stat(struct target_controller *, - target_addr path, unsigned path_len, target_addr buf); + target_addr path, size_t path_len, target_addr buf); int hostio_fstat(struct target_controller *, int fd, target_addr buf); int hostio_gettimeofday(struct target_controller *, target_addr tv, target_addr tz); int hostio_isatty(struct target_controller *, int fd); int hostio_system(struct target_controller *, - target_addr cmd, unsigned cmd_len); + target_addr cmd, size_t cmd_len); #endif diff --git a/src/include/target.h b/src/include/target.h index 8ca7e74c..86c7d986 100644 --- a/src/include/target.h +++ b/src/include/target.h @@ -79,7 +79,7 @@ struct target_controller { /* Interface to host system calls */ int (*open)(struct target_controller *, - target_addr path, unsigned path_len, + target_addr path, size_t path_len, enum target_open_flags flags, mode_t mode); int (*close)(struct target_controller *, int fd); int (*read)(struct target_controller *, @@ -89,18 +89,18 @@ struct target_controller { long (*lseek)(struct target_controller *, int fd, long offset, enum target_seek_flag flag); int (*rename)(struct target_controller *, - target_addr oldpath, unsigned old_len, - target_addr newpath, unsigned new_len); + target_addr oldpath, size_t old_len, + target_addr newpath, size_t new_len); int (*unlink)(struct target_controller *, - target_addr path, unsigned path_len); + target_addr path, size_t path_len); int (*stat)(struct target_controller *, - target_addr path, unsigned path_len, target_addr buf); + target_addr path, size_t path_len, target_addr buf); int (*fstat)(struct target_controller *, int fd, target_addr buf); int (*gettimeofday)(struct target_controller *, target_addr tv, target_addr tz); int (*isatty)(struct target_controller *, int fd); int (*system)(struct target_controller *, - target_addr cmd, unsigned cmd_len); + target_addr cmd, size_t cmd_len); enum target_errno errno_; bool interrupted; }; diff --git a/src/target/target.c b/src/target/target.c index 70224a13..750b17a6 100644 --- a/src/target/target.c +++ b/src/target/target.c @@ -424,7 +424,7 @@ void tc_printf(target *t, const char *fmt, ...) } /* Interface to host system calls */ -int tc_open(target *t, target_addr path, unsigned plen, +int tc_open(target *t, target_addr path, size_t plen, enum target_open_flags flags, mode_t mode) { if (t->tc->open == NULL) { @@ -464,8 +464,8 @@ long tc_lseek(target *t, int fd, long offset, enum target_seek_flag flag) return t->tc->lseek(t->tc, fd, offset, flag); } -int tc_rename(target *t, target_addr oldpath, unsigned oldlen, - target_addr newpath, unsigned newlen) +int tc_rename(target *t, target_addr oldpath, size_t oldlen, + target_addr newpath, size_t newlen) { if (t->tc->rename == NULL) { t->tc->errno_ = TARGET_ENOENT; @@ -474,7 +474,7 @@ int tc_rename(target *t, target_addr oldpath, unsigned oldlen, return t->tc->rename(t->tc, oldpath, oldlen, newpath, newlen); } -int tc_unlink(target *t, target_addr path, unsigned plen) +int tc_unlink(target *t, target_addr path, size_t plen) { if (t->tc->unlink == NULL) { t->tc->errno_ = TARGET_ENOENT; @@ -483,7 +483,7 @@ int tc_unlink(target *t, target_addr path, unsigned plen) return t->tc->unlink(t->tc, path, plen); } -int tc_stat(target *t, target_addr path, unsigned plen, target_addr buf) +int tc_stat(target *t, target_addr path, size_t plen, target_addr buf) { if (t->tc->stat == NULL) { t->tc->errno_ = TARGET_ENOENT; @@ -516,7 +516,7 @@ int tc_isatty(target *t, int fd) return t->tc->isatty(t->tc, fd); } -int tc_system(target *t, target_addr cmd, unsigned cmdlen) +int tc_system(target *t, target_addr cmd, size_t cmdlen) { if (t->tc->system == NULL) { return -1; diff --git a/src/target/target_internal.h b/src/target/target_internal.h index 6042a46c..9f55ea58 100644 --- a/src/target/target_internal.h +++ b/src/target/target_internal.h @@ -142,21 +142,21 @@ void target_mem_write8(target *t, uint32_t addr, uint8_t value); void tc_printf(target *t, const char *fmt, ...); /* Interface to host system calls */ -int tc_open(target *, target_addr path, unsigned plen, +int tc_open(target *, target_addr path, size_t plen, enum target_open_flags flags, mode_t mode); int tc_close(target *t, int fd); int tc_read(target *t, int fd, target_addr buf, unsigned int count); int tc_write(target *t, int fd, target_addr buf, unsigned int count); long tc_lseek(target *t, int fd, long offset, enum target_seek_flag flag); -int tc_rename(target *t, target_addr oldpath, unsigned oldlen, - target_addr newpath, unsigned newlen); -int tc_unlink(target *t, target_addr path, unsigned plen); -int tc_stat(target *t, target_addr path, unsigned plen, target_addr buf); +int tc_rename(target *t, target_addr oldpath, size_t oldlen, + target_addr newpath, size_t newlen); +int tc_unlink(target *t, target_addr path, size_t plen); +int tc_stat(target *t, target_addr path, size_t plen, target_addr buf); int tc_fstat(target *t, int fd, target_addr buf); int tc_gettimeofday(target *t, target_addr tv, target_addr tz); int tc_isatty(target *t, int fd); -int tc_system(target *t, target_addr cmd, unsigned cmdlen); +int tc_system(target *t, target_addr cmd, size_t cmdlen); /* Probe for various targets. * Actual functions implemented in their respective drivers.