From nobody Fri Dec 19 00:28:22 2025 Received: from galois.linutronix.de (Galois.linutronix.de [193.142.43.55]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 64E67256C6C; Tue, 25 Mar 2025 09:05:48 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=193.142.43.55 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1742893550; cv=none; b=LSriF8EUao2boAKRcL9kAmHvTdmAAftvAiJ/mtAStua3wUSfnArJt5ucSloFZ4gclXR+7SGKAccPuTQAL/eqPScmvaZdf7Z1wXZvbD+ZF8XMiMhIF6Kkt+UwMzTebhNp2JJWOuzdH8kXXS+yQz3ra0Rhu/zwb9mjP4TSUojue8Y= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1742893550; c=relaxed/simple; bh=7KcuXHrI8LPnPPUt0G/MUGGn4Pv1sgln2X8XjIBw2+Y=; h=Date:From:To:Subject:Cc:In-Reply-To:References:MIME-Version: Message-ID:Content-Type; b=VxNdCqu5d88vsdZzqmpE2yEp7t3PhZO7CggxrpYVkHgOaerxH9kw/HovmlwQHrs6R2/WdsJPCW0Gkww1ywbuDsl93kI1GTxHCukbG1TH+s4XaSMvrYDBIcl6e7rYpa+sMgRJzXg6s0smePLjIpcC1rgMQhxCc70usgdJaArxgoE= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=linutronix.de; spf=pass smtp.mailfrom=linutronix.de; dkim=pass (2048-bit key) header.d=linutronix.de header.i=@linutronix.de header.b=1oy1KCW1; dkim=permerror (0-bit key) header.d=linutronix.de header.i=@linutronix.de header.b=Vf3mjM/L; arc=none smtp.client-ip=193.142.43.55 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=linutronix.de Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=linutronix.de Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=linutronix.de header.i=@linutronix.de header.b="1oy1KCW1"; dkim=permerror (0-bit key) header.d=linutronix.de header.i=@linutronix.de header.b="Vf3mjM/L" Date: Tue, 25 Mar 2025 09:05:45 -0000 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linutronix.de; s=2020; t=1742893546; h=from:from:sender:sender:reply-to:reply-to:subject:subject:date:date: message-id:message-id:to:to:cc:cc:mime-version:mime-version: content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=J3DDaGELfMJH6d3yfzzMMebQJjGNmvVdzjAG0zpx4E8=; b=1oy1KCW14mo2gtN4jY5DhFXuzTxmOKUdhNB2TQbi24j6e75M6joXIIZ1d+h+uT7vixV3xe vkMIx2iDhcCsiDrFoUZUEGgilL15CECIaXxrZXgrAtRLIDzO+zxOSRVL9UHHZhrof+GExL gUBwBsl0tk12nEIKaymXemEkgtHBnS2d6jWNpBEHubHhEBEK5klRHJ9DTWAZI1Fz/R+nEW ZQWBhgHS4fz9uTHH5LddmRXo44yrruHzAiZjqewIZ3u94qcB5cpA4BzrQEsDxTqLR7Aeh9 2WstwEBndmBzBmQOUrHYTaXWxmmJ/KdcAccJ0SkmKx9zICMw6W7XZLp6M+Nlig== DKIM-Signature: v=1; a=ed25519-sha256; c=relaxed/relaxed; d=linutronix.de; s=2020e; t=1742893546; h=from:from:sender:sender:reply-to:reply-to:subject:subject:date:date: message-id:message-id:to:to:cc:cc:mime-version:mime-version: content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=J3DDaGELfMJH6d3yfzzMMebQJjGNmvVdzjAG0zpx4E8=; b=Vf3mjM/LC93uKKDTNUcQLClwouZYvZQLVyPQl8UZgy8uNJWF7ipkKQdvKGxcF8NhBXPQyu PRpg+B/3nBzLffBw== From: "tip-bot2 for Ahmed S. Darwish" Sender: tip-bot2@linutronix.de Reply-to: linux-kernel@vger.kernel.org To: linux-tip-commits@vger.kernel.org Subject: [tip: x86/cpu] tools/x86/kcpuid: Simplify usage() handling Cc: "Ahmed S. Darwish" , Ingo Molnar , "H. Peter Anvin" , Linus Torvalds , Josh Poimboeuf , x86@kernel.org, linux-kernel@vger.kernel.org In-Reply-To: <20250324142042.29010-4-darwi@linutronix.de> References: <20250324142042.29010-4-darwi@linutronix.de> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Message-ID: <174289354597.14745.2248278160822769009.tip-bot2@tip-bot2> Robot-ID: Robot-Unsubscribe: Contact to get blacklisted from these emails Precedence: bulk Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable The following commit has been merged into the x86/cpu branch of tip: Commit-ID: 660c29fe53deeb3b3aef1d666ed3bde7608380bd Gitweb: https://git.kernel.org/tip/660c29fe53deeb3b3aef1d666ed3bde76= 08380bd Author: Ahmed S. Darwish AuthorDate: Mon, 24 Mar 2025 15:20:24 +01:00 Committer: Ingo Molnar CommitterDate: Tue, 25 Mar 2025 09:53:44 +01:00 tools/x86/kcpuid: Simplify usage() handling Refactor usage() to accept an exit code parameter and exit the program after usage output. This streamlines its callers' code paths. Remove the "Invalid option" error message since getopt_long(3) already emits a similar message by default. Signed-off-by: Ahmed S. Darwish Signed-off-by: Ingo Molnar Cc: H. Peter Anvin Cc: Linus Torvalds Cc: Josh Poimboeuf Link: https://lore.kernel.org/r/20250324142042.29010-4-darwi@linutronix.de --- tools/arch/x86/kcpuid/kcpuid.c | 37 ++++++++++++++------------------- 1 file changed, 16 insertions(+), 21 deletions(-) diff --git a/tools/arch/x86/kcpuid/kcpuid.c b/tools/arch/x86/kcpuid/kcpuid.c index 25b10fe..a90ac0b 100644 --- a/tools/arch/x86/kcpuid/kcpuid.c +++ b/tools/arch/x86/kcpuid/kcpuid.c @@ -10,6 +10,7 @@ =20 #define ARRAY_SIZE(x) (sizeof(x) / sizeof((x)[0])) #define min(a, b) (((a) < (b)) ? (a) : (b)) +#define __noreturn __attribute__((__noreturn__)) =20 typedef unsigned int u32; typedef unsigned long long u64; @@ -584,17 +585,17 @@ static void setup_platform_cpuid(void) leafs_ext =3D setup_cpuid_range(0x80000000); } =20 -static void usage(void) +static void __noreturn usage(int exit_code) { - warnx("kcpuid [-abdfhr] [-l leaf] [-s subleaf]\n" - "\t-a|--all Show both bit flags and complex bit fields = info\n" - "\t-b|--bitflags Show boolean flags only\n" - "\t-d|--detail Show details of the flag/fields (default)\n" - "\t-f|--flags Specify the CPUID CSV file\n" - "\t-h|--help Show usage info\n" - "\t-l|--leaf=3Dindex Specify the leaf you want to check\n" - "\t-r|--raw Show raw CPUID data\n" - "\t-s|--subleaf=3Dsub Specify the subleaf you want to check" + errx(exit_code, "kcpuid [-abdfhr] [-l leaf] [-s subleaf]\n" + "\t-a|--all Show both bit flags and complex bit fields i= nfo\n" + "\t-b|--bitflags Show boolean flags only\n" + "\t-d|--detail Show details of the flag/fields (default)\n" + "\t-f|--flags Specify the CPUID CSV file\n" + "\t-h|--help Show usage info\n" + "\t-l|--leaf=3Dindex Specify the leaf you want to check\n" + "\t-r|--raw Show raw CPUID data\n" + "\t-s|--subleaf=3Dsub Specify the subleaf you want to check" ); } =20 @@ -610,7 +611,7 @@ static struct option opts[] =3D { { NULL, 0, NULL, 0 } }; =20 -static int parse_options(int argc, char *argv[]) +static void parse_options(int argc, char *argv[]) { int c; =20 @@ -630,9 +631,7 @@ static int parse_options(int argc, char *argv[]) user_csv =3D optarg; break; case 'h': - usage(); - exit(1); - break; + usage(EXIT_SUCCESS); case 'l': /* main leaf */ user_index =3D strtoul(optarg, NULL, 0); @@ -645,11 +644,8 @@ static int parse_options(int argc, char *argv[]) user_sub =3D strtoul(optarg, NULL, 0); break; default: - warnx("Invalid option '%c'", optopt); - return -1; - } - - return 0; + usage(EXIT_FAILURE); + } } =20 /* @@ -662,8 +658,7 @@ static int parse_options(int argc, char *argv[]) */ int main(int argc, char *argv[]) { - if (parse_options(argc, argv)) - return -1; + parse_options(argc, argv); =20 /* Setup the cpuid leafs of current platform */ setup_platform_cpuid();