All of lore.kernel.org
 help / color / mirror / Atom feed
From: Samuel Thibault <samuel.thibault@ens-lyon.org>
To: Juergen Gross <jgross@suse.com>
Cc: minios-devel@lists.xenproject.org,
	xen-devel@lists.xenproject.org, wl@xen.org
Subject: Re: [PATCH 04/15] mini-os: replace multiple fd elements in struct file by common one
Date: Sun, 9 Jan 2022 02:25:32 +0100	[thread overview]
Message-ID: <20220109012532.3xggmswcyfgs2xiq@begin> (raw)
In-Reply-To: <20220106115741.3219-5-jgross@suse.com>

Juergen Gross, le jeu. 06 janv. 2022 12:57:30 +0100, a ecrit:
> The type specific union in struct files contains two instances of
> "int fd". Replace them by a common one.
> 
> Signed-off-by: Juergen Gross <jgross@suse.com>

Reviewed-by: Samuel Thibault <samuel.thibault@ens-lyon.org>

> ---
>  include/lib.h |  9 +--------
>  lib/sys.c     | 28 ++++++++++++++--------------
>  2 files changed, 15 insertions(+), 22 deletions(-)
> 
> diff --git a/include/lib.h b/include/lib.h
> index 4d9b14b..dc56f52 100644
> --- a/include/lib.h
> +++ b/include/lib.h
> @@ -187,14 +187,7 @@ struct file {
>      bool read;	/* maybe available for read */
>      off_t offset;
>      union {
> -	struct {
> -            /* lwIP fd */
> -	    int fd;
> -	} socket;
> -	struct {
> -            /* FS import fd */
> -	    int fd;
> -	} file;
> +        int fd; /* Any fd from an upper layer. */
>  	struct {
>  	    struct evtchn_port_list ports;
>  	} evtchn;
> diff --git a/lib/sys.c b/lib/sys.c
> index e1cea70..1da7401 100644
> --- a/lib/sys.c
> +++ b/lib/sys.c
> @@ -258,7 +258,7 @@ int read(int fd, void *buf, size_t nbytes)
>          }
>  #ifdef HAVE_LWIP
>  	case FTYPE_SOCKET:
> -	    return lwip_read(files[fd].socket.fd, buf, nbytes);
> +	    return lwip_read(files[fd].fd, buf, nbytes);
>  #endif
>  #ifdef CONFIG_NETFRONT
>  	case FTYPE_TAP: {
> @@ -335,7 +335,7 @@ int write(int fd, const void *buf, size_t nbytes)
>  	    return nbytes;
>  #ifdef HAVE_LWIP
>  	case FTYPE_SOCKET:
> -	    return lwip_write(files[fd].socket.fd, (void*) buf, nbytes);
> +	    return lwip_write(files[fd].fd, (void*) buf, nbytes);
>  #endif
>  #ifdef CONFIG_NETFRONT
>  	case FTYPE_TAP:
> @@ -428,7 +428,7 @@ int close(int fd)
>  #endif
>  #ifdef HAVE_LWIP
>  	case FTYPE_SOCKET: {
> -	    int res = lwip_close(files[fd].socket.fd);
> +	    int res = lwip_close(files[fd].fd);
>  	    files[fd].type = FTYPE_NONE;
>  	    return res;
>  	}
> @@ -594,7 +594,7 @@ int fcntl(int fd, int cmd, ...)
>  	    if (files[fd].type == FTYPE_SOCKET && !(arg & ~O_NONBLOCK)) {
>  		/* Only flag supported: non-blocking mode */
>  		uint32_t nblock = !!(arg & O_NONBLOCK);
> -		return lwip_ioctl(files[fd].socket.fd, FIONBIO, &nblock);
> +		return lwip_ioctl(files[fd].fd, FIONBIO, &nblock);
>  	    }
>  	    /* Fallthrough */
>  #endif
> @@ -732,15 +732,15 @@ static int select_poll(int nfds, fd_set *readfds, fd_set *writefds, fd_set *exce
>      for (i = 0; i < nfds; i++) {
>  	if (files[i].type == FTYPE_SOCKET) {
>  	    if (FD_ISSET(i, readfds)) {
> -		FD_SET(files[i].socket.fd, &sock_readfds);
> +		FD_SET(files[i].fd, &sock_readfds);
>  		sock_nfds = i+1;
>  	    }
>  	    if (FD_ISSET(i, writefds)) {
> -		FD_SET(files[i].socket.fd, &sock_writefds);
> +		FD_SET(files[i].fd, &sock_writefds);
>  		sock_nfds = i+1;
>  	    }
>  	    if (FD_ISSET(i, exceptfds)) {
> -		FD_SET(files[i].socket.fd, &sock_exceptfds);
> +		FD_SET(files[i].fd, &sock_exceptfds);
>  		sock_nfds = i+1;
>  	    }
>  	}
> @@ -803,19 +803,19 @@ static int select_poll(int nfds, fd_set *readfds, fd_set *writefds, fd_set *exce
>  	case FTYPE_SOCKET:
>  	    if (FD_ISSET(i, readfds)) {
>  	        /* Optimize no-network-packet case.  */
> -		if (sock_n && FD_ISSET(files[i].socket.fd, &sock_readfds))
> +		if (sock_n && FD_ISSET(files[i].fd, &sock_readfds))
>  		    n++;
>  		else
>  		    FD_CLR(i, readfds);
>  	    }
>              if (FD_ISSET(i, writefds)) {
> -		if (sock_n && FD_ISSET(files[i].socket.fd, &sock_writefds))
> +		if (sock_n && FD_ISSET(files[i].fd, &sock_writefds))
>  		    n++;
>  		else
>  		    FD_CLR(i, writefds);
>              }
>              if (FD_ISSET(i, exceptfds)) {
> -		if (sock_n && FD_ISSET(files[i].socket.fd, &sock_exceptfds))
> +		if (sock_n && FD_ISSET(files[i].fd, &sock_exceptfds))
>  		    n++;
>  		else
>  		    FD_CLR(i, exceptfds);
> @@ -1112,7 +1112,7 @@ int socket(int domain, int type, int protocol)
>  	return -1;
>      res = alloc_fd(FTYPE_SOCKET);
>      printk("socket -> %d\n", res);
> -    files[res].socket.fd = fd;
> +    files[res].fd = fd;
>      return res;
>  }
>  
> @@ -1124,11 +1124,11 @@ int accept(int s, struct sockaddr *addr, socklen_t *addrlen)
>  	errno = EBADF;
>  	return -1;
>      }
> -    fd = lwip_accept(files[s].socket.fd, addr, addrlen);
> +    fd = lwip_accept(files[s].fd, addr, addrlen);
>      if (fd < 0)
>  	return -1;
>      res = alloc_fd(FTYPE_SOCKET);
> -    files[res].socket.fd = fd;
> +    files[res].fd = fd;
>      printk("accepted on %d -> %d\n", s, res);
>      return res;
>  }
> @@ -1141,7 +1141,7 @@ ret name proto \
>  	errno = EBADF; \
>  	return -1; \
>      } \
> -    s = files[s].socket.fd; \
> +    s = files[s].fd; \
>      return lwip_##name args; \
>  }
>  
> -- 
> 2.26.2
> 

-- 
Samuel
<c> xlnt comme sujet de stage je peux essayer de donner une description formelle de automake
 -+- #ens-mim -+-


  reply	other threads:[~2022-01-09  1:25 UTC|newest]

Thread overview: 37+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2022-01-06 11:57 [PATCH 00/15] mini-os: remove struct file dependency from config Juergen Gross
2022-01-06 11:57 ` [PATCH 01/15] mini-os: split struct file definition from its usage Juergen Gross
2022-01-09  1:17   ` Samuel Thibault
2022-01-06 11:57 ` [PATCH 02/15] mini-os: makes file.read bool and move it ahead of device specific part Juergen Gross
2022-01-09  1:18   ` Samuel Thibault
2022-01-09  1:21     ` Samuel Thibault
2022-01-09  6:12       ` Juergen Gross
2022-01-09 10:20         ` Samuel Thibault
2022-01-09 10:28           ` Juergen Gross
2022-01-09 10:33             ` Samuel Thibault
2022-01-06 11:57 ` [PATCH 03/15] mini-os: make offset a common struct file member for all types Juergen Gross
2022-01-09  1:23   ` Samuel Thibault
2022-01-06 11:57 ` [PATCH 04/15] mini-os: replace multiple fd elements in struct file by common one Juergen Gross
2022-01-09  1:25   ` Samuel Thibault [this message]
2022-01-06 11:57 ` [PATCH 05/15] mini-os: introduce a common dev pointer in struct file Juergen Gross
2022-01-09  1:25   ` Samuel Thibault
2022-01-06 11:57 ` [PATCH 06/15] mini-os: eliminate blkfront union member " Juergen Gross
2022-01-09  1:26   ` Samuel Thibault
2022-01-06 11:57 ` [PATCH 07/15] mini-os: eliminate consfront " Juergen Gross
2022-01-09  1:27   ` Samuel Thibault
2022-01-06 11:57 ` [PATCH 08/15] mini-os: eliminate fbfront " Juergen Gross
2022-01-09  1:27   ` Samuel Thibault
2022-01-06 11:57 ` [PATCH 09/15] mini-os: eliminate kbdfront " Juergen Gross
2022-01-09  1:28   ` Samuel Thibault
2022-01-06 11:57 ` [PATCH 10/15] mini-os: eliminate netfront " Juergen Gross
2022-01-09  1:28   ` Samuel Thibault
2022-01-06 11:57 ` [PATCH 11/15] mini-os: move tpm respgot member of struct file to device specific data Juergen Gross
2022-01-09  1:30   ` Samuel Thibault
2022-01-06 11:57 ` [PATCH 12/15] mini-os: eliminate tpmfront union member in struct file Juergen Gross
2022-01-09  1:30   ` Samuel Thibault
2022-01-06 11:57 ` [PATCH 13/15] mini-os: eliminate tpmtis " Juergen Gross
2022-01-09  1:31   ` Samuel Thibault
2022-01-06 11:57 ` [PATCH 14/15] mini-os: eliminate xenbus " Juergen Gross
2022-01-09  1:32   ` Samuel Thibault
2022-01-06 11:57 ` [PATCH 15/15] mini-os: introduce get_file_from_fd() Juergen Gross
2022-01-09  1:33   ` Samuel Thibault
2022-01-07  2:39 ` [PATCH 00/15] mini-os: remove struct file dependency from config Samuel Thibault

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=20220109012532.3xggmswcyfgs2xiq@begin \
    --to=samuel.thibault@ens-lyon.org \
    --cc=jgross@suse.com \
    --cc=minios-devel@lists.xenproject.org \
    --cc=wl@xen.org \
    --cc=xen-devel@lists.xenproject.org \
    /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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.