All of lore.kernel.org
 help / color / mirror / Atom feed
From: Luiz Capitulino <lcapitulino@redhat.com>
To: Lei Li <lilei@linux.vnet.ibm.com>
Cc: qemu-devel@nongnu.org, anthony@codemonkey.ws
Subject: Re: [Qemu-devel] [PATCH 2/4] hmp: factor out ringbuf_print_help()
Date: Mon, 9 Sep 2013 15:15:18 -0400	[thread overview]
Message-ID: <20130909151518.09dca657@redhat.com> (raw)
In-Reply-To: <1378112508-8970-3-git-send-email-lilei@linux.vnet.ibm.com>

On Mon,  2 Sep 2013 17:01:46 +0800
Lei Li <lilei@linux.vnet.ibm.com> wrote:

> Factor out ringbuf_print_help(), which will be called in
> hmp_read_ringbuf_cb() reading data that can be written with
> monitor_printf() to the console from ringbuf backend.
> 
> Signed-off-by: Lei Li <lilei@linux.vnet.ibm.com>
> ---
>  hmp.c |   31 +++++++++++++++++++------------
>  1 files changed, 19 insertions(+), 12 deletions(-)
> 
> diff --git a/hmp.c b/hmp.c
> index fcca6ae..624ed6f 100644
> --- a/hmp.c
> +++ b/hmp.c
> @@ -752,6 +752,24 @@ void hmp_pmemsave(Monitor *mon, const QDict *qdict)
>      hmp_handle_error(mon, &errp);
>  }
>  
> +static void ringbuf_print_help(Monitor *mon, const char *data)

That's a very bad name. You could call it ringbuf_print_contents(),
but then I think you should pass a size parameter. Or, you call it
ringbuf_print_char() and keep the loop in the caller.

> +{
> +    int i;
> +
> +    for (i = 0; data[i]; i++) {
> +        unsigned char ch = data[i];
> +
> +        if (ch == '\\') {
> +            monitor_printf(mon, "\\\\");
> +        } else if ((ch < 0x20 && ch != '\n' && ch != '\t') || ch == 0x7F) {
> +            monitor_printf(mon, "\\u%04X", ch);
> +        } else {
> +            monitor_printf(mon, "%c", ch);
> +        }
> +
> +    }
> +}
> +
>  void hmp_ringbuf_write(Monitor *mon, const QDict *qdict)
>  {
>      const char *chardev = qdict_get_str(qdict, "device");
> @@ -769,7 +787,6 @@ void hmp_ringbuf_read(Monitor *mon, const QDict *qdict)
>      const char *chardev = qdict_get_str(qdict, "device");
>      char *data;
>      Error *errp = NULL;
> -    int i;
>  
>      data = qmp_ringbuf_read(chardev, size, false, 0, &errp);
>      if (errp) {
> @@ -778,18 +795,8 @@ void hmp_ringbuf_read(Monitor *mon, const QDict *qdict)
>          return;
>      }
>  
> -    for (i = 0; data[i]; i++) {
> -        unsigned char ch = data[i];
> -
> -        if (ch == '\\') {
> -            monitor_printf(mon, "\\\\");
> -        } else if ((ch < 0x20 && ch != '\n' && ch != '\t') || ch == 0x7F) {
> -            monitor_printf(mon, "\\u%04X", ch);
> -        } else {
> -            monitor_printf(mon, "%c", ch);
> -        }
> +    ringbuf_print_help(mon, data);
>  
> -    }
>      monitor_printf(mon, "\n");
>      g_free(data);
>  }

  reply	other threads:[~2013-09-09 20:07 UTC|newest]

Thread overview: 8+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2013-09-02  9:01 [Qemu-devel] [PATCH 0/4 RFC] Introduce console for ringbuf backend Lei Li
2013-09-02  9:01 ` [Qemu-devel] [PATCH 1/4] monitor: introduce monitor_read_console Lei Li
2013-09-09 19:13   ` Luiz Capitulino
2013-09-02  9:01 ` [Qemu-devel] [PATCH 2/4] hmp: factor out ringbuf_print_help() Lei Li
2013-09-09 19:15   ` Luiz Capitulino [this message]
2013-09-02  9:01 ` [Qemu-devel] [PATCH 3/4] qemu-char: export ringbuf_count Lei Li
2013-09-02  9:01 ` [Qemu-devel] [PATCH 4/4] hmp: add console support for ringbuf backend Lei Li
2013-09-09 20:27   ` Luiz Capitulino

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=20130909151518.09dca657@redhat.com \
    --to=lcapitulino@redhat.com \
    --cc=anthony@codemonkey.ws \
    --cc=lilei@linux.vnet.ibm.com \
    --cc=qemu-devel@nongnu.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.