Development discussion of WireGuard
 help / color / mirror / Atom feed
From: Hangbin Liu <liuhangbin@gmail.com>
To: wireguard@lists.zx2c4.com
Cc: "Jason A . Donenfeld" <Jason@zx2c4.com>,
	Hangbin Liu <liuhangbin@gmail.com>
Subject: [PATCH wireguard-tools] src/show: remove dead offset check code
Date: Mon, 17 May 2021 17:10:53 +0800	[thread overview]
Message-ID: <20210517091053.886157-1-liuhangbin@gmail.com> (raw)

At first the offset will always be 0. So the check of offset ? ", " : ""
is useless.

Signed-off-by: Hangbin Liu <liuhangbin@gmail.com>
---
 src/show.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/src/show.c b/src/show.c
index 761858b..83d4d6b 100644
--- a/src/show.c
+++ b/src/show.c
@@ -141,7 +141,7 @@ static size_t pretty_time(char *buf, const size_t len, unsigned long long left)
 	seconds = left % 60;
 
 	if (years)
-		offset += snprintf(buf + offset, len - offset, "%s%llu " TERMINAL_FG_CYAN "year%s" TERMINAL_RESET, offset ? ", " : "", years, years == 1 ? "" : "s");
+		offset = snprintf(buf, len, "%llu " TERMINAL_FG_CYAN "year%s" TERMINAL_RESET, years, years == 1 ? "" : "s");
 	if (days)
 		offset += snprintf(buf + offset, len - offset, "%s%llu " TERMINAL_FG_CYAN  "day%s" TERMINAL_RESET, offset ? ", " : "", days, days == 1 ? "" : "s");
 	if (hours)
-- 
2.26.3


             reply	other threads:[~2021-05-17 15:27 UTC|newest]

Thread overview: 4+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2021-05-17  9:10 Hangbin Liu [this message]
2021-05-17  9:44 ` Jason A. Donenfeld
2021-05-18  1:01   ` Hangbin Liu
2021-05-18  7:14     ` Jason A. Donenfeld

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20210517091053.886157-1-liuhangbin@gmail.com \
    --to=liuhangbin@gmail.com \
    --cc=Jason@zx2c4.com \
    --cc=wireguard@lists.zx2c4.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).