MCPcopy Create free account
hub / github.com/RsyncProject/rsync / output_itemized_counts

Function output_itemized_counts

main.c:387–416  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

385}
386
387static void output_itemized_counts(const char *prefix, int *counts)
388{
389 static char *const labels[] = { "reg", "dir", "link", "dev", "special" };
390 char buf[1024], *pre = " (";
391 int j, len = 0;
392 int total = counts[0];
393 if (total) {
394 counts[0] -= counts[1] + counts[2] + counts[3] + counts[4];
395 for (j = 0; j < 5; j++) {
396 if (counts[j]) {
397 /* snprintf can return more than its size arg
398 * on truncation; keep len <= sizeof buf - 2 so
399 * the closing ')' and trailing NUL always
400 * have room and the next iteration's
401 * sizeof buf - len - 2 cannot underflow. */
402 if (len >= (int)sizeof buf - 2)
403 break;
404 len += snprintf(buf+len, sizeof buf - len - 2,
405 "%s%s: %s",
406 pre, labels[j], comma_num(counts[j]));
407 if (len > (int)sizeof buf - 2)
408 len = (int)sizeof buf - 2;
409 pre = ", ";
410 }
411 }
412 buf[len++] = ')';
413 }
414 buf[len] = '\0';
415 rprintf(FINFO, "%s: %s%s\n", prefix, comma_num(total), buf);
416}
417
418static const char *bytes_per_sec_human_dnum(void)
419{

Callers 1

output_summaryFunction · 0.85

Calls 2

comma_numFunction · 0.85
rprintfFunction · 0.70

Tested by

no test coverage detected