diff options
author | Wayne Davison <wayne@opencoder.net> | 2022-01-12 19:50:58 -0800 |
---|---|---|
committer | Wayne Davison <wayne@opencoder.net> | 2022-01-12 20:04:32 -0800 |
commit | 8c4ceb3b86749523573fec0df38a3b315575735c (patch) | |
tree | b096918ae9a8734f4eb2b2d2de41e4704ed8fa5d | |
parent | 30a590954416fa0ab2a2b27cd8098b310794446d (diff) | |
download | rsync-8c4ceb3b86749523573fec0df38a3b315575735c.tar.gz |
Avoid a -8 in the progress output's remaining time
If the double "remain" value is so large that it overflows an int, make
the estimated seconds output as :00 instead of :-8. Similar for the
estimated remaining minutes. Support larger hours values.
-rw-r--r-- | NEWS.md | 5 | ||||
-rw-r--r-- | progress.c | 8 |
2 files changed, 9 insertions, 4 deletions
@@ -88,6 +88,11 @@ check to see if the allowed time is over, which should make rsync exit more consistently. + - Tweak the snprintf() in progress.c that turns the remaining time into a + HHHH:MM:SS value to avoid putting a -8 into the SS or MM spots when the + remaining seconds is so large that it overflows the integer arithmetic + trying to perform a modulus. + ### ENHANCEMENTS: - Use openssl's `-verify_hostname` option in the rsync-ssl script. @@ -118,10 +118,10 @@ static void rprint_progress(OFF_T ofs, OFF_T size, struct timeval *now, int is_l if (remain < 0) strlcpy(rembuf, " ??:??:??", sizeof rembuf); else { - snprintf(rembuf, sizeof rembuf, "%4d:%02d:%02d", - (int) (remain / 3600.0), - (int) (remain / 60.0) % 60, - (int) remain % 60); + snprintf(rembuf, sizeof rembuf, "%4lu:%02u:%02u", + (unsigned long) (remain / 3600.0), + (unsigned int) (remain / 60.0) % 60, + (unsigned int) remain % 60); } output_needs_newline = 0; |