Development discussion of WireGuard
 help / color / mirror / Atom feed
* [PATCH wireguard-tools] src/show: remove dead offset check code
@ 2021-05-17  9:10 Hangbin Liu
  2021-05-17  9:44 ` Jason A. Donenfeld
  0 siblings, 1 reply; 4+ messages in thread
From: Hangbin Liu @ 2021-05-17  9:10 UTC (permalink / raw)
  To: wireguard; +Cc: Jason A . Donenfeld, Hangbin Liu

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


^ permalink raw reply	[flat|nested] 4+ messages in thread

end of thread, other threads:[~2021-05-18  7:14 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2021-05-17  9:10 [PATCH wireguard-tools] src/show: remove dead offset check code Hangbin Liu
2021-05-17  9:44 ` Jason A. Donenfeld
2021-05-18  1:01   ` Hangbin Liu
2021-05-18  7:14     ` Jason A. Donenfeld

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).