diff options
author | Simon Marchi <simon.marchi@efficios.com> | 2022-08-26 15:38:26 -0400 |
---|---|---|
committer | Simon Marchi <simon.marchi@polymtl.ca> | 2022-09-21 14:11:03 -0400 |
commit | b872057a63c53106e4bf6033a52d53b988f30dfd (patch) | |
tree | 0178e5e9ae12af553f15c2e13cac0eb61e1cdafc /gdb/sparc64-tdep.c | |
parent | 198f946ffe9fbfeeb187531e57cab6c3fd9d8b3d (diff) | |
download | fsf-binutils-gdb-b872057a63c53106e4bf6033a52d53b988f30dfd.zip fsf-binutils-gdb-b872057a63c53106e4bf6033a52d53b988f30dfd.tar.gz fsf-binutils-gdb-b872057a63c53106e4bf6033a52d53b988f30dfd.tar.bz2 |
gdbsupport: convert FILEIO_* macros to an enum
Converting from free-form macros to an enum gives a bit of type-safety.
This caught places where we would assign host error numbers to what
should contain a target fileio error number, for instance in
target_fileio_pread.
I added the FILEIO_SUCCESS enumerator, because
remote.c:remote_hostio_parse_result initializes the remote_errno output
variable to 0. It seems better to have an explicit enumerator than to
assign a value for which there is no enumerator. I considered
initializing this variable to FILEIO_EUNKNOWN instead, such that if the
remote side replies with an error and omits the errno value, we'll get
an errno that represents an error instead of 0 (which reprensents no
error). But it's not clear what the consequences of that change would
be, so I prefer to err on the side of caution and just keep the existing
behavior (there is no intended change in behavior with this patch).
Note that remote_hostio_parse_resul still reads blindly what the remote
side sends as a target errno into this variable, so we can still end up
with a nonsensical value here. It's not good, but out of the scope of
this patch.
Convert host_to_fileio_error and fileio_errno_to_host to return / accept
a fileio_error instead of an int, and cascade the change in the whole
chain that uses that.
Change-Id: I454b0e3fcf0732447bc872252fa8e57d138b0e03
Diffstat (limited to 'gdb/sparc64-tdep.c')
-rw-r--r-- | gdb/sparc64-tdep.c | 8 |
1 files changed, 4 insertions, 4 deletions
diff --git a/gdb/sparc64-tdep.c b/gdb/sparc64-tdep.c index 7b6e991..5e69657 100644 --- a/gdb/sparc64-tdep.c +++ b/gdb/sparc64-tdep.c @@ -166,7 +166,7 @@ get_adi_info (pid_t pid) void sparc64_forget_process (pid_t pid) { - int target_errno; + fileio_error target_errno; for (auto pit = adi_proc_list.before_begin (), it = std::next (pit); @@ -287,7 +287,7 @@ adi_tag_fd (void) char cl_name[MAX_PROC_NAME_SIZE]; snprintf (cl_name, sizeof(cl_name), "/proc/%ld/adi/tags", (long) pid); - int target_errno; + fileio_error target_errno; proc->stat.tag_fd = target_fileio_open (NULL, cl_name, O_RDWR|O_EXCL, false, 0, &target_errno); return proc->stat.tag_fd; @@ -350,7 +350,7 @@ adi_read_versions (CORE_ADDR vaddr, size_t size, gdb_byte *tags) paddress (target_gdbarch (), vaddr * ast.blksize)); } - int target_errno; + fileio_error target_errno; return target_fileio_pread (fd, tags, size, vaddr, &target_errno); } @@ -371,7 +371,7 @@ adi_write_versions (CORE_ADDR vaddr, size_t size, unsigned char *tags) paddress (target_gdbarch (), vaddr * ast.blksize)); } - int target_errno; + fileio_error target_errno; return target_fileio_pwrite (fd, tags, size, vaddr, &target_errno); } |