git/list[1] front-page[2] threads[3] people[4] search[5] about
 

[PATCH 1/1] Improve progress display in kB range.

From
James Cloos <cloos@jhcloos.com>
Date
Apr 19, 2009, 04:32 UTC
Message-ID
<d03620ac4d99f3280df31708032a072a4a6cd96e.1240115957.git.cloos@jhcloos.com>
In-Reply-To
<cover.1240115957.git.cloos@jhcloos.com>

When progress.c:throughput_string() is called, the variable total invariably has its twelve least significant bits set. Ie, it is always the case that:

       total & 0xFFF == 0xFFF
As such, there is no point in displaying centi KiB.
Signed-off-by: James Cloos <cloos@jhcloos.com>
---
 progress.c |    5 ++---
 1 files changed, 2 insertions(+), 3 deletions(-)
diff --git a/progress.c b/progress.c
index 55a8687..e51b834 100644
--- a/progress.c
+++ b/progress.c
@@ -125,9 +125,8 @@ static void throughput_string(struct throughput *tp, off_t total,
 			      (int)(total >> 20),
 			      ((int)(total & ((1 << 20) - 1)) * 100) >> 20);
 	} else if (total > 1 << 10) {
-		l -= snprintf(tp->display, l, ", %u.%2.2u KiB",
-			      (int)(total >> 10),
-			      ((int)(total & ((1 << 10) - 1)) * 100) >> 10);
+		l -= snprintf(tp->display, l, ", %u KiB",
+			      (int)(total >> 10));
 	} else {
 		l -= snprintf(tp->display, l, ", %u bytes", (int)total);
 	}
-- 
1.6.3.rc1.1.g7e8e.dirty
Previous: James CloosNext: Nicolas Pitre
Message 2 of 13 in “Improve progress display in kB range.”
  1. 0/1 Improve progress display in kB range.James Cloos, Apr 19, 2009
  2. 1/1 Improve progress display in kB range.James Cloos, Apr 19, 2009
  3. Nicolas PitreApr 21, 2009
  4. James CloosApr 21, 2009
  5. Nicolas PitreApr 21, 2009
  6. James CloosApr 21, 2009
  7. James CloosApr 22, 2009
  8. Junio C HamanoApr 22, 2009
  9. James CloosApr 22, 2009
  10. Johannes SixtApr 23, 2009
  11. James CloosApr 24, 2009
  12. Nicolas PitreApr 24, 2009
  13. James CloosApr 24, 2009

Read the whole thread, see it on lore, or plain text.

$ cat FOOTERMessages come from the public archive at lore.kernel.org/git, fetched every hour. The front page is chosen and written each morning by an AI editor and can be wrong; the threads themselves are the record. About and API. For agents: an MCP server at https://gitlist.dev/mcp, and any thread, story or person page as Markdown by adding .md to its URL (or sending Accept: text/markdown). Details in /llms.txt.