From: Simon Marchi <simark@simark.ca>
To: Tom Tromey <tromey@adacore.com>, gdb-patches@sourceware.org
Subject: Re: [PATCH 2/2] Use enum types for remote fileio flags
Date: Thu, 26 Feb 2026 12:10:58 -0500 [thread overview]
Message-ID: <d633c702-f6e8-4723-b634-247bd480298e@simark.ca> (raw)
In-Reply-To: <20260225-target-fd-newtype-v1-2-e04af6692ccb@adacore.com>
On 2/25/26 4:25 PM, Tom Tromey wrote:
> diff --git a/gdb/sparc64-tdep.c b/gdb/sparc64-tdep.c
> index 6919a1c37d3..6733aa7cc48 100644
> --- a/gdb/sparc64-tdep.c
> +++ b/gdb/sparc64-tdep.c
> @@ -287,8 +287,9 @@ adi_tag_fd ()
> char cl_name[MAX_PROC_NAME_SIZE];
> snprintf (cl_name, sizeof(cl_name), "/proc/%ld/adi/tags", (long) pid);
> fileio_error target_errno;
> - proc->stat.tag_fd = target_fileio_open (NULL, cl_name, O_RDWR|O_EXCL,
> - false, 0, &target_errno);
> + proc->stat.tag_fd = target_fileio_open (NULL, cl_name,
> + FILEIO_O_RDWR | FILEIO_O_EXCL,
> + FILEIO_S_IRWXU, 0, &target_errno);
Perhaps change that 0 to false (the `bool warn_if_slow` param).
So the flags here goes from "false" (obviously wrong) to FILEIO_S_IRWXU.
Since we don't pass the _CREATE flag, I think that the value for mode
is irrelevant. If so, it might be clearer to pass 0, otherwise it makes
it seem like the value we pass is meaningful, which can be confusing.
> /* lseek(2) flags */
> -#define FILEIO_SEEK_SET 0
> -#define FILEIO_SEEK_CUR 1
> -#define FILEIO_SEEK_END 2
> +enum fileio_lseek_flag : unsigned
> +{
> + FILEIO_SEEK_SET = 0,
> + FILEIO_SEEK_CUR = 1,
> + FILEIO_SEEK_END = 2,
> +};
> +DEF_ENUM_FLAGS_TYPE (enum fileio_lseek_flag, fileio_lseek_flags);
I don't think these values are actually flags, theys are all mutually
exclusive, I think it should be a regular enum (or enum class).
If we want to mimic the posix API, you could call it
"fileio_lseek_whence".
But I also noticed the enum type is not actually used. It could be used
in remote_fileio_seek_flag_to_host, although it wouldn't be terribly
useful. So perhaps this enum could be anonymous actually.
>
> /* errno values */
> enum fileio_error
> @@ -146,12 +159,12 @@ extern int fileio_error_to_host (fileio_error errnum);
> /* Convert File-I/O open flags FFLAGS to host format, storing
> the result in *FLAGS. Return 0 on success, -1 on error. */
>
> -extern int fileio_to_host_openflags (int fflags, int *flags);
> +extern int fileio_to_host_openflags (fileio_open_flags fflags, int *flags);
In the implementation, the second parameter is named open_flags_p. You
could maybe rename it here. That would free up "flags" for the first
parameter, if you want.
Simon
next prev parent reply other threads:[~2026-02-26 17:11 UTC|newest]
Thread overview: 9+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-02-25 21:25 [PATCH 0/2] Stronger typing for remote file i/o Tom Tromey
2026-02-25 21:25 ` [PATCH 1/2] Use a newtype for remote file descriptor Tom Tromey
2026-02-26 16:38 ` Simon Marchi
2026-02-27 13:36 ` Tom Tromey
2026-02-26 16:43 ` Simon Marchi
2026-02-27 13:36 ` Tom Tromey
2026-02-25 21:25 ` [PATCH 2/2] Use enum types for remote fileio flags Tom Tromey
2026-02-26 17:10 ` Simon Marchi [this message]
2026-02-27 14:15 ` Tom Tromey
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=d633c702-f6e8-4723-b634-247bd480298e@simark.ca \
--to=simark@simark.ca \
--cc=gdb-patches@sourceware.org \
--cc=tromey@adacore.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox