Blame SOURCES/kvm-qjson-Inline-token_is_escape-and-simplify.patch

34b321
From 225cb3d48dd4dcbc7bf845c0b4b06a90030874f3 Mon Sep 17 00:00:00 2001
34b321
From: Markus Armbruster <armbru@redhat.com>
34b321
Date: Wed, 27 Jul 2016 07:35:06 +0200
34b321
Subject: [PATCH 08/16] qjson: Inline token_is_escape() and simplify
34b321
34b321
RH-Author: Markus Armbruster <armbru@redhat.com>
34b321
Message-id: <1469604913-12442-10-git-send-email-armbru@redhat.com>
34b321
Patchwork-id: 71479
34b321
O-Subject: [RHEL-7.3 qemu-kvm PATCH v2 08/15] qjson: Inline token_is_escape() and simplify
34b321
Bugzilla: 1276036
34b321
RH-Acked-by: Miroslav Rezanina <mrezanin@redhat.com>
34b321
RH-Acked-by: John Snow <jsnow@redhat.com>
34b321
RH-Acked-by: Paolo Bonzini <pbonzini@redhat.com>
34b321
34b321
Signed-off-by: Markus Armbruster <armbru@redhat.com>
34b321
Message-Id: <1448486613-17634-8-git-send-email-armbru@redhat.com>
34b321
Reviewed-by: Eric Blake <eblake@redhat.com>
34b321
(cherry picked from commit 6b9606f68ec589def27bd2a9cea97ec63cffd581)
34b321
Signed-off-by: Miroslav Rezanina <mrezanin@redhat.com>
34b321
34b321
Conflicts:
34b321
	qobject/json-parser.c
34b321
34b321
Straighforward conflict because lacking commit fc48ffc "qobject: Use
34b321
'bool' for qbool", we still use qbool_from_int().
34b321
34b321
Signed-off-by: Markus Armbruster <armbru@redhat.com>
34b321
---
34b321
 qobject/json-parser.c | 32 +++++++++++++++-----------------
34b321
 1 file changed, 15 insertions(+), 17 deletions(-)
34b321
34b321
diff --git a/qobject/json-parser.c b/qobject/json-parser.c
34b321
index e3690de..79f4173 100644
34b321
--- a/qobject/json-parser.c
34b321
+++ b/qobject/json-parser.c
34b321
@@ -64,15 +64,6 @@ static JSONTokenType token_get_type(QObject *obj)
34b321
     return qdict_get_int(qobject_to_qdict(obj), "type");
34b321
 }
34b321
 
34b321
-static int token_is_escape(QObject *obj, const char *value)
34b321
-{
34b321
-    if (token_get_type(obj) != JSON_ESCAPE) {
34b321
-        return 0;
34b321
-    }
34b321
-
34b321
-    return (strcmp(token_get_value(obj), value) == 0);
34b321
-}
34b321
-
34b321
 /**
34b321
  * Error handler
34b321
  */
34b321
@@ -559,6 +550,7 @@ static QObject *parse_escape(JSONParserContext *ctxt, va_list *ap)
34b321
 {
34b321
     QObject *token = NULL, *obj;
34b321
     JSONParserContext saved_ctxt = parser_context_save(ctxt);
34b321
+    const char *val;
34b321
 
34b321
     if (ap == NULL) {
34b321
         goto out;
34b321
@@ -569,20 +561,26 @@ static QObject *parse_escape(JSONParserContext *ctxt, va_list *ap)
34b321
         goto out;
34b321
     }
34b321
 
34b321
-    if (token_is_escape(token, "%p")) {
34b321
+    if (token_get_type(token) != JSON_ESCAPE) {
34b321
+        goto out;
34b321
+    }
34b321
+
34b321
+    val = token_get_value(token);
34b321
+
34b321
+    if (!strcmp(val, "%p")) {
34b321
         obj = va_arg(*ap, QObject *);
34b321
-    } else if (token_is_escape(token, "%i")) {
34b321
+    } else if (!strcmp(val, "%i")) {
34b321
         obj = QOBJECT(qbool_from_int(va_arg(*ap, int)));
34b321
-    } else if (token_is_escape(token, "%d")) {
34b321
+    } else if (!strcmp(val, "%d")) {
34b321
         obj = QOBJECT(qint_from_int(va_arg(*ap, int)));
34b321
-    } else if (token_is_escape(token, "%ld")) {
34b321
+    } else if (!strcmp(val, "%ld")) {
34b321
         obj = QOBJECT(qint_from_int(va_arg(*ap, long)));
34b321
-    } else if (token_is_escape(token, "%lld") ||
34b321
-               token_is_escape(token, "%I64d")) {
34b321
+    } else if (!strcmp(val, "%lld") ||
34b321
+               !strcmp(val, "%I64d")) {
34b321
         obj = QOBJECT(qint_from_int(va_arg(*ap, long long)));
34b321
-    } else if (token_is_escape(token, "%s")) {
34b321
+    } else if (!strcmp(val, "%s")) {
34b321
         obj = QOBJECT(qstring_from_str(va_arg(*ap, const char *)));
34b321
-    } else if (token_is_escape(token, "%f")) {
34b321
+    } else if (!strcmp(val, "%f")) {
34b321
         obj = QOBJECT(qfloat_from_double(va_arg(*ap, double)));
34b321
     } else {
34b321
         goto out;
34b321
-- 
34b321
1.8.3.1
34b321