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 Received: from bombadil.infradead.org (bombadil.infradead.org [198.137.202.133]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id DCFA8E6FE27 for ; Fri, 6 Sep 2024 15:33:41 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20210309; h=Sender:List-Subscribe:List-Help :List-Post:List-Archive:List-Unsubscribe:List-Id:Content-Transfer-Encoding: Content-Type:MIME-Version:Message-ID:Date:References:In-Reply-To:Subject:Cc: To:From:Reply-To:Content-ID:Content-Description:Resent-Date:Resent-From: Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID:List-Owner; bh=TZFn5/Wh+6xOaD5wMVXpC8+lYEYUiqnhRyA8Q/iYkNs=; b=qWsYGDT/I9lI++ZqnK6LOcdqxB 7mpY4GjZGJj1SJhAibmBYPYwSaorRfSRNegPLm0WySJJpbhymBFo4LO5Wmphld4ys2wWK+kopbguD 5Y26u8htVxQ44WyHa82Uua2i46bEwUVQEREniL0/ESVwlmg5zZZ7aOR8ntX24ufGVArVb+ovphAHr 0039rOQbLjEoZjWg8V6LaC5W+m9vm8bO4k0bV9m3a2Ap5NiP59ybJ/8xZXKhcQMaVi+slS0xGn6sN D/0amgJeULCfsjJ/KVS4G23KK/Os5pfLmjscfwQKNSDTI8S6lb/mWW6TVuUjiswFjGnLEtryz0kcF 6xGwRnAA==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.97.1 #2 (Red Hat Linux)) id 1smaxn-0000000CmoJ-1tGq; Fri, 06 Sep 2024 15:33:31 +0000 Received: from mgamail.intel.com ([192.198.163.16]) by bombadil.infradead.org with esmtps (Exim 4.97.1 #2 (Red Hat Linux)) id 1smawm-0000000CmWP-351b for linux-arm-kernel@lists.infradead.org; Fri, 06 Sep 2024 15:32:30 +0000 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1725636748; x=1757172748; h=from:to:cc:subject:in-reply-to:references:date: message-id:mime-version:content-transfer-encoding; bh=krjsuq3HBhcuxaQHBr9KpekfFKRQ2YCSUdVgMpOdeEg=; b=bI2CcBfpzWX3Tn1TqTdex9iK/BMZNBHI1Q9kSjvnQ7v+ejg1IMQRPKhH qvqY78zYQEI63SrCikiefHjsEND8bMX5TCXYPsZJ1eL+plGHLfWN1MaQ+ j8ip9lvAA49FIMKIydAZcR6/RyT/EWgFCbgCdbaUCD3OFYAsH+OuumtCK AMBcfAeKKNu4TEzKyhO0yaJrFKqr//l+JBQawhCTYSdRZOSqeTfjHNpY2 BIcQQpWNTJ+JSmJNqHW2dYm4rCQAhv7kSks9KRGUf4jUEh4DE7gCIjLRp itT7dTDKUlbb+saRaXK+DTKC/k4OmTK5APjzievlnZgHMJXzIsvVBacTw w==; X-CSE-ConnectionGUID: zhtgusLPR6yU/fLNvvuVWA== X-CSE-MsgGUID: BuA9ImTtSZqBvYrlmx4fFw== X-IronPort-AV: E=McAfee;i="6700,10204,11187"; a="13412484" X-IronPort-AV: E=Sophos;i="6.10,208,1719903600"; d="scan'208";a="13412484" Received: from orviesa005.jf.intel.com ([10.64.159.145]) by fmvoesa110.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 06 Sep 2024 08:32:28 -0700 X-CSE-ConnectionGUID: 7hg6BEdBSyyGJbhlcVyp1Q== X-CSE-MsgGUID: doAxGO40RJyWHOv1GYC2zg== X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="6.10,208,1719903600"; d="scan'208";a="70792221" Received: from sschumil-mobl2.ger.corp.intel.com (HELO localhost) ([10.245.246.62]) by orviesa005-auth.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 06 Sep 2024 08:32:15 -0700 From: Jani Nikula To: Masahiro Yamada , da.gomez@samsung.com Cc: Nathan Chancellor , Nicolas Schier , Lucas De Marchi , Thomas =?utf-8?Q?Hellstr=C3=B6m?= , Rodrigo Vivi , Maarten Lankhorst , Maxime Ripard , Thomas Zimmermann , David Airlie , William Hubbs , Chris Brannon , Kirk Reiser , Samuel Thibault , Paul Moore , Stephen Smalley , Ondrej Mosnacek , Catalin Marinas , Will Deacon , Marc Zyngier , Oliver Upton , James Morse , Suzuki K Poulose , Zenghui Yu , Greg Kroah-Hartman , Jiri Slaby , Nick Desaulniers , Bill Wendling , Justin Stitt , Simona Vetter , linux-kernel@vger.kernel.org, linux-kbuild@vger.kernel.org, intel-xe@lists.freedesktop.org, dri-devel@lists.freedesktop.org, speakup@linux-speakup.org, selinux@vger.kernel.org, linux-arm-kernel@lists.infradead.org, kvmarm@lists.linux.dev, linux-serial@vger.kernel.org, llvm@lists.linux.dev, Finn Behrens , "Daniel Gomez (Samsung)" , gost.dev@samsung.com Subject: Re: [PATCH v2 3/8] drm/xe: xe_gen_wa_oob: fix program_invocation_short_name for macos In-Reply-To: Organization: Intel Finland Oy - BIC 0357606-4 - Westendinkatu 7, 02160 Espoo References: <20240906-macos-build-support-v2-0-06beff418848@samsung.com> <20240906-macos-build-support-v2-3-06beff418848@samsung.com> Date: Fri, 06 Sep 2024 18:32:08 +0300 Message-ID: <87h6asn6h3.fsf@intel.com> MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: quoted-printable X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20240906_083228_810361_BFFC176C X-CRM114-Status: GOOD ( 16.41 ) X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+linux-arm-kernel=archiver.kernel.org@lists.infradead.org On Fri, 06 Sep 2024, Masahiro Yamada wrote: > On Fri, Sep 6, 2024 at 8:01=E2=80=AFPM Daniel Gomez via B4 Relay > wrote: >> >> From: Daniel Gomez >> >> Use getprogname() [1] instead of program_invocation_short_name() [2] >> for macOS hosts. >> >> [1]: >> https://www.gnu.org/software/gnulib/manual/html_node/ >> program_005finvocation_005fshort_005fname.html >> >> [2]: >> https://developer.apple.com/library/archive/documentation/System/ >> Conceptual/ManPages_iPhoneOS/man3/getprogname.3.html >> >> Fixes build error for macOS hosts: >> >> drivers/gpu/drm/xe/xe_gen_wa_oob.c:34:3: error: use of >> undeclared identifier 'program_invocation_short_name' 34 | >> program_invocation_short_name); | ^ 1 error >> generated. >> >> Signed-off-by: Daniel Gomez >> Reviewed-by: Lucas De Marchi >> --- >> drivers/gpu/drm/xe/xe_gen_wa_oob.c | 4 ++++ >> 1 file changed, 4 insertions(+) >> >> diff --git a/drivers/gpu/drm/xe/xe_gen_wa_oob.c b/drivers/gpu/drm/xe/xe_= gen_wa_oob.c >> index 904cf47925aa..0d933644d8a0 100644 >> --- a/drivers/gpu/drm/xe/xe_gen_wa_oob.c >> +++ b/drivers/gpu/drm/xe/xe_gen_wa_oob.c >> @@ -8,6 +8,7 @@ >> #include >> #include >> #include >> +#include >> #include >> >> #define HEADER \ >> @@ -30,6 +31,9 @@ >> >> static void print_usage(FILE *f) >> { >> +#ifdef __APPLE__ >> + const char *program_invocation_short_name =3D getprogname(); >> +#endif >> fprintf(f, "usage: %s \n", >> program_invocation_short_name); >> } >> >> -- >> 2.46.0 >> >> > > > > Before adding such #ifdef, you should check how other programs do. IMO either option is preferred over adding #ifdefs. BR, Jani. > > > > > > > > > > Solution 1 : hard-code the program name > > > diff --git a/drivers/gpu/drm/xe/xe_gen_wa_oob.c > b/drivers/gpu/drm/xe/xe_gen_wa_oob.c > index 106ee2b027f0..9e9a29e2cecf 100644 > --- a/drivers/gpu/drm/xe/xe_gen_wa_oob.c > +++ b/drivers/gpu/drm/xe/xe_gen_wa_oob.c > @@ -30,8 +30,7 @@ > > static void print_usage(FILE *f) > { > - fprintf(f, "usage: %s > \n", > - program_invocation_short_name); > + fprintf(f, "usage: xe_gen_wa_oob > \n"); > } > > static void print_parse_error(const char *err_msg, const char *line, > > > > > > > > > Solution 2: use argv[0] > > > diff --git a/drivers/gpu/drm/xe/xe_gen_wa_oob.c > b/drivers/gpu/drm/xe/xe_gen_wa_oob.c > index 106ee2b027f0..600c63e88e46 100644 > --- a/drivers/gpu/drm/xe/xe_gen_wa_oob.c > +++ b/drivers/gpu/drm/xe/xe_gen_wa_oob.c > @@ -28,10 +28,10 @@ > "\n" \ > "#endif\n" > > -static void print_usage(FILE *f) > +static void print_usage(FILE *f, const char *progname) > { > fprintf(f, "usage: %s > \n", > - program_invocation_short_name); > + progname); > } > > static void print_parse_error(const char *err_msg, const char *line, > @@ -136,7 +136,7 @@ int main(int argc, const char *argv[]) > > if (argc < 3) { > fprintf(stderr, "ERROR: wrong arguments\n"); > - print_usage(stderr); > + print_usage(stderr, argv[0]); > return 1; > } --=20 Jani Nikula, Intel