Received: from eggs.gnu.org ([2001:4830:134:3::10]:34294) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1axUt9-0005mI-Vd for qemu-devel@nongnu.org; Tue, 03 May 2016 03:37:06 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1axUsy-00067L-8b for qemu-devel@nongnu.org; Tue, 03 May 2016 03:36:54 -0400 Received: from mx1.redhat.com ([209.132.183.28]:58475) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1axUsy-0005xH-3U for qemu-devel@nongnu.org; Tue, 03 May 2016 03:36:48 -0400 Received: from int-mx09.intmail.prod.int.phx2.redhat.com (int-mx09.intmail.prod.int.phx2.redhat.com [10.5.11.22]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id 4C58B85545 for ; Tue, 3 May 2016 07:36:33 +0000 (UTC) From: Markus Armbruster References: <1461903820-3092-1-git-send-email-eblake@redhat.com> <1461903820-3092-4-git-send-email-eblake@redhat.com> <87d1p839ci.fsf@dusky.pond.sub.org> <5723A078.2010408@redhat.com> Date: Tue, 03 May 2016 09:36:31 +0200 In-Reply-To: <5723A078.2010408@redhat.com> (Eric Blake's message of "Fri, 29 Apr 2016 11:57:12 -0600") Message-ID: <87mvo7bnk0.fsf@dusky.pond.sub.org> MIME-Version: 1.0 Content-Type: text/plain Subject: Re: [Qemu-devel] [PATCH v3 03/18] qapi: Factor out JSON string escaping List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: Eric Blake Cc: famz@redhat.com, qemu-devel@nongnu.org, Luiz Capitulino Eric Blake writes: > On 04/29/2016 06:09 AM, Markus Armbruster wrote: >> Eric Blake writes: >> >>> Pull out a new qstring_append_json_string() helper, so that all >>> JSON output producers can use the same output escaping rules. >>> >>> While it appears that vmstate's use of the simpler qjson.c >>> formatter is not currently encountering any string that needs >>> escapes to be valid JSON, it is better to be safe than sorry. >>> >>> Signed-off-by: Eric Blake >>> Reviewed-by: Fam Zheng > >>> - qstring_append(str, "\""); >>> + qstring_append_json_string(str, qstring_get_str(val)); >>> break; > >> I think this belongs to qobject-json.c, because it's very much about >> JSON (it encapsulates knowledge on JSON string escaping), and a mere >> user of QString (it knows nothing about QString's implementation). >> >> Precedence: qobject_from_json() & friends are there, not in qobject.c. > > Fair enough. Does the name qstring_append_json_string() still work, or > do I need to adjust the name to something with 'qobject' in there, to > make it easier to know which header and .c file to use for the function? I think the name is fine. If you strongly prefer to encode the source file in the identifier, you could use qobject_json_string_append_to_qstring(), but that's even longer, and less clear.