From patchwork Sun Dec 8 22:59:06 2013 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Peter Maydell X-Patchwork-Id: 298902 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Received: from lists.gnu.org (lists.gnu.org [IPv6:2001:4830:134:3::11]) (using TLSv1 with cipher AES256-SHA (256/256 bits)) (Client did not present a certificate) by ozlabs.org (Postfix) with ESMTPS id 5C66E2C0087 for ; Mon, 9 Dec 2013 09:59:58 +1100 (EST) Received: from localhost ([::1]:41107 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1VpnKN-0005Ea-Cl for incoming@patchwork.ozlabs.org; Sun, 08 Dec 2013 17:59:55 -0500 Received: from eggs.gnu.org ([2001:4830:134:3::10]:42333) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1VpnJi-0004op-58 for qemu-devel@nongnu.org; Sun, 08 Dec 2013 17:59:15 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1VpnJd-0003M0-PB for qemu-devel@nongnu.org; Sun, 08 Dec 2013 17:59:14 -0500 Received: from mnementh.archaic.org.uk ([2001:8b0:1d0::1]:43203) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1VpnJd-0003Lb-Ik for qemu-devel@nongnu.org; Sun, 08 Dec 2013 17:59:09 -0500 Received: from pm215 by mnementh.archaic.org.uk with local (Exim 4.80) (envelope-from ) id 1VpnJb-0008Jb-4y; Sun, 08 Dec 2013 22:59:07 +0000 From: Peter Maydell To: qemu-devel@nongnu.org Date: Sun, 8 Dec 2013 22:59:06 +0000 Message-Id: <1386543546-31919-6-git-send-email-peter.maydell@linaro.org> X-Mailer: git-send-email 1.7.10.4 In-Reply-To: <1386543546-31919-1-git-send-email-peter.maydell@linaro.org> References: <1386543546-31919-1-git-send-email-peter.maydell@linaro.org> X-detected-operating-system: by eggs.gnu.org: Error: Malformed IPv6 address (bad octet value). X-Received-From: 2001:8b0:1d0::1 Cc: =?UTF-8?q?Andreas=20F=C3=A4rber?= , patches@linaro.org Subject: [Qemu-devel] [PATCH 5/5] ui/cocoa: Fix code for starting QEMU via image file load dialog X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.14 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org Sender: qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org Fix a number of bugs in the code for starting QEMU via the image file load dialog: * use the actual argv[0] rather than "qemu": this avoids failures to find BIOS image files caused by not looking in the correct directory relative to the executable path * allocate a large enough argv array to NULL terminate it * use g_strdup(X) rather than g_strdup_printf("%s", X) or g_strdup_printf(X) * disable the printing of the simulated command line argument (which is presumably intended for debug only) Signed-off-by: Peter Maydell --- ui/cocoa.m | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/ui/cocoa.m b/ui/cocoa.m index 4ca1477..94bf729 100644 --- a/ui/cocoa.m +++ b/ui/cocoa.m @@ -834,18 +834,18 @@ QemuCocoaView *cocoaView; if(returnCode == NSCancelButton) { exit(0); } else if(returnCode == NSOKButton) { - const char *bin = "qemu"; char *img = (char*)[ [ [ sheet URL ] path ] cStringUsingEncoding:NSASCIIStringEncoding]; - char **argv = (char**)malloc( sizeof(char*)*3 ); + char **argv = g_new(char *, 4); [sheet close]; - argv[0] = g_strdup_printf("%s", bin); - argv[1] = g_strdup_printf("-hda"); - argv[2] = g_strdup_printf("%s", img); + argv[0] = g_strdup(gArgv[0]); + argv[1] = g_strdup("-hda"); + argv[2] = g_strdup(img); + argv[3] = NULL; - printf("Using argc %d argv %s -hda %s\n", 3, bin, img); + // printf("Using argc %d argv %s -hda %s\n", 3, gArgv[0], img); [self startEmulationWithArgc:3 argv:(char**)argv]; }