Re: [PATCH 1/2] Use a newtype for remote file descriptor

Simon Marchi
2026-02-26T16:44:22Z

On 2/25/26 4:25 PM, Tom Tromey wrote:
> @@ -3251,25 +3251,27 @@ target_fileio_open (struct inferior *inf, const char *filename,
> if (fd == -1 && *target_errno == FILEIO_ENOSYS)
> continue;
>
> + remote_fd result;
> if (fd < 0)
> - fd = -1;
> + result = remote_fd::INVALID;
> else
> - fd = acquire_fileio_fd (t, fd);
> + result = acquire_fileio_fd (t, fd);
>
> target_debug_printf_nofunc ("target_fileio_open (%d,%s,0x%x,0%o,%d) = %d (%d)",
> - inf == NULL ? 0 : inf->num, filename, flags, mode,
> - warn_if_slow, fd, fd != -1 ? 0 : *target_errno);
> - return fd;
> + inf == NULL ? 0 : inf->num, filename,
> + flags, mode, warn_if_slow, int (fd),
> + int (fd) != -1 ? 0 : *target_errno);
> + return result;

One more nit: in this function, you don't need to case fd to int, since
fd is an int. You could either remove the cast, or use `result` in the
debug print.

Simon