From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from eggs.gnu.org ([2001:4830:134:3::10]:57022) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1XW9oT-00006g-Nn for qemu-devel@nongnu.org; Mon, 22 Sep 2014 16:02:26 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1XW9oO-0008M3-FG for qemu-devel@nongnu.org; Mon, 22 Sep 2014 16:02:21 -0400 Received: from mail-oi0-f43.google.com ([209.85.218.43]:50547) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1XW9oO-0008Lc-At for qemu-devel@nongnu.org; Mon, 22 Sep 2014 16:02:16 -0400 Received: by mail-oi0-f43.google.com with SMTP id v63so3827757oia.16 for ; Mon, 22 Sep 2014 13:02:09 -0700 (PDT) Message-ID: <5420803E.5090804@mvista.com> Date: Mon, 22 Sep 2014 15:02:06 -0500 From: Corey Minyard MIME-Version: 1.0 References: <1411405169-820-1-git-send-email-minyard@acm.org> <1411405169-820-2-git-send-email-minyard@acm.org> In-Reply-To: Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 7bit Subject: Re: [Qemu-devel] [PATCH 1/6] qemu-char: Make the filename size for a chardev a #define List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: Peter Maydell , minyard@acm.org Cc: mjg59@srcf.ucam.org, "Michael S. Tsirkin" , hwd@huawei.com, QEMU Developers , bcketchum@gmail.com, =?UTF-8?B?QW5kcmVhcyBGw6RyYmVy?= On 09/22/2014 12:20 PM, Peter Maydell wrote: > On 22 September 2014 09:59, wrote: >> From: Corey Minyard >> >> Signed-off-by: Corey Minyard >> Reviewed-by: Paolo Bonzini > Wouldn't it be better to just drop the max-size restriction > by using g_strdup_printf (and then free when done) rather than > snprintf into a fixed size buffer? > > thanks > -- PMM I'm not sure. I was trying to minimize changes, but I did this because the malloc and snprintf were being moved apart from each other. This is also being used in some arrays declared on the stack, which also might need fixing. There may be race conditions with the filename if you free it and replace it, but I'm not really sure. Someone who knows better than me would have to speak to that. -corey