qemu-devel.nongnu.org archive mirror
 help / color / mirror / Atom feed
From: Anthony Liguori <anthony@codemonkey.ws>
To: Michael Roth <mdroth@linux.vnet.ibm.com>
Cc: aliguori@linux.vnet.ibm.com, lcapitulino@redhat.com,
	agl@linux.vnet.ibm.com, qemu-devel@nongnu.org,
	Jes.Sorensen@redhat.com
Subject: Re: [Qemu-devel] [PATCH v1][ 01/14] QError: Introduce qerror_format_desc()
Date: Tue, 07 Jun 2011 14:18:07 -0500	[thread overview]
Message-ID: <4DEE796F.5000000@codemonkey.ws> (raw)
In-Reply-To: <1306948500-15086-2-git-send-email-mdroth@linux.vnet.ibm.com>

On 06/01/2011 12:14 PM, Michael Roth wrote:
> From: Luiz Capitulino<lcapitulino@redhat.com>
>
> Refactor non-QError-specific bits out of qerror_human() into general
> function that can be used by the error_get_pretty() analogue in the
> new error-propagation framework.
>
> Signed-off-by: Luiz Capitulino<lcapitulino@redhat.com>
> Signed-off-by: Michael Roth<mdroth@linux.vnet.ibm.com>

Applied series1.  Thanks.

Regards,

Anthony Liguori

> ---
>   qerror.c |   44 +++++++++++++++++++++++++-------------------
>   1 files changed, 25 insertions(+), 19 deletions(-)
>
> diff --git a/qerror.c b/qerror.c
> index 4855604..af6ed39 100644
> --- a/qerror.c
> +++ b/qerror.c
> @@ -326,12 +326,14 @@ QError *qerror_from_info(const char *file, int linenr, const char *func,
>       return qerr;
>   }
>
> -static void parse_error(const QError *qerror, int c)
> +static void parse_error(const QErrorStringTable *entry, int c)
>   {
> -    qerror_abort(qerror, "expected '%c' in '%s'", c, qerror->entry->desc);
> +    fprintf(stderr, "expected '%c' in '%s'", c, entry->desc);
> +    abort();
>   }
>
> -static const char *append_field(QString *outstr, const QError *qerror,
> +static const char *append_field(QDict *error, QString *outstr,
> +                                const QErrorStringTable *entry,
>                                   const char *start)
>   {
>       QObject *obj;
> @@ -340,23 +342,23 @@ static const char *append_field(QString *outstr, const QError *qerror,
>       const char *end, *key;
>
>       if (*start != '%')
> -        parse_error(qerror, '%');
> +        parse_error(entry, '%');
>       start++;
>       if (*start != '(')
> -        parse_error(qerror, '(');
> +        parse_error(entry, '(');
>       start++;
>
>       end = strchr(start, ')');
>       if (!end)
> -        parse_error(qerror, ')');
> +        parse_error(entry, ')');
>
>       key_qs = qstring_from_substr(start, 0, end - start - 1);
>       key = qstring_get_str(key_qs);
>
> -    qdict = qobject_to_qdict(qdict_get(qerror->error, "data"));
> +    qdict = qobject_to_qdict(qdict_get(error, "data"));
>       obj = qdict_get(qdict, key);
>       if (!obj) {
> -        qerror_abort(qerror, "key '%s' not found in QDict", key);
> +        abort();
>       }
>
>       switch (qobject_type(obj)) {
> @@ -367,35 +369,31 @@ static const char *append_field(QString *outstr, const QError *qerror,
>               qstring_append_int(outstr, qdict_get_int(qdict, key));
>               break;
>           default:
> -            qerror_abort(qerror, "invalid type '%c'", qobject_type(obj));
> +            abort();
>       }
>
>       QDECREF(key_qs);
>       return ++end;
>   }
>
> -/**
> - * qerror_human(): Format QError data into human-readable string.
> - *
> - * Formats according to member 'desc' of the specified QError object.
> - */
> -QString *qerror_human(const QError *qerror)
> +static QString *qerror_format_desc(QDict *error,
> +                                   const QErrorStringTable *entry)
>   {
> -    const char *p;
>       QString *qstring;
> +    const char *p;
>
> -    assert(qerror->entry != NULL);
> +    assert(entry != NULL);
>
>       qstring = qstring_new();
>
> -    for (p = qerror->entry->desc; *p != '\0';) {
> +    for (p = entry->desc; *p != '\0';) {
>           if (*p != '%') {
>               qstring_append_chr(qstring, *p++);
>           } else if (*(p + 1) == '%') {
>               qstring_append_chr(qstring, '%');
>               p += 2;
>           } else {
> -            p = append_field(qstring, qerror, p);
> +            p = append_field(error, qstring, entry, p);
>           }
>       }
>
> @@ -403,6 +401,14 @@ QString *qerror_human(const QError *qerror)
>   }
>
>   /**
> + * qerror_human(): Format QError data into human-readable string.
> + */
> +QString *qerror_human(const QError *qerror)
> +{
> +    return qerror_format_desc(qerror->error, qerror->entry);
> +}
> +
> +/**
>    * qerror_print(): Print QError data
>    *
>    * This function will print the member 'desc' of the specified QError object,

  reply	other threads:[~2011-06-07 19:18 UTC|newest]

Thread overview: 16+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2011-06-01 17:14 [Qemu-devel] [QAPI+QGA 1/3] Error propagation and JSON parser fix-ups Michael Roth
2011-06-01 17:14 ` [Qemu-devel] [PATCH v1][ 01/14] QError: Introduce qerror_format_desc() Michael Roth
2011-06-07 19:18   ` Anthony Liguori [this message]
2011-06-01 17:14 ` [Qemu-devel] [PATCH v1][ 02/14] QError: Introduce qerror_format() Michael Roth
2011-06-01 17:14 ` [Qemu-devel] [PATCH v1][ 03/14] Introduce the new error framework Michael Roth
2011-06-01 17:14 ` [Qemu-devel] [PATCH v1][ 04/14] json-parser: propagate error from parser Michael Roth
2011-06-01 17:14 ` [Qemu-devel] [PATCH v1][ 05/14] json-streamer: allow recovery after bad input Michael Roth
2011-06-01 17:14 ` [Qemu-devel] [PATCH v1][ 06/14] json-lexer: limit the maximum size of a given token Michael Roth
2011-06-01 17:14 ` [Qemu-devel] [PATCH v1][ 07/14] json-streamer: limit the maximum recursion depth and maximum token count Michael Roth
2011-06-01 17:14 ` [Qemu-devel] [PATCH v1][ 08/14] json-streamer: make sure to reset token_size after emitting a token list Michael Roth
2011-06-01 17:14 ` [Qemu-devel] [PATCH v1][ 09/14] json-parser: detect premature EOI Michael Roth
2011-06-01 17:14 ` [Qemu-devel] [PATCH v1][ 10/14] json-lexer: reset the lexer state on an invalid token Michael Roth
2011-06-01 17:14 ` [Qemu-devel] [PATCH v1][ 11/14] json-lexer: fix flushing logic to not always go to error state Michael Roth
2011-06-01 17:14 ` [Qemu-devel] [PATCH v1][ 12/14] json-lexer: make lexer error-recovery more deterministic Michael Roth
2011-06-01 17:14 ` [Qemu-devel] [PATCH v1][ 13/14] json-streamer: add handling for JSON_ERROR token/state Michael Roth
2011-06-01 17:15 ` [Qemu-devel] [PATCH v1][ 14/14] json-parser: add handling for NULL token list Michael Roth

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=4DEE796F.5000000@codemonkey.ws \
    --to=anthony@codemonkey.ws \
    --cc=Jes.Sorensen@redhat.com \
    --cc=agl@linux.vnet.ibm.com \
    --cc=aliguori@linux.vnet.ibm.com \
    --cc=lcapitulino@redhat.com \
    --cc=mdroth@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 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).