qemu-devel.nongnu.org archive mirror
 help / color / mirror / Atom feed
From: Markus Armbruster <armbru@redhat.com>
To: qemu-devel@nongnu.org
Cc: mdroth@linux.vnet.ibm.com
Subject: [PATCH 13/20] qobject: Drop qstring_get_try_str()
Date: Fri, 11 Dec 2020 18:11:45 +0100	[thread overview]
Message-ID: <20201211171152.146877-14-armbru@redhat.com> (raw)
In-Reply-To: <20201211171152.146877-1-armbru@redhat.com>

No users left outside tests/, and the ones in tests/ can just as well
use qstring_get_str().  Do that, and drop the function.

Signed-off-by: Markus Armbruster <armbru@redhat.com>
---
 include/qapi/qmp/qstring.h |  1 -
 qobject/qstring.c          | 10 ----------
 tests/check-qjson.c        | 11 +++++------
 3 files changed, 5 insertions(+), 17 deletions(-)

diff --git a/include/qapi/qmp/qstring.h b/include/qapi/qmp/qstring.h
index 56034dae54..53567db6c0 100644
--- a/include/qapi/qmp/qstring.h
+++ b/include/qapi/qmp/qstring.h
@@ -28,7 +28,6 @@ QString *qstring_from_substr(const char *str, size_t start, size_t end);
 QString *qstring_from_gstring(GString *gstr);
 size_t qstring_get_length(const QString *qstring);
 const char *qstring_get_str(const QString *qstring);
-const char *qstring_get_try_str(const QString *qstring);
 void qstring_append_int(QString *qstring, int64_t value);
 void qstring_append(QString *qstring, const char *str);
 void qstring_append_chr(QString *qstring, int c);
diff --git a/qobject/qstring.c b/qobject/qstring.c
index cfe3f3bf00..ea86d80cf0 100644
--- a/qobject/qstring.c
+++ b/qobject/qstring.c
@@ -139,16 +139,6 @@ const char *qstring_get_str(const QString *qstring)
     return qstring->string;
 }
 
-/**
- * qstring_get_try_str(): Return a pointer to the stored string
- *
- * NOTE: will return NULL if qstring is not provided.
- */
-const char *qstring_get_try_str(const QString *qstring)
-{
-    return qstring ? qstring_get_str(qstring) : NULL;
-}
-
 /**
  * qstring_is_equal(): Test whether the two QStrings are equal
  */
diff --git a/tests/check-qjson.c b/tests/check-qjson.c
index 337add0838..c845f91d43 100644
--- a/tests/check-qjson.c
+++ b/tests/check-qjson.c
@@ -89,7 +89,7 @@ static void escaped_string(void)
         for (j = 0; j < 2; j++) {
             if (test_cases[i].utf8_out) {
                 cstr = from_json_str(test_cases[i].json_in, j, &error_abort);
-                g_assert_cmpstr(qstring_get_try_str(cstr),
+                g_assert_cmpstr(qstring_get_str(cstr),
                                 ==, test_cases[i].utf8_out);
                 if (!test_cases[i].skip) {
                     jstr = to_json_str(cstr);
@@ -751,7 +751,7 @@ static void utf8_string(void)
             /* Parse @json_in, expect @utf8_out */
             if (utf8_out) {
                 str = from_json_str(json_in, j, &error_abort);
-                g_assert_cmpstr(qstring_get_try_str(str), ==, utf8_out);
+                g_assert_cmpstr(qstring_get_str(str), ==, utf8_out);
                 qobject_unref(str);
             } else {
                 str = from_json_str(json_in, j, NULL);
@@ -782,7 +782,7 @@ static void utf8_string(void)
             /* Parse @json_out right back, unless it has replacements */
             if (!strstr(json_out, "\\uFFFD")) {
                 str = from_json_str(json_out, j, &error_abort);
-                g_assert_cmpstr(qstring_get_try_str(str), ==, utf8_in);
+                g_assert_cmpstr(qstring_get_str(str), ==, utf8_in);
                 qobject_unref(str);
             }
         }
@@ -1021,9 +1021,8 @@ static void interpolation_valid(void)
 
     /* string */
 
-    qstr = qobject_to(QString,
-                     qobject_from_jsonf_nofail("%s", value_s));
-    g_assert_cmpstr(qstring_get_try_str(qstr), ==, value_s);
+    qstr = qobject_to(QString, qobject_from_jsonf_nofail("%s", value_s));
+    g_assert_cmpstr(qstring_get_str(qstr), ==, value_s);
     qobject_unref(qstr);
 
     /* object */
-- 
2.26.2



  parent reply	other threads:[~2020-12-11 18:07 UTC|newest]

Thread overview: 36+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2020-12-11 17:11 [PATCH 00/20] Immutable QString, and also one JSON writer less Markus Armbruster
2020-12-11 17:11 ` [PATCH 01/20] hmp: Simplify how qmp_human_monitor_command() gets output Markus Armbruster
2020-12-16 18:53   ` Dr. David Alan Gilbert
2020-12-11 17:11 ` [PATCH 02/20] monitor: Use GString instead of QString for output buffer Markus Armbruster
2020-12-16 19:36   ` Dr. David Alan Gilbert
2020-12-11 17:11 ` [PATCH 03/20] qobject: Make qobject_to_json_pretty() take a pretty argument Markus Armbruster
2020-12-11 17:11 ` [PATCH 04/20] qobject: Use GString instead of QString to accumulate JSON Markus Armbruster
2020-12-11 17:11 ` [PATCH 05/20] qobject: Change qobject_to_json()'s value to GString Markus Armbruster
2021-03-24  7:16   ` Thomas Huth
2021-03-24  8:14     ` Markus Armbruster
2020-12-11 17:11 ` [PATCH 06/20] Revert "qstring: add qstring_free()" Markus Armbruster
2020-12-11 17:11 ` [PATCH 07/20] hw/rdma: Replace QList by GQueue Markus Armbruster
2020-12-11 17:11 ` [PATCH 08/20] qobject: Move internals to qobject-internal.h Markus Armbruster
2020-12-11 17:11 ` [PATCH 09/20] qmp: Fix tracing of non-string command IDs Markus Armbruster
2020-12-11 17:11 ` [PATCH 10/20] block: Avoid qobject_get_try_str() Markus Armbruster
2020-12-11 18:28   ` Vladimir Sementsov-Ogievskiy
2020-12-11 17:11 ` [PATCH 11/20] Revert "qobject: let object_property_get_str() use new API" Markus Armbruster
2020-12-11 19:48   ` Eduardo Habkost
2020-12-11 17:11 ` [PATCH 12/20] qobject: Drop qobject_get_try_str() Markus Armbruster
2020-12-11 17:11 ` Markus Armbruster [this message]
2020-12-11 17:11 ` [PATCH 14/20] qobject: Factor quoted_str() out of to_json() Markus Armbruster
2020-12-11 17:11 ` [PATCH 15/20] qobject: Factor JSON writer out of qobject_to_json() Markus Armbruster
2020-12-11 17:11 ` [PATCH 16/20] migration: Replace migration's JSON writer by the general one Markus Armbruster
2020-12-16 19:46   ` Dr. David Alan Gilbert
2020-12-17  7:10     ` Markus Armbruster
2020-12-17  9:38       ` Dr. David Alan Gilbert
2020-12-17 10:32       ` Dr. David Alan Gilbert
2020-12-11 17:11 ` [PATCH 17/20] json: Use GString instead of QString to accumulate strings Markus Armbruster
2020-12-11 17:11 ` [PATCH 18/20] keyval: Use GString to accumulate value strings Markus Armbruster
2020-12-22  9:56   ` Paolo Bonzini
2021-01-11 13:05     ` Markus Armbruster
2021-01-11 13:51       ` Paolo Bonzini
2020-12-11 17:11 ` [PATCH 19/20] block: Use GString instead of QString to build filenames Markus Armbruster
2020-12-11 18:47   ` Vladimir Sementsov-Ogievskiy
2020-12-11 17:11 ` [PATCH 20/20] qobject: Make QString immutable Markus Armbruster
2020-12-22  9:59 ` [PATCH 00/20] Immutable QString, and also one JSON writer less Paolo Bonzini

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=20201211171152.146877-14-armbru@redhat.com \
    --to=armbru@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).