From: Eric Blake <eblake@redhat.com>
To: Markus Armbruster <armbru@redhat.com>
Cc: qemu-devel@nongnu.org, Kevin Wolf <kwolf@redhat.com>,
"open list:Block layer core" <qemu-block@nongnu.org>,
Chrysostomos Nanakos <chris@include.gr>,
Jeff Cody <jcody@redhat.com>,
Luiz Capitulino <lcapitulino@redhat.com>,
Max Reitz <mreitz@redhat.com>
Subject: Re: [Qemu-devel] [PATCH v4 21/28] qstring: Add qstring_wrap_str()
Date: Thu, 9 Jun 2016 10:31:42 -0600 [thread overview]
Message-ID: <575999EE.1000806@redhat.com> (raw)
In-Reply-To: <87y46nd3b0.fsf@dusky.pond.sub.org>
[-- Attachment #1: Type: text/plain, Size: 1356 bytes --]
On 06/02/2016 09:21 AM, Markus Armbruster wrote:
> Eric Blake <eblake@redhat.com> writes:
>
>> Several spots in the code malloc a string, then wrap it in a
>> QString, which has to duplicate the input. Adding a new
>> constructor with transfer semantics makes this pattern more
>> efficient, comparable to the just-added transfer semantics to
>> go from QString back to raw string. Use the new
>> qstring_wrap_str() where it makes sense.
>>
>> The new test still passes under valgrind.
>>
>> Signed-off-by: Eric Blake <eblake@redhat.com>
>>
>> +++ b/qobject/qstring.c
>> @@ -66,6 +66,31 @@ QString *qstring_from_str(const char *str)
>> return qstring_from_substr(str, 0, strlen(str) - 1);
>> }
>>
>> +/**
>> + * qstring_wrap_str(): Create a new QString around a malloc'd C string
>> + *
>> + * Returns a strong reference, and caller must not use @str any more.
>> + * @str may be NULL, in which case the QString will be "".
>
> I'm not fond of conflating null pointers and "" (see also the trouble
> with visit_type_str()). For what it's worth, qstring_from_str(NULL)
> crashes. Can we reject null?
Probably. I'll add an assert, and update the interface to match if
things still pass with my usage.
--
Eric Blake eblake redhat com +1-919-301-3266
Libvirt virtualization library http://libvirt.org
[-- Attachment #2: OpenPGP digital signature --]
[-- Type: application/pgp-signature, Size: 604 bytes --]
next prev parent reply other threads:[~2016-06-09 16:31 UTC|newest]
Thread overview: 71+ messages / expand[flat|nested] mbox.gz Atom feed top
2016-05-19 4:40 [Qemu-devel] [PATCH v4 00/28] Add qapi-to-JSON and clone visitors Eric Blake
2016-05-19 4:40 ` [Qemu-devel] [PATCH v4 01/28] qapi: Rename (one) qjson.h to qobject-json.h Eric Blake
2016-06-01 15:09 ` Markus Armbruster
2016-05-19 4:40 ` [Qemu-devel] [PATCH v4 02/28] qapi: Improve use of qmp/types.h Eric Blake
2016-05-19 4:40 ` [Qemu-devel] [PATCH v4 03/28] qemu-img: Don't leak errors when outputting JSON Eric Blake
2016-06-01 15:25 ` Markus Armbruster
2016-05-19 4:40 ` [Qemu-devel] [PATCH v4 04/28] qapi: Add parameter to visit_end_* Eric Blake
2016-06-01 15:36 ` Markus Armbruster
2016-06-07 23:20 ` Eric Blake
2016-05-19 4:40 ` [Qemu-devel] [PATCH v4 05/28] qapi: Add new visit_free() function Eric Blake
2016-06-01 16:03 ` Markus Armbruster
2016-06-03 11:46 ` Markus Armbruster
2016-05-19 4:40 ` [Qemu-devel] [PATCH v4 06/28] opts-visitor: Favor " Eric Blake
2016-06-01 16:06 ` Markus Armbruster
2016-05-19 4:40 ` [Qemu-devel] [PATCH v4 07/28] string-input-visitor: " Eric Blake
2016-06-01 16:13 ` Markus Armbruster
2016-05-19 4:40 ` [Qemu-devel] [PATCH v4 08/28] qmp-input-visitor: " Eric Blake
2016-06-01 16:19 ` Markus Armbruster
2016-05-19 4:40 ` [Qemu-devel] [PATCH v4 09/28] string-output-visitor: " Eric Blake
2016-05-19 4:40 ` [Qemu-devel] [PATCH v4 10/28] qmp-output-visitor: " Eric Blake
2016-05-19 4:40 ` [Qemu-devel] [PATCH v4 11/28] tests: Factor out common code in qapi output tests Eric Blake
2016-06-01 16:33 ` Markus Armbruster
2016-05-19 4:40 ` [Qemu-devel] [PATCH v4 12/28] qapi: Add new visit_complete() function Eric Blake
2016-06-01 17:02 ` Markus Armbruster
2016-05-19 4:40 ` [Qemu-devel] [PATCH v4 13/28] qapi: Add new clone visitor Eric Blake
2016-06-02 13:43 ` Markus Armbruster
2016-06-03 14:04 ` Markus Armbruster
2016-06-09 4:15 ` Eric Blake
2016-05-19 4:41 ` [Qemu-devel] [PATCH v4 14/28] sockets: Use new QAPI cloning Eric Blake
2016-05-19 4:41 ` [Qemu-devel] [PATCH v4 15/28] replay: " Eric Blake
2016-05-19 4:41 ` [Qemu-devel] [PATCH v4 16/28] qapi: Factor out JSON string escaping Eric Blake
2016-06-02 14:53 ` Markus Armbruster
2016-05-19 4:41 ` [Qemu-devel] [PATCH v4 17/28] qapi: Factor out JSON number formatting Eric Blake
2016-06-02 15:02 ` Markus Armbruster
2016-06-02 15:06 ` Eric Blake
2016-06-03 9:02 ` Markus Armbruster
2016-06-09 16:07 ` Eric Blake
2016-06-13 8:22 ` Markus Armbruster
2016-06-13 12:34 ` Eric Blake
2016-06-13 14:41 ` Markus Armbruster
2016-05-19 4:41 ` [Qemu-devel] [PATCH v4 18/28] qapi: Add qstring_append_printf() Eric Blake
2016-05-19 4:41 ` [Qemu-devel] [PATCH v4 19/28] qapi: Use qstring_append_chr() where appropriate Eric Blake
2016-05-19 4:41 ` [Qemu-devel] [PATCH v4 20/28] qstring: Add qstring_consume_str() Eric Blake
2016-05-19 4:41 ` [Qemu-devel] [PATCH v4 21/28] qstring: Add qstring_wrap_str() Eric Blake
2016-06-02 15:21 ` Markus Armbruster
2016-06-09 16:31 ` Eric Blake [this message]
2016-05-19 4:41 ` [Qemu-devel] [PATCH v4 22/28] qobject: Consolidate qobject_to_json() calls Eric Blake
2016-06-02 15:32 ` Markus Armbruster
2016-05-19 4:41 ` [Qemu-devel] [PATCH v4 23/28] tests: Test qobject_to_json() pretty formatting Eric Blake
2016-05-19 4:41 ` [Qemu-devel] [PATCH v4 24/28] qapi: Add JSON output visitor Eric Blake
2016-06-03 7:39 ` Markus Armbruster
2016-06-03 12:53 ` Eric Blake
2016-06-03 14:09 ` Markus Armbruster
2016-05-19 4:41 ` [Qemu-devel] [PATCH v4 25/28] qapi: Support pretty printing in " Eric Blake
2016-06-03 7:56 ` Markus Armbruster
2016-06-03 12:55 ` Eric Blake
2016-06-03 14:08 ` Markus Armbruster
2016-05-19 4:41 ` [Qemu-devel] [PATCH v4 26/28] qobject: Implement qobject_to_json() atop JSON visitor Eric Blake
2016-06-03 8:25 ` Markus Armbruster
2016-05-19 4:41 ` [Qemu-devel] [PATCH v4 27/28] qapi: Add 'any' support to JSON output Eric Blake
2016-06-03 8:29 ` Markus Armbruster
2016-05-19 4:41 ` [Qemu-devel] [PATCH v4 28/28] qemu-img: Use new JSON output formatter Eric Blake
2016-05-19 14:58 ` [Qemu-devel] [PATCH v4 00/28] Add qapi-to-JSON and clone visitors Eric Blake
2016-05-19 16:52 ` [Qemu-devel] [PATCH v4 29/28] qapi: Add strict mode to JSON output visitor Eric Blake
2016-05-19 20:18 ` Eric Blake
2016-06-03 8:36 ` Markus Armbruster
2016-06-03 9:21 ` Markus Armbruster
2016-05-19 17:05 ` [Qemu-devel] [PATCH v4 00/28] Add qapi-to-JSON and clone visitors Markus Armbruster
2016-06-03 12:09 ` Markus Armbruster
2016-06-09 16:16 ` Eric Blake
2016-06-13 8:26 ` Markus Armbruster
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=575999EE.1000806@redhat.com \
--to=eblake@redhat.com \
--cc=armbru@redhat.com \
--cc=chris@include.gr \
--cc=jcody@redhat.com \
--cc=kwolf@redhat.com \
--cc=lcapitulino@redhat.com \
--cc=mreitz@redhat.com \
--cc=qemu-block@nongnu.org \
--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).