From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from eggs.gnu.org ([2001:4830:134:3::10]:54363) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1Wsu4X-0004t1-Gg for qemu-devel@nongnu.org; Fri, 06 Jun 2014 09:20:50 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1Wsu4O-0000AM-9q for qemu-devel@nongnu.org; Fri, 06 Jun 2014 09:20:41 -0400 Received: from mail-we0-x230.google.com ([2a00:1450:400c:c03::230]:53856) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1Wsu4O-000099-25 for qemu-devel@nongnu.org; Fri, 06 Jun 2014 09:20:32 -0400 Received: by mail-we0-f176.google.com with SMTP id q59so2754767wes.21 for ; Fri, 06 Jun 2014 06:20:31 -0700 (PDT) Date: Fri, 6 Jun 2014 15:20:28 +0200 From: Stefan Hajnoczi Message-ID: <20140606132028.GG14322@stefanha-thinkpad> References: <1402017120-27655-1-git-send-email-akong@redhat.com> <1402017120-27655-3-git-send-email-akong@redhat.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <1402017120-27655-3-git-send-email-akong@redhat.com> Subject: Re: [Qemu-devel] [PATCH v3 2/4] qtest: introduce qmp_exec_hmp_cmd() List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: Amos Kong Cc: arei.gonglei@huawei.com, qemu-devel@nongnu.org, afaerber@suse.de On Fri, Jun 06, 2014 at 09:11:58AM +0800, Amos Kong wrote: > +void qmp_exec_hmp_cmd(const char *expected_ret, const char *fmt, ...) > +{ > + va_list ap; > + char cmd[1024]; > + char *escaped_cmd; > + QDict *response; > + const char *response_return; > + > + va_start(ap, fmt); > + vsprintf(cmd, fmt, ap); > + va_end(ap); > + > + escaped_cmd = g_strescape(cmd, NULL); > + response = qmp("{\"execute\": \"human-monitor-command\"," > + " \"arguments\": {" > + " \"command-line\": \"%s\"" > + "}}", escaped_cmd); > + free(escaped_cmd); glib uses g_malloc()/g_free() instead of malloc()/free(). Please use g_free() since the string comes from g_strescape().