From patchwork Tue Aug 14 04:08:06 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Joel Stanley X-Patchwork-Id: 957346 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 41qJx43DQFz9s7c for ; Tue, 14 Aug 2018 14:08:24 +1000 (AEST) Authentication-Results: ozlabs.org; dmarc=none (p=none dis=none) header.from=jms.id.au Authentication-Results: ozlabs.org; dkim=fail reason="signature verification failed" (2048-bit key; unprotected) header.d=gmail.com header.i=@gmail.com header.b="tJscdkkc"; 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 41qJx41MWKzF0dS for ; Tue, 14 Aug 2018 14:08:24 +1000 (AEST) Authentication-Results: lists.ozlabs.org; dmarc=none (p=none dis=none) header.from=jms.id.au Authentication-Results: lists.ozlabs.org; dkim=fail reason="signature verification failed" (2048-bit key; unprotected) header.d=gmail.com header.i=@gmail.com header.b="tJscdkkc"; dkim-atps=neutral X-Original-To: pdbg@lists.ozlabs.org Delivered-To: pdbg@lists.ozlabs.org Authentication-Results: lists.ozlabs.org; spf=pass (mailfrom) smtp.mailfrom=gmail.com (client-ip=2607:f8b0:4864:20::541; helo=mail-pg1-x541.google.com; envelope-from=joel.stan@gmail.com; receiver=) Authentication-Results: lists.ozlabs.org; dmarc=none (p=none dis=none) header.from=jms.id.au Authentication-Results: lists.ozlabs.org; dkim=pass (2048-bit key; unprotected) header.d=gmail.com header.i=@gmail.com header.b="tJscdkkc"; dkim-atps=neutral Received: from mail-pg1-x541.google.com (mail-pg1-x541.google.com [IPv6:2607:f8b0:4864:20::541]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by lists.ozlabs.org (Postfix) with ESMTPS id 41qJwy14S7zF0Qs for ; Tue, 14 Aug 2018 14:08:17 +1000 (AEST) Received: by mail-pg1-x541.google.com with SMTP id h12-v6so8519041pgs.3 for ; Mon, 13 Aug 2018 21:08:17 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=sender:from:to:subject:date:message-id; bh=bRRkWYgXTq+7u2pbVRcVc9YBLoc9lIyylsZrjZtT/tE=; b=tJscdkkcpyGjOFMZS5aWMZSj/PWBz7JWrasaW6/gLNvUU96qOIxuldPyQABsYBQeBp 1ysOfldwaOJQm3wHKVKf7H8BhKECP/NV4TeI9hZ84OzsW5NbADTzu6ug691pMEqGOzgs EPDRdlSzBF/vyRq9zaACR8Xf35veV4qu2nPOA+daWEraqm+sJRW7dDmK2g57T3dKqPyZ +L1F9DI8NNM1tFBNeZKNrEudcYc/6qd8go5EvJYyasPB9lAOv06oCVvSERjAAmu5FBE5 5B8u3cVfGHBUDzVcQ4tF3or17eqGTrL1V3qjHlVcL4SIjpkM+OFOS9N/XVf7KUlUwzeC Rdcw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:sender:from:to:subject:date:message-id; bh=bRRkWYgXTq+7u2pbVRcVc9YBLoc9lIyylsZrjZtT/tE=; b=CPRqqwIk0LWpIdoYIRb/0BAZ0hS6UVl67qLypmixIVkxX6mekB0Qd2qLy0rfIw1874 iMlWJq6VDrNwru/oa4865MnIT6BuIHItnMxVwf5gec92RbHRZU5bm2gGV0JKELQ7Zm+W 4D0N6V9I37ARxLRlUCg+F/1UKIar/OE3R1omY3DfEbhedRAP4DFTEwaGBmXSKs8Nlh89 TamYYBqZ3aafJDzBNn3VayPLNHemPv5nRsYxka2ng4YnyPSOu4oDkjqJeQA4Y3FhTDCP qmOG/zKkHNhhjpM0c4bvBnei5ZbE+H/l3sL4gx9OLFn78SVhDd+z+KfAspHIB3T5Xhwj vQBg== X-Gm-Message-State: AOUpUlGjdvSkzQ6Y4a5oOqlIpSaqxcXE4dsqwncapd2xcLDq1Grm6XxJ IaXpvZCbGki/qMtwsAbvUQSQ1ier X-Google-Smtp-Source: AA+uWPyY7QsDiqB2BCVV12dh2JK9smOfdJqQYuafHRSZ0JSiqiLw+c09JW8vE5VguMs5SZ9bOfzC8g== X-Received: by 2002:a63:aa44:: with SMTP id x4-v6mr19745816pgo.120.1534219695469; Mon, 13 Aug 2018 21:08:15 -0700 (PDT) Received: from aurora.jms.id.au (bh02i525f01.au.ibm.com. [202.81.18.30]) by smtp.gmail.com with ESMTPSA id l127-v6sm29941237pfc.55.2018.08.13.21.08.12 for (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Mon, 13 Aug 2018 21:08:14 -0700 (PDT) Received: by aurora.jms.id.au (sSMTP sendmail emulation); Tue, 14 Aug 2018 13:38:08 +0930 From: Joel Stanley To: pdbg@lists.ozlabs.org Date: Tue, 14 Aug 2018 13:38:06 +0930 Message-Id: <20180814040806.29107-1-joel@jms.id.au> X-Mailer: git-send-email 2.17.1 Subject: [Pdbg] [PATCH] progress: No more progress X-BeenThere: pdbg@lists.ozlabs.org X-Mailman-Version: 2.1.27 Precedence: list List-Id: "mailing list for https://github.com/open-power/pdbg development" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , MIME-Version: 1.0 Errors-To: pdbg-bounces+incoming=patchwork.ozlabs.org@lists.ozlabs.org Sender: "Pdbg" This adds an option to suppress progress: -S, --shutup Shut up those annoying progress bars Signed-off-by: Joel Stanley --- src/main.c | 10 +++++++++- src/progress.c | 16 ++++++++++++++++ src/progress.h | 1 + 3 files changed, 26 insertions(+), 1 deletion(-) diff --git a/src/main.c b/src/main.c index b446b5b6ff9b..73b307183105 100644 --- a/src/main.c +++ b/src/main.c @@ -37,6 +37,7 @@ #include "htm.h" #include "options.h" #include "optcmd.h" +#include "progress.h" #define PR_ERROR(x, args...) \ pdbg_log(PDBG_ERROR, x, ##args) @@ -162,6 +163,8 @@ static void print_usage(char *pname) printf("\t\tand defaults to 0x50 for I2C\n"); printf("\t-D, --debug=\n"); printf("\t\t0:error (default) 1:warning 2:notice 3:info 4:debug\n"); + printf("\t-S, --shutup\n"); + printf("\t\tShut up those annoying progress bars\n"); printf("\t-V, --version\n"); printf("\t-h, --help\n"); printf("\n"); @@ -328,6 +331,7 @@ static bool parse_options(int argc, char *argv[]) {"cpu", required_argument, NULL, 'l'}, #endif {"debug", required_argument, NULL, 'D'}, + {"shutup", no_argument, NULL, 'S'}, {"version", no_argument, NULL, 'V'}, {NULL, 0, NULL, 0} }; @@ -339,7 +343,7 @@ static bool parse_options(int argc, char *argv[]) memset(l_list, 0, sizeof(l_list)); do { - c = getopt_long(argc, argv, "+ab:c:d:hp:s:t:D:V" PPC_OPTS, + c = getopt_long(argc, argv, "+ab:c:d:hp:s:t:D:SV" PPC_OPTS, long_opts, NULL); if (c == -1) break; @@ -425,6 +429,10 @@ static bool parse_options(int argc, char *argv[]) fprintf(stderr, "Invalid slave address '%s'\n", optarg); break; + case 'S': + progress_shutup(); + break; + case 'D': pdbg_set_loglevel(atoi(optarg)); break; diff --git a/src/progress.c b/src/progress.c index 648596db7565..4baee12a3a59 100644 --- a/src/progress.c +++ b/src/progress.c @@ -20,6 +20,7 @@ #include #include #include +#include #include "progress.h" @@ -27,6 +28,7 @@ static uint64_t progress_pcent; static uint64_t progress_n_upd; static time_t progress_prevsec; static struct timespec progress_start; +static bool shutup; #define PROGRESS_CHARS 50 @@ -36,6 +38,9 @@ static void progress_bar(unsigned int percent) assert(percent <= 100); + if (shutup) + return; + progress = (percent * PROGRESS_CHARS) / 101; fprintf(stderr, "\r["); @@ -47,6 +52,11 @@ static void progress_bar(unsigned int percent) fflush(stderr); } +void progress_shutup(void) +{ + shutup = true; +} + void progress_init(void) { progress_pcent = 0; @@ -64,6 +74,9 @@ void progress_tick(uint64_t cur, uint64_t end) unsigned int pcent; double sec; + if (shutup) + return; + pcent = (unsigned int)((cur * 100) / end); if (progress_pcent == pcent && cur < progress_n_upd && cur < end) @@ -100,5 +113,8 @@ void progress_tick(uint64_t cur, uint64_t end) void progress_end(void) { + if (shutup) + return; + fprintf(stderr, "\n"); } diff --git a/src/progress.h b/src/progress.h index 48c93b2c8789..a3714c8de17e 100644 --- a/src/progress.h +++ b/src/progress.h @@ -20,5 +20,6 @@ void progress_init(void); void progress_tick(uint64_t cur, uint64_t end); void progress_end(void); +void progress_shutup(void); #endif /* __PROGRESS_H */