From patchwork Mon May 8 18:13:10 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Alexander Monakov X-Patchwork-Id: 1778521 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@legolas.ozlabs.org Authentication-Results: legolas.ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=gcc.gnu.org (client-ip=2620:52:3:1:0:246e:9693:128c; helo=sourceware.org; envelope-from=gcc-patches-bounces+incoming=patchwork.ozlabs.org@gcc.gnu.org; receiver=) Authentication-Results: legolas.ozlabs.org; dkim=pass (1024-bit key; unprotected) header.d=gcc.gnu.org header.i=@gcc.gnu.org header.a=rsa-sha256 header.s=default header.b=AUSsPfoJ; dkim-atps=neutral Received: from sourceware.org (server2.sourceware.org [IPv6:2620:52:3:1:0:246e:9693:128c]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature ECDSA (P-384) server-digest SHA384) (No client certificate requested) by legolas.ozlabs.org (Postfix) with ESMTPS id 4QFTv22Ynqz214X for ; Tue, 9 May 2023 04:13:50 +1000 (AEST) Received: from server2.sourceware.org (localhost [IPv6:::1]) by sourceware.org (Postfix) with ESMTP id 16E9738555BD for ; Mon, 8 May 2023 18:13:48 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org 16E9738555BD DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gcc.gnu.org; s=default; t=1683569628; bh=sXu4vDlY5p6Y+pInEQVP1msog0eEzqoG2Vs9eFvlbdE=; h=To:Cc:Subject:Date:In-Reply-To:References:List-Id: List-Unsubscribe:List-Archive:List-Post:List-Help:List-Subscribe: From:Reply-To:From; b=AUSsPfoJeftTKVVrhmHW27Yge9FxTzZPDlAyYjICO/jH4m0XyIibp4DBN6kMYEP4R yUr5NkfvP1/IPrY8s91xpxzfZYNbhKsUGHw6cauW9svsL0J6ZsHP55guiumyKmzZSk V6HS6xxLi1fJ/GlszwlG9L/NIMlA1VxGx4N3bM8s= X-Original-To: gcc-patches@gcc.gnu.org Delivered-To: gcc-patches@gcc.gnu.org Received: from mail.ispras.ru (mail.ispras.ru [83.149.199.84]) by sourceware.org (Postfix) with ESMTPS id ABB8E3858D3C for ; Mon, 8 May 2023 18:13:20 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org ABB8E3858D3C Received: from localhost.intra.ispras.ru (unknown [10.10.3.121]) by mail.ispras.ru (Postfix) with ESMTP id 2411C44C1013; Mon, 8 May 2023 18:13:19 +0000 (UTC) DKIM-Filter: OpenDKIM Filter v2.11.0 mail.ispras.ru 2411C44C1013 To: gcc-patches@gcc.gnu.org Cc: Alexander Monakov Subject: [PATCH 2/3] genmatch: clean up showUsage Date: Mon, 8 May 2023 21:13:10 +0300 Message-Id: <20230508181311.25961-3-amonakov@ispras.ru> X-Mailer: git-send-email 2.32.0 In-Reply-To: <20230508181311.25961-1-amonakov@ispras.ru> References: <20230508181311.25961-1-amonakov@ispras.ru> MIME-Version: 1.0 X-Spam-Status: No, score=-9.3 required=5.0 tests=BAYES_00, GIT_PATCH_0, KAM_DMARC_STATUS, SPF_HELO_NONE, SPF_PASS, TXREP, T_SCC_BODY_TEXT_LINE autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on server2.sourceware.org X-BeenThere: gcc-patches@gcc.gnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Gcc-patches mailing list List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-Patchwork-Original-From: Alexander Monakov via Gcc-patches From: Alexander Monakov Reply-To: Alexander Monakov Errors-To: gcc-patches-bounces+incoming=patchwork.ozlabs.org@gcc.gnu.org Sender: "Gcc-patches" Display usage more consistently and get rid of camelCase. gcc/ChangeLog: * genmatch.cc (showUsage): Reimplement as ... (usage): ...this. Adjust all uses. (main): Print usage when no arguments. Add missing 'return 1'. --- gcc/genmatch.cc | 21 ++++++++++----------- 1 file changed, 10 insertions(+), 11 deletions(-) diff --git a/gcc/genmatch.cc b/gcc/genmatch.cc index d5e56e2d68..baf93855a6 100644 --- a/gcc/genmatch.cc +++ b/gcc/genmatch.cc @@ -5301,13 +5301,12 @@ round_alloc_size (size_t s) /* Construct and display the help menu. */ static void -showUsage () +usage () { - fprintf (stderr, "Usage: genmatch [--gimple] [--generic] " - "[--header=] [--include=] [-v[v]] input " - "[...]\n"); - fprintf (stderr, "\nWhen more then one outputfile is specified --header " - "is required.\n"); + const char *usage = "Usage:\n" + " %s [--gimple|--generic] [-v[v]] \n" + " %s [options] [--include=FILE] --header=FILE ...\n"; + fprintf (stderr, usage, progname, progname); } /* Write out the correct include to the match-head fle containing the helper @@ -5332,9 +5331,6 @@ main (int argc, char **argv) progname = "genmatch"; - if (argc < 2) - return 1; - bool gimple = true; char *s_header_file = NULL; char *s_include_file = NULL; @@ -5359,14 +5355,17 @@ main (int argc, char **argv) files.safe_push (argv[i]); else { - showUsage (); + usage (); return 1; } } /* Validate if the combinations are valid. */ if ((files.length () > 1 && !s_header_file) || files.is_empty ()) - showUsage (); + { + usage (); + return 1; + } if (!s_include_file) s_include_file = s_header_file;