* [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 related [flat|nested] 4+ messages in thread
* Re: [PATCH wireguard-tools] src/show: remove dead offset check code
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
0 siblings, 1 reply; 4+ messages in thread
From: Jason A. Donenfeld @ 2021-05-17 9:44 UTC (permalink / raw)
To: Hangbin Liu; +Cc: WireGuard mailing list
The compiler will optimize this out, right? In which case, I like the
consistency, in case lines are ever reordered or copy and pasted.
^ permalink raw reply [flat|nested] 4+ messages in thread
* Re: [PATCH wireguard-tools] src/show: remove dead offset check code
2021-05-17 9:44 ` Jason A. Donenfeld
@ 2021-05-18 1:01 ` Hangbin Liu
2021-05-18 7:14 ` Jason A. Donenfeld
0 siblings, 1 reply; 4+ messages in thread
From: Hangbin Liu @ 2021-05-18 1:01 UTC (permalink / raw)
To: Jason A. Donenfeld; +Cc: WireGuard mailing list
On Mon, May 17, 2021 at 11:44:08AM +0200, Jason A. Donenfeld wrote:
> The compiler will optimize this out, right? In which case, I like the
> consistency, in case lines are ever reordered or copy and pasted.
Not sure if compiler will optimize. I just got the complain when do covscan
checking. I'm OK to keep the format.
Thanks
Hangbin
^ 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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.