qemu-devel.nongnu.org archive mirror
 help / color / mirror / Atom feed
* [RFC PATCH] chardev: use bool for fe_open
@ 2023-12-11 14:59 Alex Bennée
  2023-12-11 16:45 ` Philippe Mathieu-Daudé
  0 siblings, 1 reply; 2+ messages in thread
From: Alex Bennée @ 2023-12-11 14:59 UTC (permalink / raw)
  To: qemu-devel; +Cc: Alex Bennée, Marc-André Lureau, Paolo Bonzini

The function qemu_chr_fe_init already treats be->fe_open as a bool and
if it acts like a bool it should be one. While we are at it add some
kdoc decorations.

Signed-off-by: Alex Bennée <alex.bennee@linaro.org>
---
 include/chardev/char-fe.h | 19 ++++++++++++-------
 chardev/char-fe.c         |  8 ++++----
 2 files changed, 16 insertions(+), 11 deletions(-)

diff --git a/include/chardev/char-fe.h b/include/chardev/char-fe.h
index 0ff6f87511..87b63f8bc8 100644
--- a/include/chardev/char-fe.h
+++ b/include/chardev/char-fe.h
@@ -7,8 +7,12 @@
 typedef void IOEventHandler(void *opaque, QEMUChrEvent event);
 typedef int BackendChangeHandler(void *opaque);
 
-/* This is the backend as seen by frontend, the actual backend is
- * Chardev */
+/**
+ * struct CharBackend - back end as seen by front end
+ * @fe_open: the front end is ready for IO
+ *
+ * The actual backend is Chardev
+ */
 struct CharBackend {
     Chardev *chr;
     IOEventHandler *chr_event;
@@ -17,7 +21,7 @@ struct CharBackend {
     BackendChangeHandler *chr_be_change;
     void *opaque;
     int tag;
-    int fe_open;
+    bool fe_open;
 };
 
 /**
@@ -156,12 +160,13 @@ void qemu_chr_fe_set_echo(CharBackend *be, bool echo);
 
 /**
  * qemu_chr_fe_set_open:
+ * @be: a CharBackend
+ * @fe_open: the front end open status
  *
- * Set character frontend open status.  This is an indication that the
- * front end is ready (or not) to begin doing I/O.
- * Without associated Chardev, do nothing.
+ * This is an indication that the front end is ready (or not) to begin
+ * doing I/O. Without associated Chardev, do nothing.
  */
-void qemu_chr_fe_set_open(CharBackend *be, int fe_open);
+void qemu_chr_fe_set_open(CharBackend *be, bool fe_open);
 
 /**
  * qemu_chr_fe_printf:
diff --git a/chardev/char-fe.c b/chardev/char-fe.c
index 7789f7be9c..5a09ef4da7 100644
--- a/chardev/char-fe.c
+++ b/chardev/char-fe.c
@@ -257,7 +257,7 @@ void qemu_chr_fe_set_handlers_full(CharBackend *b,
                                    bool sync_state)
 {
     Chardev *s;
-    int fe_open;
+    bool fe_open;
 
     s = b->chr;
     if (!s) {
@@ -265,10 +265,10 @@ void qemu_chr_fe_set_handlers_full(CharBackend *b,
     }
 
     if (!opaque && !fd_can_read && !fd_read && !fd_event) {
-        fe_open = 0;
+        fe_open = false;
         remove_fd_in_watch(s);
     } else {
-        fe_open = 1;
+        fe_open = true;
     }
     b->chr_can_read = fd_can_read;
     b->chr_read = fd_read;
@@ -336,7 +336,7 @@ void qemu_chr_fe_set_echo(CharBackend *be, bool echo)
     }
 }
 
-void qemu_chr_fe_set_open(CharBackend *be, int fe_open)
+void qemu_chr_fe_set_open(CharBackend *be, bool fe_open)
 {
     Chardev *chr = be->chr;
 
-- 
2.39.2



^ permalink raw reply related	[flat|nested] 2+ messages in thread

* Re: [RFC PATCH] chardev: use bool for fe_open
  2023-12-11 14:59 [RFC PATCH] chardev: use bool for fe_open Alex Bennée
@ 2023-12-11 16:45 ` Philippe Mathieu-Daudé
  0 siblings, 0 replies; 2+ messages in thread
From: Philippe Mathieu-Daudé @ 2023-12-11 16:45 UTC (permalink / raw)
  To: Alex Bennée, qemu-devel; +Cc: Marc-André Lureau, Paolo Bonzini

On 11/12/23 15:59, Alex Bennée wrote:
> The function qemu_chr_fe_init already treats be->fe_open as a bool and
> if it acts like a bool it should be one. While we are at it add some
> kdoc decorations.
> 
> Signed-off-by: Alex Bennée <alex.bennee@linaro.org>
> ---
>   include/chardev/char-fe.h | 19 ++++++++++++-------
>   chardev/char-fe.c         |  8 ++++----
>   2 files changed, 16 insertions(+), 11 deletions(-)
> 
> diff --git a/include/chardev/char-fe.h b/include/chardev/char-fe.h
> index 0ff6f87511..87b63f8bc8 100644
> --- a/include/chardev/char-fe.h
> +++ b/include/chardev/char-fe.h
> @@ -7,8 +7,12 @@
>   typedef void IOEventHandler(void *opaque, QEMUChrEvent event);
>   typedef int BackendChangeHandler(void *opaque);
>   
> -/* This is the backend as seen by frontend, the actual backend is
> - * Chardev */
> +/**
> + * struct CharBackend - back end as seen by front end
> + * @fe_open: the front end is ready for IO
> + *
> + * The actual backend is Chardev
> + */
>   struct CharBackend {
>       Chardev *chr;
>       IOEventHandler *chr_event;
> @@ -17,7 +21,7 @@ struct CharBackend {
>       BackendChangeHandler *chr_be_change;
>       void *opaque;
>       int tag;
> -    int fe_open;
> +    bool fe_open;

Clearer as 'fe_is_opened'.

>   };
>   
>   /**
> @@ -156,12 +160,13 @@ void qemu_chr_fe_set_echo(CharBackend *be, bool echo);
>   
>   /**
>    * qemu_chr_fe_set_open:
> + * @be: a CharBackend
> + * @fe_open: the front end open status
>    *
> - * Set character frontend open status.  This is an indication that the
> - * front end is ready (or not) to begin doing I/O.
> - * Without associated Chardev, do nothing.
> + * This is an indication that the front end is ready (or not) to begin
> + * doing I/O. Without associated Chardev, do nothing.
>    */
> -void qemu_chr_fe_set_open(CharBackend *be, int fe_open);
> +void qemu_chr_fe_set_open(CharBackend *be, bool fe_open);

Ditto, otherwise:

Reviewed-by: Philippe Mathieu-Daudé <philmd@linaro.org>



^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2023-12-11 16:46 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2023-12-11 14:59 [RFC PATCH] chardev: use bool for fe_open Alex Bennée
2023-12-11 16:45 ` Philippe Mathieu-Daudé

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).