From patchwork Sun Jan 12 22:52:34 2014 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Peter Maydell X-Patchwork-Id: 23139 Return-Path: X-Original-To: linaro@patches.linaro.org Delivered-To: linaro@patches.linaro.org Received: from mail-ig0-f199.google.com (mail-ig0-f199.google.com [209.85.213.199]) by ip-10-151-82-157.ec2.internal (Postfix) with ESMTPS id 90AB020A64 for ; Sun, 12 Jan 2014 22:53:29 +0000 (UTC) Received: by mail-ig0-f199.google.com with SMTP id c10sf525566igq.2 for ; Sun, 12 Jan 2014 14:53:28 -0800 (PST) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20130820; h=x-gm-message-state:mime-version:delivered-to:from:to:date :message-id:in-reply-to:references:cc:subject:precedence:list-id :list-unsubscribe:list-archive:list-post:list-help:list-subscribe :errors-to:sender:x-original-sender :x-original-authentication-results:mailing-list; bh=pcJKqXnWotaZrFRXq9LITeOIYiAEI8ThSGtksVdOBeI=; b=cE8WnfXrLC7XAixfGW0Nlh+2Ongm+Xdx2sMwPxiYAGDmHZbAKdtFIDelrlskZfIYEH qQd5eH623gmy0X1DLhLVQVQU5IvzlWTTQKNwkDVaDQYGik06UBXlujX6DiSii8CCU+AN wjYjCxvqg7RV4hf3jH8tlta42akAg2if71ILbnBPbqb52Y/hEV7fnsNUbSrZ388pTvlv VLT+K/i/1UDQNL9BiPvi4OPc8DMzOAFP4aJNFHACmdhYV4TMxQVsZFKozyyxInUQTzVK 4DDTjAtcQoWKIyBbfGzTfKP/3y5jI2p1ZERTH45DQkz9W4uTUS4cGvHVVfFUyoqvF9EO LNMw== X-Gm-Message-State: ALoCoQlYyU6R6mkdtG6b7P6NmLqZnQsR89aRTR7Xouey+x9p7e7VHBSmswsvwYbabFcTLe6QkrC1 X-Received: by 10.182.87.225 with SMTP id bb1mr8498546obb.16.1389567208531; Sun, 12 Jan 2014 14:53:28 -0800 (PST) MIME-Version: 1.0 X-BeenThere: patchwork-forward@linaro.org Received: by 10.49.15.70 with SMTP id v6ls2329111qec.47.gmail; Sun, 12 Jan 2014 14:53:28 -0800 (PST) X-Received: by 10.52.244.49 with SMTP id xd17mr13567891vdc.26.1389567208362; Sun, 12 Jan 2014 14:53:28 -0800 (PST) Received: from mail-vb0-f52.google.com (mail-vb0-f52.google.com [209.85.212.52]) by mx.google.com with ESMTPS id vc3si6907398vdc.5.2014.01.12.14.53.28 for (version=TLSv1 cipher=ECDHE-RSA-RC4-SHA bits=128/128); Sun, 12 Jan 2014 14:53:28 -0800 (PST) Received-SPF: neutral (google.com: 209.85.212.52 is neither permitted nor denied by best guess record for domain of patch+caf_=patchwork-forward=linaro.org@linaro.org) client-ip=209.85.212.52; Received: by mail-vb0-f52.google.com with SMTP id p14so152270vbm.39 for ; Sun, 12 Jan 2014 14:53:28 -0800 (PST) X-Received: by 10.58.186.233 with SMTP id fn9mr2373736vec.31.1389567208285; Sun, 12 Jan 2014 14:53:28 -0800 (PST) X-Forwarded-To: patchwork-forward@linaro.org X-Forwarded-For: patch@linaro.org patchwork-forward@linaro.org Delivered-To: patch@linaro.org Received: by 10.59.13.131 with SMTP id ey3csp92886ved; Sun, 12 Jan 2014 14:53:27 -0800 (PST) X-Received: by 10.224.130.6 with SMTP id q6mr32645969qas.29.1389567207740; Sun, 12 Jan 2014 14:53:27 -0800 (PST) Received: from lists.gnu.org (lists.gnu.org. [2001:4830:134:3::11]) by mx.google.com with ESMTPS id z7si18460133qep.122.2014.01.12.14.53.27 for (version=TLSv1 cipher=RC4-SHA bits=128/128); Sun, 12 Jan 2014 14:53:27 -0800 (PST) Received-SPF: pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 2001:4830:134:3::11 as permitted sender) client-ip=2001:4830:134:3::11; Received: from localhost ([::1]:39745 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1W2TuI-0006LJ-Mq for patch@linaro.org; Sun, 12 Jan 2014 17:53:26 -0500 Received: from eggs.gnu.org ([2001:4830:134:3::10]:46221) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1W2Tta-0005m4-R1 for qemu-devel@nongnu.org; Sun, 12 Jan 2014 17:52:43 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1W2TtZ-000524-Hr for qemu-devel@nongnu.org; Sun, 12 Jan 2014 17:52:42 -0500 Received: from mnementh.archaic.org.uk ([2001:8b0:1d0::1]:44742) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1W2TtZ-00050Z-Ao for qemu-devel@nongnu.org; Sun, 12 Jan 2014 17:52:41 -0500 Received: from pm215 by mnementh.archaic.org.uk with local (Exim 4.80) (envelope-from ) id 1W2TtX-00085r-4z; Sun, 12 Jan 2014 22:52:39 +0000 From: Peter Maydell To: Anthony Liguori Date: Sun, 12 Jan 2014 22:52:34 +0000 Message-Id: <1389567158-31066-6-git-send-email-peter.maydell@linaro.org> X-Mailer: git-send-email 1.7.10.4 In-Reply-To: <1389567158-31066-1-git-send-email-peter.maydell@linaro.org> References: <1389567158-31066-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: Blue Swirl , =?UTF-8?q?Andreas=20F=C3=A4rber?= , qemu-devel@nongnu.org, Aurelien Jarno Subject: [Qemu-devel] [PULL 5/9] 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+patch=linaro.org@nongnu.org Sender: qemu-devel-bounces+patch=linaro.org@nongnu.org X-Removed-Original-Auth: Dkim didn't pass. X-Original-Sender: peter.maydell@linaro.org X-Original-Authentication-Results: mx.google.com; spf=neutral (google.com: 209.85.212.52 is neither permitted nor denied by best guess record for domain of patch+caf_=patchwork-forward=linaro.org@linaro.org) smtp.mail=patch+caf_=patchwork-forward=linaro.org@linaro.org Mailing-list: list patchwork-forward@linaro.org; contact patchwork-forward+owners@linaro.org X-Google-Group-Id: 836684582541 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 Message-id: 1386543546-31919-6-git-send-email-peter.maydell@linaro.org --- ui/cocoa.m | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/ui/cocoa.m b/ui/cocoa.m index fd55044..b90b782 100644 --- a/ui/cocoa.m +++ b/ui/cocoa.m @@ -833,18 +833,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]; }