[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.22 19:17, Andrew Cooper wrote:
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.

Fine with me.


Juergen

Attachment: OpenPGP_0xB0DE9DD628BF132F.asc
Description: OpenPGP public key

Attachment: OpenPGP_signature
Description: OpenPGP digital signature


 


Rackspace

Lists.xenproject.org is hosted with RackSpace, monitoring our
servers 24x7x365 and backed by RackSpace's Fanatical Support®.