From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-13.8 required=3.0 tests=BAYES_00, HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_CR_TRAILER,INCLUDES_PATCH, MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 5D217C433E0 for ; Tue, 9 Mar 2021 13:12:44 +0000 (UTC) Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id 8BD2A6514A for ; Tue, 9 Mar 2021 13:12:43 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 8BD2A6514A Authentication-Results: mail.kernel.org; dmarc=fail (p=none dis=none) header.from=eik.bme.hu Authentication-Results: mail.kernel.org; spf=pass smtp.mailfrom=qemu-devel-bounces+qemu-devel=archiver.kernel.org@nongnu.org Received: from localhost ([::1]:33864 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1lJcAE-0005xJ-AM for qemu-devel@archiver.kernel.org; Tue, 09 Mar 2021 08:12:42 -0500 Received: from eggs.gnu.org ([2001:470:142:3::10]:41216) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1lJc8O-0004ab-FE for qemu-devel@nongnu.org; Tue, 09 Mar 2021 08:10:48 -0500 Received: from zero.eik.bme.hu ([2001:738:2001:2001::2001]:36319) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1lJc8L-0003yv-Hh for qemu-devel@nongnu.org; Tue, 09 Mar 2021 08:10:47 -0500 Received: from zero.eik.bme.hu (blah.eik.bme.hu [152.66.115.182]) by localhost (Postfix) with SMTP id 9F463746344; Tue, 9 Mar 2021 14:10:39 +0100 (CET) Received: by zero.eik.bme.hu (Postfix, from userid 432) id 7C4C3746334; Tue, 9 Mar 2021 14:10:39 +0100 (CET) Received: from localhost (localhost [127.0.0.1]) by zero.eik.bme.hu (Postfix) with ESMTP id 7AE8C74632F; Tue, 9 Mar 2021 14:10:39 +0100 (CET) Date: Tue, 9 Mar 2021 14:10:39 +0100 (CET) From: BALATON Zoltan To: Akihiko Odaki Subject: Re: [PATCH 2/2] ui/cocoa: Do not rely on the first argument In-Reply-To: <20210309122226.23117-2-akihiko.odaki@gmail.com> Message-ID: <30b88283-8d6b-502b-9032-33c81e26d97@eik.bme.hu> References: <20210309122226.23117-1-akihiko.odaki@gmail.com> <20210309122226.23117-2-akihiko.odaki@gmail.com> MIME-Version: 1.0 Content-Type: text/plain; charset=US-ASCII; format=flowed Received-SPF: pass client-ip=2001:738:2001:2001::2001; envelope-from=balaton@eik.bme.hu; helo=zero.eik.bme.hu X-Spam_score_int: -18 X-Spam_score: -1.9 X-Spam_bar: - X-Spam_report: (-1.9 / 5.0 requ) BAYES_00=-1.9, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Peter Maydell , qemu-devel@nongnu.org, Gerd Hoffmann Errors-To: qemu-devel-bounces+qemu-devel=archiver.kernel.org@nongnu.org Sender: "Qemu-devel" On Tue, 9 Mar 2021, Akihiko Odaki wrote: > The first argument of the executable was used to get its path, but it is > not reliable because the executer can specify any arbitrary string. Use the > interfaces provided by QEMU and the platform to get those paths. > > Signed-off-by: Akihiko Odaki > --- > ui/cocoa.m | 29 +++++++++++++++-------------- > 1 file changed, 15 insertions(+), 14 deletions(-) > > diff --git a/ui/cocoa.m b/ui/cocoa.m > index d8eacea6d22..6e94301c0d6 100644 > --- a/ui/cocoa.m > +++ b/ui/cocoa.m > @@ -1414,20 +1414,21 @@ - (void)make_about_window > [superView addSubview: picture_view]; > > /* Make the name label */ > - x = 0; > - y = y - 25; > - int name_width = about_width, name_height = 20; > - NSRect name_rect = NSMakeRect(x, y, name_width, name_height); > - NSTextField *name_label = [[NSTextField alloc] initWithFrame: name_rect]; > - [name_label setEditable: NO]; > - [name_label setBezeled: NO]; > - [name_label setDrawsBackground: NO]; > - [name_label setAlignment: NSTextAlignmentCenter]; > - NSString *qemu_name = [[NSString alloc] initWithCString: gArgv[0] > - encoding: NSASCIIStringEncoding]; > - qemu_name = [qemu_name lastPathComponent]; > - [name_label setStringValue: qemu_name]; > - [superView addSubview: name_label]; > + NSBundle *bundle = [NSBundle mainBundle]; > + if (bundle) { Does this break about window if the executable is not in a bundle (like when run from the command line after compiling)? Shouldn't you only put the qemu_name in this if and have some default name if bundle is not available (or fall back to argv[0] in that case? Regards, BALATON Zoltan > + x = 0; > + y = y - 25; > + int name_width = about_width, name_height = 20; > + NSRect name_rect = NSMakeRect(x, y, name_width, name_height); > + NSTextField *name_label = [[NSTextField alloc] initWithFrame: name_rect]; > + [name_label setEditable: NO]; > + [name_label setBezeled: NO]; > + [name_label setDrawsBackground: NO]; > + [name_label setAlignment: NSTextAlignmentCenter]; > + NSString *qemu_name = [[bundle executablePath] lastPathComponent]; > + [name_label setStringValue: qemu_name]; > + [superView addSubview: name_label]; > + } > > /* Set the version label's attributes */ > x = 0; >