[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[PATCH 19/20] block: Use GString instead of QString to build filenames
From: |
Markus Armbruster |
Subject: |
[PATCH 19/20] block: Use GString instead of QString to build filenames |
Date: |
Fri, 11 Dec 2020 18:11:51 +0100 |
QString supports modifying its string, but it's quite limited: you can
only append. Just one caller remains:
bdrv_parse_filename_strip_prefix() uses it just for building an
initial string.
Change it to do build the initial string with GString. This is
another step towards making QString immutable.
Cc: Kevin Wolf <kwolf@redhat.com>
Cc: Max Reitz <mreitz@redhat.com>
Cc: qemu-block@nongnu.org
Signed-off-by: Markus Armbruster <armbru@redhat.com>
---
block.c | 11 ++++++-----
1 file changed, 6 insertions(+), 5 deletions(-)
diff --git a/block.c b/block.c
index 94d3a15081..75ffbe9092 100644
--- a/block.c
+++ b/block.c
@@ -216,7 +216,7 @@ void bdrv_parse_filename_strip_prefix(const char *filename,
const char *prefix,
/* Stripping the explicit protocol prefix may result in a protocol
* prefix being (wrongly) detected (if the filename contains a colon)
*/
if (path_has_protocol(filename)) {
- QString *fat_filename;
+ GString *fat_filename;
/* This means there is some colon before the first slash;
therefore,
* this cannot be an absolute path */
@@ -224,12 +224,13 @@ void bdrv_parse_filename_strip_prefix(const char
*filename, const char *prefix,
/* And we can thus fix the protocol detection issue by prefixing it
* by "./" */
- fat_filename = qstring_from_str("./");
- qstring_append(fat_filename, filename);
+ fat_filename = g_string_new("./");
+ g_string_append(fat_filename, filename);
- assert(!path_has_protocol(qstring_get_str(fat_filename)));
+ assert(!path_has_protocol(fat_filename->str));
- qdict_put(options, "filename", fat_filename);
+ qdict_put(options, "filename",
+ qstring_from_gstring(fat_filename));
} else {
/* If no protocol prefix was detected, we can use the shortened
* filename as-is */
--
2.26.2
- [PATCH 00/20] Immutable QString, and also one JSON writer less, Markus Armbruster, 2020/12/11
- [PATCH 02/20] monitor: Use GString instead of QString for output buffer, Markus Armbruster, 2020/12/11
- [PATCH 04/20] qobject: Use GString instead of QString to accumulate JSON, Markus Armbruster, 2020/12/11
- [PATCH 14/20] qobject: Factor quoted_str() out of to_json(), Markus Armbruster, 2020/12/11
- [PATCH 08/20] qobject: Move internals to qobject-internal.h, Markus Armbruster, 2020/12/11
- [PATCH 05/20] qobject: Change qobject_to_json()'s value to GString, Markus Armbruster, 2020/12/11
- [PATCH 06/20] Revert "qstring: add qstring_free()", Markus Armbruster, 2020/12/11
- [PATCH 12/20] qobject: Drop qobject_get_try_str(), Markus Armbruster, 2020/12/11
- [PATCH 19/20] block: Use GString instead of QString to build filenames,
Markus Armbruster <=
- [PATCH 09/20] qmp: Fix tracing of non-string command IDs, Markus Armbruster, 2020/12/11
- [PATCH 03/20] qobject: Make qobject_to_json_pretty() take a pretty argument, Markus Armbruster, 2020/12/11
- [PATCH 07/20] hw/rdma: Replace QList by GQueue, Markus Armbruster, 2020/12/11
- [PATCH 10/20] block: Avoid qobject_get_try_str(), Markus Armbruster, 2020/12/11
- [PATCH 15/20] qobject: Factor JSON writer out of qobject_to_json(), Markus Armbruster, 2020/12/11
- [PATCH 20/20] qobject: Make QString immutable, Markus Armbruster, 2020/12/11
- [PATCH 18/20] keyval: Use GString to accumulate value strings, Markus Armbruster, 2020/12/11