|
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index] Re: [PATCH v2 15/18] mini-os: introduce get_file_from_fd()
On 11/01/2022 14:58, Juergen Gross wrote:
> diff --git a/lib/sys.c b/lib/sys.c
> index 6f2b026..0e6fe5d 100644
> --- a/lib/sys.c
> +++ b/lib/sys.c
> @@ -98,6 +98,14 @@ struct file files[NOFILE] = {
> { .type = FTYPE_CONSOLE }, /* stderr */
> };
>
> +struct file *get_file_from_fd(int fd)
> +{
> + if ( fd < 0 || fd >= NOFILE )
fd >= ARRAY_SIZE(files) ?
Generates slightly safer code in the event that `struct file
files[NOFILE]` gets refactored.
~Andrew
> + return NULL;
> +
> + return (files[fd].type == FTYPE_NONE) ? NULL : files + fd;
> +}
> +
> DECLARE_WAIT_QUEUE_HEAD(event_queue);
>
> int alloc_fd(enum fd_type type)
|
![]() |
Lists.xenproject.org is hosted with RackSpace, monitoring our |