[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [PATCH 02/15] mini-os: makes file.read bool and move it ahead of device specific part



Juergen Gross, le jeu. 06 janv. 2022 12:57:28 +0100, a ecrit:
> The read member of struct file should be bool.
> 
> In order to have the device specific part at the end of the structure
> move "read" ahead of that.
> 
> Signed-off-by: Juergen Gross <jgross@xxxxxxxx>

Reviewed-by: Samuel Thibault <samuel.thibault@xxxxxxxxxxxx>

> ---
>  blkfront.c             |  4 ++--
>  console/xencons_ring.c |  2 +-
>  fbfront.c              | 12 ++++++------
>  include/lib.h          |  3 ++-
>  netfront.c             |  4 ++--
>  tpm_tis.c              |  2 +-
>  tpmfront.c             |  6 +++---
>  7 files changed, 17 insertions(+), 16 deletions(-)
> 
> diff --git a/blkfront.c b/blkfront.c
> index 834a978..7c8eb74 100644
> --- a/blkfront.c
> +++ b/blkfront.c
> @@ -62,7 +62,7 @@ void blkfront_handler(evtchn_port_t port, struct pt_regs 
> *regs, void *data)
>      int fd = dev->fd;
>  
>      if (fd != -1)
> -        files[fd].read = 1;
> +        files[fd].read = true;
>  #endif
>      wake_up(&blkfront_queue);
>  }
> @@ -484,7 +484,7 @@ int blkfront_aio_poll(struct blkfront_dev *dev)
>  moretodo:
>  #ifdef HAVE_LIBC
>      if (dev->fd != -1) {
> -        files[dev->fd].read = 0;
> +        files[dev->fd].read = false;
>          mb(); /* Make sure to let the handler set read to 1 before we start 
> looking at the ring */
>      }
>  #endif
> diff --git a/console/xencons_ring.c b/console/xencons_ring.c
> index b6db74e..c348f3c 100644
> --- a/console/xencons_ring.c
> +++ b/console/xencons_ring.c
> @@ -102,7 +102,7 @@ void console_handle_input(evtchn_port_t port, struct 
> pt_regs *regs, void *data)
>          int fd = dev ? dev->fd : -1;
>  
>          if (fd != -1)
> -            files[fd].read = 1;
> +            files[fd].read = true;
>  
>          wake_up(&console_queue);
>  #else
> diff --git a/fbfront.c b/fbfront.c
> index d3b3848..6725da1 100644
> --- a/fbfront.c
> +++ b/fbfront.c
> @@ -45,7 +45,7 @@ void kbdfront_handler(evtchn_port_t port, struct pt_regs 
> *regs, void *data)
>      int fd = dev->fd;
>  
>      if (fd != -1)
> -        files[fd].read = 1;
> +        files[fd].read = true;
>  #endif
>      wake_up(&kbdfront_queue);
>  }
> @@ -207,7 +207,7 @@ int kbdfront_receive(struct kbdfront_dev *dev, union 
> xenkbd_in_event *buf, int n
>  
>  #ifdef HAVE_LIBC
>      if (dev->fd != -1) {
> -        files[dev->fd].read = 0;
> +        files[dev->fd].read = false;
>          mb(); /* Make sure to let the handler set read to 1 before we start 
> looking at the ring */
>      }
>  #endif
> @@ -229,7 +229,7 @@ int kbdfront_receive(struct kbdfront_dev *dev, union 
> xenkbd_in_event *buf, int n
>  #ifdef HAVE_LIBC
>      if (cons != prod && dev->fd != -1)
>          /* still some events to read */
> -        files[dev->fd].read = 1;
> +        files[dev->fd].read = true;
>  #endif
>  
>      return i;
> @@ -349,7 +349,7 @@ void fbfront_handler(evtchn_port_t port, struct pt_regs 
> *regs, void *data)
>      int fd = dev->fd;
>  
>      if (fd != -1)
> -        files[fd].read = 1;
> +        files[fd].read = true;
>  #endif
>      wake_up(&fbfront_queue);
>  }
> @@ -376,7 +376,7 @@ int fbfront_receive(struct fbfront_dev *dev, union 
> xenfb_in_event *buf, int n)
>  
>  #ifdef HAVE_LIBC
>      if (dev->fd != -1) {
> -        files[dev->fd].read = 0;
> +        files[dev->fd].read = false;
>          mb(); /* Make sure to let the handler set read to 1 before we start 
> looking at the ring */
>      }
>  #endif
> @@ -398,7 +398,7 @@ int fbfront_receive(struct fbfront_dev *dev, union 
> xenfb_in_event *buf, int n)
>  #ifdef HAVE_LIBC
>      if (cons != prod && dev->fd != -1)
>          /* still some events to read */
> -        files[dev->fd].read = 1;
> +        files[dev->fd].read = true;
>  #endif
>  
>      return i;
> diff --git a/include/lib.h b/include/lib.h
> index a638bc9..df2de9e 100644
> --- a/include/lib.h
> +++ b/include/lib.h
> @@ -49,6 +49,7 @@
>  #define _LIB_H_
>  
>  #include <stdarg.h>
> +#include <stdbool.h>
>  #include <stddef.h>
>  #include <xen/xen.h>
>  #include <xen/event_channel.h>
> @@ -183,6 +184,7 @@ struct evtchn_port_info {
>  
>  struct file {
>      enum fd_type type;
> +    bool read;       /* maybe available for read */
>      union {
>       struct {
>              /* lwIP fd */
> @@ -235,7 +237,6 @@ struct file {
>          } xenbus;
>  #endif
>      };
> -    int read;        /* maybe available for read */
>  };
>  
>  extern struct file files[];
> diff --git a/netfront.c b/netfront.c
> index dfe065b..a566e34 100644
> --- a/netfront.c
> +++ b/netfront.c
> @@ -255,7 +255,7 @@ void netfront_select_handler(evtchn_port_t port, struct 
> pt_regs *regs, void *dat
>      local_irq_restore(flags);
>  
>      if (fd != -1)
> -        files[fd].read = 1;
> +        files[fd].read = true;
>      wake_up(&netfront_queue);
>  }
>  #endif
> @@ -783,7 +783,7 @@ ssize_t netfront_receive(struct netfront_dev *dev, 
> unsigned char *data, size_t l
>      network_rx(dev);
>      if (!dev->rlen && fd != -1)
>          /* No data for us, make select stop returning */
> -        files[fd].read = 0;
> +        files[fd].read = false;
>      /* Before re-enabling the interrupts, in case a packet just arrived in 
> the
>       * meanwhile. */
>      local_irq_restore(flags);
> diff --git a/tpm_tis.c b/tpm_tis.c
> index 475ac5d..4a51027 100644
> --- a/tpm_tis.c
> +++ b/tpm_tis.c
> @@ -845,7 +845,7 @@ int tpm_tis_send(struct tpm_chip* tpm, uint8_t* buf, 
> size_t len) {
>     }
>  #ifdef HAVE_LIBC
>     if(tpm->fd >= 0) {
> -      files[tpm->fd].read = 0;
> +      files[tpm->fd].read = false;
>        files[tpm->fd].tpm_tis.respgot = 0;
>        files[tpm->fd].tpm_tis.offset = 0;
>     }
> diff --git a/tpmfront.c b/tpmfront.c
> index 6049244..d825b49 100644
> --- a/tpmfront.c
> +++ b/tpmfront.c
> @@ -66,7 +66,7 @@ void tpmfront_handler(evtchn_port_t port, struct pt_regs 
> *regs, void *data) {
>     dev->waiting = 0;
>  #ifdef HAVE_LIBC
>     if(dev->fd >= 0) {
> -      files[dev->fd].read = 1;
> +      files[dev->fd].read = true;
>     }
>  #endif
>     wake_up(&dev->waitq);
> @@ -438,7 +438,7 @@ int tpmfront_send(struct tpmfront_dev* dev, const 
> uint8_t* msg, size_t length)
>     dev->resplen = 0;
>  #ifdef HAVE_LIBC
>     if(dev->fd >= 0) {
> -      files[dev->fd].read = 0;
> +      files[dev->fd].read = false;
>        files[dev->fd].tpmfront.respgot = 0;
>        files[dev->fd].tpmfront.offset = 0;
>     }
> @@ -611,7 +611,7 @@ int tpmfront_posix_fstat(int fd, struct stat* buf)
>  
>     /* If we have a response waiting, then read it now from the backend
>      * so we can get its length*/
> -   if(dev->waiting || (files[dev->fd].read == 1 && 
> !files[dev->fd].tpmfront.respgot)) {
> +   if(dev->waiting || (files[dev->fd].read && 
> !files[dev->fd].tpmfront.respgot)) {
>        if ((rc = tpmfront_recv(dev, &dummybuf, &dummysz)) != 0) {
>        errno = EIO;
>        return -1;
> -- 
> 2.26.2
> 

-- 
Samuel
> No manual is ever necessary.
May I politely interject here: BULLSHIT.  That's the biggest Apple lie of all!
(Discussion in comp.os.linux.misc on the intuitiveness of interfaces.)



 


Rackspace

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