From patchwork Fri Jun 1 06:30:45 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Amitay Isaacs X-Patchwork-Id: 923776 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Received: from lists.ozlabs.org (lists.ozlabs.org [203.11.71.2]) (using TLSv1.2 with cipher ADH-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id 40xvdv59s5z9s0W for ; Fri, 1 Jun 2018 16:32:51 +1000 (AEST) Authentication-Results: ozlabs.org; dmarc=none (p=none dis=none) header.from=ozlabs.org Authentication-Results: ozlabs.org; dkim=fail reason="signature verification failed" (2048-bit key; secure) header.d=ozlabs.org header.i=@ozlabs.org header.b="VkrlY/tf"; dkim-atps=neutral Received: from lists.ozlabs.org (lists.ozlabs.org [IPv6:2401:3900:2:1::3]) by lists.ozlabs.org (Postfix) with ESMTP id 40xvdv2Z2mzF0Rs for ; Fri, 1 Jun 2018 16:32:51 +1000 (AEST) Authentication-Results: lists.ozlabs.org; dmarc=none (p=none dis=none) header.from=ozlabs.org Authentication-Results: lists.ozlabs.org; dkim=fail reason="signature verification failed" (2048-bit key; secure) header.d=ozlabs.org header.i=@ozlabs.org header.b="VkrlY/tf"; dkim-atps=neutral X-Original-To: pdbg@lists.ozlabs.org Delivered-To: pdbg@lists.ozlabs.org Received: from ozlabs.org (bilbo.ozlabs.org [203.11.71.1]) (using TLSv1.2 with cipher ADH-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by lists.ozlabs.org (Postfix) with ESMTPS id 40xvc32PS5zF0Vt for ; Fri, 1 Jun 2018 16:31:15 +1000 (AEST) Authentication-Results: lists.ozlabs.org; dmarc=none (p=none dis=none) header.from=ozlabs.org Authentication-Results: lists.ozlabs.org; dkim=pass (2048-bit key; secure) header.d=ozlabs.org header.i=@ozlabs.org header.b="VkrlY/tf"; dkim-atps=neutral Received: from authenticated.ozlabs.org (localhost [127.0.0.1]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPSA id 40xvc2053Wz9s0x; Fri, 1 Jun 2018 16:31:13 +1000 (AEST) Authentication-Results: ozlabs.org; dmarc=none (p=none dis=none) header.from=ozlabs.org DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=ozlabs.org; s=201707; t=1527834674; bh=3Sibv8fNusijJNqFUKgw/Dre9FnmH55ExPBzfDLWL5w=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=VkrlY/tfq5qvJa24SBrbRr5Z8HFUIhXY3TlMyC5k/ESiWobMEHFIe9W1gXO70fr9F HYg12UryE+PDGFJA0WPnJKTrr9M97DQLpn2AqR3Ep22W1HGWy/HGgP8cnu+Fr77J7d V2C1kYxS50Cw/LPkN0cNgqw5CipWRxUs9PLt9xwYVeAagplS6KAPhR+L9T5GepW5UD dhmImEozLmUKs8+/O72PHT1CeQAZI7gcf8D6naXzEAWqlltSCtVvIFrRyyC3CAZYVX Nf6zmjDK2Ax5dEM/+rg4Dh4INMTfLJ2aEKD+olbEpOgXsnp89DurXMmvNdR84sWGse YujF8tlPFfTjA== From: Amitay Isaacs To: pdbg@lists.ozlabs.org Date: Fri, 1 Jun 2018 16:30:45 +1000 Message-Id: <20180601063050.19286-3-amitay@ozlabs.org> X-Mailer: git-send-email 2.17.0 In-Reply-To: <20180601063050.19286-1-amitay@ozlabs.org> References: <20180601063050.19286-1-amitay@ozlabs.org> Subject: [Pdbg] [PATCH v2 2/7] main: Print specific errors for invalid arguments X-BeenThere: pdbg@lists.ozlabs.org X-Mailman-Version: 2.1.26 Precedence: list List-Id: "mailing list for https://github.com/open-power/pdbg development" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Amitay Isaacs MIME-Version: 1.0 Errors-To: pdbg-bounces+incoming=patchwork.ozlabs.org@lists.ozlabs.org Sender: "Pdbg" This avoids the large usage message obscuring the actual errors from parsing options. Print usage only if an option is invalid. Signed-off-by: Amitay Isaacs Reviewed-By: Alistair Popple --- src/main.c | 33 ++++++++++++++++----------------- 1 file changed, 16 insertions(+), 17 deletions(-) diff --git a/src/main.c b/src/main.c index 457cda2..db27409 100644 --- a/src/main.c +++ b/src/main.c @@ -226,7 +226,7 @@ static bool parse_list(const char *arg, int max, int *list, int *count) static bool parse_options(int argc, char *argv[]) { int c; - bool opt_error = true; + bool opt_error = false; int p_list[MAX_PROCESSORS]; int c_list[MAX_CHIPS]; int t_list[MAX_THREADS]; @@ -255,8 +255,6 @@ static bool parse_options(int argc, char *argv[]) switch(c) { case 'a': - opt_error = false; - if (p_count == 0) { p_count = MAX_PROCESSORS; for (i=0; i