mirror of
https://github.com/RsyncProject/rsync.git
synced 2026-05-05 21:45:22 -04:00
Changed human_num() to big_num() with an extra arg so that it can
be used in place of all %.0f output idioms.
This commit is contained in:
4
fileio.c
4
fileio.c
@@ -232,8 +232,8 @@ char *map_ptr(struct map_struct *map, OFF_T offset, int32 len)
|
||||
if (map->p_fd_offset != read_start) {
|
||||
OFF_T ret = do_lseek(map->fd, read_start, SEEK_SET);
|
||||
if (ret != read_start) {
|
||||
rsyserr(FERROR, errno, "lseek returned %.0f, not %.0f",
|
||||
(double)ret, (double)read_start);
|
||||
rsyserr(FERROR, errno, "lseek returned %s, not %s",
|
||||
big_num(ret, 0), big_num(read_start, 0));
|
||||
exit_cleanup(RERR_FILEIO);
|
||||
}
|
||||
map->p_fd_offset = read_start;
|
||||
|
||||
8
flist.c
8
flist.c
@@ -317,9 +317,9 @@ static void flist_expand(struct file_list *flist, int extra)
|
||||
flist->malloced);
|
||||
|
||||
if (DEBUG_GTE(FLIST, 1) && flist->malloced != FLIST_START) {
|
||||
rprintf(FCLIENT, "[%s] expand file_list pointer array to %.0f bytes, did%s move\n",
|
||||
rprintf(FCLIENT, "[%s] expand file_list pointer array to %s bytes, did%s move\n",
|
||||
who_am_i(),
|
||||
(double)sizeof flist->files[0] * flist->malloced,
|
||||
big_num(sizeof flist->files[0] * flist->malloced, 0),
|
||||
(new_ptr == flist->files) ? " not" : "");
|
||||
}
|
||||
|
||||
@@ -2686,10 +2686,10 @@ static void output_flist(struct file_list *flist)
|
||||
} else
|
||||
root = dir = slash = name = trail = "";
|
||||
rprintf(FINFO,
|
||||
"[%s] i=%d %s %s%s%s%s mode=0%o len=%.0f%s%s flags=%x\n",
|
||||
"[%s] i=%d %s %s%s%s%s mode=0%o len=%s%s%s flags=%x\n",
|
||||
who, i + flist->ndx_start,
|
||||
root, dir, slash, name, trail,
|
||||
(int)file->mode, (double)F_LENGTH(file),
|
||||
(int)file->mode, big_num(F_LENGTH(file), 0),
|
||||
uidbuf, gidbuf, file->flags);
|
||||
}
|
||||
}
|
||||
|
||||
14
generator.c
14
generator.c
@@ -805,9 +805,9 @@ static void sum_sizes_sqroot(struct sum_struct *sum, int64 len)
|
||||
|
||||
if (sum->count && DEBUG_GTE(CHKSUM, 2)) {
|
||||
rprintf(FINFO,
|
||||
"count=%.0f rem=%ld blength=%ld s2length=%d flength=%.0f\n",
|
||||
(double)sum->count, (long)sum->remainder, (long)sum->blength,
|
||||
sum->s2length, (double)sum->flength);
|
||||
"count=%s rem=%ld blength=%ld s2length=%d flength=%s\n",
|
||||
big_num(sum->count, 0), (long)sum->remainder, (long)sum->blength,
|
||||
sum->s2length, big_num(sum->flength, 0));
|
||||
}
|
||||
}
|
||||
|
||||
@@ -857,8 +857,8 @@ static int generate_and_send_sums(int fd, OFF_T len, int f_out, int f_copy)
|
||||
|
||||
if (DEBUG_GTE(CHKSUM, 3)) {
|
||||
rprintf(FINFO,
|
||||
"chunk[%.0f] offset=%.0f len=%ld sum1=%08lx\n",
|
||||
(double)i, (double)offset - n1, (long)n1,
|
||||
"chunk[%s] offset=%s len=%ld sum1=%08lx\n",
|
||||
big_num(i, 0), big_num(offset - n1, 0), (long)n1,
|
||||
(unsigned long)sum1);
|
||||
}
|
||||
write_int(f_out, sum1);
|
||||
@@ -1904,8 +1904,8 @@ static void recv_generator(char *fname, struct file_struct *file, int ndx,
|
||||
}
|
||||
|
||||
if (DEBUG_GTE(CHKSUM, 3)) {
|
||||
rprintf(FINFO, "gen mapped %s of size %.0f\n",
|
||||
fnamecmp, (double)sx.st.st_size);
|
||||
rprintf(FINFO, "gen mapped %s of size %s\n",
|
||||
fnamecmp, big_num(sx.st.st_size, 0));
|
||||
}
|
||||
|
||||
if (DEBUG_GTE(CHKSUM, 2))
|
||||
|
||||
4
io.c
4
io.c
@@ -629,8 +629,8 @@ static void whine_about_eof(int fd)
|
||||
}
|
||||
|
||||
rprintf(FERROR, RSYNC_NAME ": connection unexpectedly closed "
|
||||
"(%.0f bytes received so far) [%s]\n",
|
||||
(double)stats.total_read, who_am_i());
|
||||
"(%s bytes received so far) [%s]\n",
|
||||
big_num(stats.total_read, 0), who_am_i());
|
||||
|
||||
exit_cleanup(RERR_STREAMIO);
|
||||
}
|
||||
|
||||
8
log.c
8
log.c
@@ -818,10 +818,10 @@ void log_delete(const char *fname, int mode)
|
||||
void log_exit(int code, const char *file, int line)
|
||||
{
|
||||
if (code == 0) {
|
||||
rprintf(FLOG,"sent %.0f bytes received %.0f bytes total size %.0f\n",
|
||||
(double)stats.total_written,
|
||||
(double)stats.total_read,
|
||||
(double)stats.total_size);
|
||||
rprintf(FLOG,"sent %s bytes received %s bytes total size %s\n",
|
||||
big_num(stats.total_written, 0),
|
||||
big_num(stats.total_read, 0),
|
||||
big_num(stats.total_size, 0));
|
||||
} else if (am_server != 2) {
|
||||
const char *name;
|
||||
|
||||
|
||||
20
main.c
20
main.c
@@ -36,6 +36,7 @@ extern int am_generator;
|
||||
extern int am_daemon;
|
||||
extern int inc_recurse;
|
||||
extern int blocking_io;
|
||||
extern int human_readable;
|
||||
extern int remove_source_files;
|
||||
extern int output_needs_newline;
|
||||
extern int need_messages_from_generator;
|
||||
@@ -244,15 +245,15 @@ static void output_summary(void)
|
||||
rprintf(FINFO,"Number of files transferred: %d\n",
|
||||
stats.num_transferred_files);
|
||||
rprintf(FINFO,"Total file size: %s bytes\n",
|
||||
human_num(stats.total_size));
|
||||
big_num(stats.total_size, human_readable));
|
||||
rprintf(FINFO,"Total transferred file size: %s bytes\n",
|
||||
human_num(stats.total_transferred_size));
|
||||
big_num(stats.total_transferred_size, human_readable));
|
||||
rprintf(FINFO,"Literal data: %s bytes\n",
|
||||
human_num(stats.literal_data));
|
||||
big_num(stats.literal_data, human_readable));
|
||||
rprintf(FINFO,"Matched data: %s bytes\n",
|
||||
human_num(stats.matched_data));
|
||||
big_num(stats.matched_data, human_readable));
|
||||
rprintf(FINFO,"File list size: %s\n",
|
||||
human_num(stats.flist_size));
|
||||
big_num(stats.flist_size, human_readable));
|
||||
if (stats.flist_buildtime) {
|
||||
rprintf(FINFO,
|
||||
"File list generation time: %.3f seconds\n",
|
||||
@@ -262,19 +263,20 @@ static void output_summary(void)
|
||||
(double)stats.flist_xfertime / 1000);
|
||||
}
|
||||
rprintf(FINFO,"Total bytes sent: %s\n",
|
||||
human_num(total_written));
|
||||
big_num(total_written, human_readable));
|
||||
rprintf(FINFO,"Total bytes received: %s\n",
|
||||
human_num(total_read));
|
||||
big_num(total_read, human_readable));
|
||||
}
|
||||
|
||||
if (INFO_GTE(STATS, 1)) {
|
||||
rprintf(FCLIENT, "\n");
|
||||
rprintf(FINFO,
|
||||
"sent %s bytes received %s bytes %s bytes/sec\n",
|
||||
human_num(total_written), human_num(total_read),
|
||||
big_num(total_written, human_readable),
|
||||
big_num(total_read, human_readable),
|
||||
human_dnum((total_written + total_read)/(0.5 + (endtime - starttime)), 2));
|
||||
rprintf(FINFO, "total size is %s speedup is %.2f%s\n",
|
||||
human_num(stats.total_size),
|
||||
big_num(stats.total_size, human_readable),
|
||||
(double)stats.total_size / (total_written+total_read),
|
||||
write_batch < 0 ? " (BATCH ONLY)" : dry_run ? " (DRY RUN)" : "");
|
||||
}
|
||||
|
||||
24
match.c
24
match.c
@@ -108,8 +108,8 @@ static void matched(int f, struct sum_struct *s, struct map_struct *buf,
|
||||
|
||||
if (DEBUG_GTE(CHKSUM, 2) && i >= 0) {
|
||||
rprintf(FINFO,
|
||||
"match at %.0f last_match=%.0f j=%d len=%ld n=%ld\n",
|
||||
(double)offset, (double)last_match, i,
|
||||
"match at %s last_match=%s j=%d len=%ld n=%ld\n",
|
||||
big_num(offset, 0), big_num(last_match, 0), i,
|
||||
(long)s->sums[i].len, (long)n);
|
||||
}
|
||||
|
||||
@@ -151,8 +151,8 @@ static void hash_search(int f,struct sum_struct *s,
|
||||
want_i = 0;
|
||||
|
||||
if (DEBUG_GTE(CHKSUM, 2)) {
|
||||
rprintf(FINFO, "hash search b=%ld len=%.0f\n",
|
||||
(long)s->blength, (double)len);
|
||||
rprintf(FINFO, "hash search b=%ld len=%s\n",
|
||||
(long)s->blength, big_num(len, 0));
|
||||
}
|
||||
|
||||
k = (int32)MIN(len, (OFF_T)s->blength);
|
||||
@@ -170,8 +170,8 @@ static void hash_search(int f,struct sum_struct *s,
|
||||
end = len + 1 - s->sums[s->count-1].len;
|
||||
|
||||
if (DEBUG_GTE(CHKSUM, 3)) {
|
||||
rprintf(FINFO, "hash search s->blength=%ld len=%.0f count=%.0f\n",
|
||||
(long)s->blength, (double)len, (double)s->count);
|
||||
rprintf(FINFO, "hash search s->blength=%ld len=%s count=%s\n",
|
||||
(long)s->blength, big_num(len, 0), big_num(s->count, 0));
|
||||
}
|
||||
|
||||
do {
|
||||
@@ -179,8 +179,8 @@ static void hash_search(int f,struct sum_struct *s,
|
||||
int32 i;
|
||||
|
||||
if (DEBUG_GTE(CHKSUM, 4)) {
|
||||
rprintf(FINFO, "offset=%.0f sum=%04x%04x\n",
|
||||
(double)offset, s2 & 0xFFFF, s1 & 0xFFFF);
|
||||
rprintf(FINFO, "offset=%s sum=%04x%04x\n",
|
||||
big_num(offset, 0), s2 & 0xFFFF, s1 & 0xFFFF);
|
||||
}
|
||||
|
||||
if (tablesize == TRADITIONAL_TABLESIZE) {
|
||||
@@ -213,8 +213,8 @@ static void hash_search(int f,struct sum_struct *s,
|
||||
|
||||
if (DEBUG_GTE(CHKSUM, 3)) {
|
||||
rprintf(FINFO,
|
||||
"potential match at %.0f i=%ld sum=%08x\n",
|
||||
(double)offset, (long)i, sum);
|
||||
"potential match at %s i=%ld sum=%08x\n",
|
||||
big_num(offset, 0), (long)i, sum);
|
||||
}
|
||||
|
||||
if (!done_csum2) {
|
||||
@@ -402,7 +402,7 @@ void match_report(void)
|
||||
return;
|
||||
|
||||
rprintf(FINFO,
|
||||
"total: matches=%d hash_hits=%d false_alarms=%d data=%.0f\n",
|
||||
"total: matches=%d hash_hits=%d false_alarms=%d data=%s\n",
|
||||
total_matches, total_hash_hits, total_false_alarms,
|
||||
(double)stats.literal_data);
|
||||
big_num(stats.literal_data, 0));
|
||||
}
|
||||
|
||||
@@ -25,6 +25,7 @@
|
||||
extern int am_server;
|
||||
extern int need_unsorted_flist;
|
||||
extern int output_needs_newline;
|
||||
extern int human_readable;
|
||||
extern struct stats stats;
|
||||
extern struct file_list *cur_flist;
|
||||
|
||||
@@ -124,7 +125,7 @@ static void rprint_progress(OFF_T ofs, OFF_T size, struct timeval *now,
|
||||
output_needs_newline = 0;
|
||||
pct = ofs == size ? 100 : (int) (100.0 * ofs / size);
|
||||
rprintf(FCLIENT, "\r%12s %3d%% %7.2f%s %s%s",
|
||||
human_num(ofs), pct, rate, units, rembuf, eol);
|
||||
big_num(ofs, human_readable), pct, rate, units, rembuf, eol);
|
||||
if (!is_last) {
|
||||
output_needs_newline = 1;
|
||||
rflush(FCLIENT);
|
||||
|
||||
20
receiver.c
20
receiver.c
@@ -179,8 +179,8 @@ static int receive_data(int f_in, char *fname_r, int fd_r, OFF_T size_r,
|
||||
int32 read_size = MAX(sum.blength * 2, 16*1024);
|
||||
mapbuf = map_file(fd_r, size_r, read_size, sum.blength);
|
||||
if (DEBUG_GTE(CHKSUM, 2)) {
|
||||
rprintf(FINFO, "recv mapped %s of size %.0f\n",
|
||||
fname_r, (double)size_r);
|
||||
rprintf(FINFO, "recv mapped %s of size %s\n",
|
||||
fname_r, big_num(size_r, 0));
|
||||
}
|
||||
} else
|
||||
mapbuf = NULL;
|
||||
@@ -209,8 +209,8 @@ static int receive_data(int f_in, char *fname_r, int fd_r, OFF_T size_r,
|
||||
}
|
||||
offset = sum.flength;
|
||||
if (fd != -1 && (j = do_lseek(fd, offset, SEEK_SET)) != offset) {
|
||||
rsyserr(FERROR_XFER, errno, "lseek of %s returned %.0f, not %.0f",
|
||||
full_fname(fname), (double)j, (double)offset);
|
||||
rsyserr(FERROR_XFER, errno, "lseek of %s returned %s, not %s",
|
||||
full_fname(fname), big_num(j, 0), big_num(offset, 0));
|
||||
exit_cleanup(RERR_FILEIO);
|
||||
}
|
||||
}
|
||||
@@ -221,8 +221,8 @@ static int receive_data(int f_in, char *fname_r, int fd_r, OFF_T size_r,
|
||||
|
||||
if (i > 0) {
|
||||
if (DEBUG_GTE(CHKSUM, 3)) {
|
||||
rprintf(FINFO,"data recv %d at %.0f\n",
|
||||
i,(double)offset);
|
||||
rprintf(FINFO,"data recv %d at %s\n",
|
||||
i, big_num(offset, 0));
|
||||
}
|
||||
|
||||
stats.literal_data += i;
|
||||
@@ -246,8 +246,8 @@ static int receive_data(int f_in, char *fname_r, int fd_r, OFF_T size_r,
|
||||
|
||||
if (DEBUG_GTE(CHKSUM, 3)) {
|
||||
rprintf(FINFO,
|
||||
"chunk[%d] of size %ld at %.0f offset=%.0f\n",
|
||||
i, (long)len, (double)offset2, (double)offset);
|
||||
"chunk[%d] of size %ld at %s offset=%s\n",
|
||||
i, (long)len, big_num(offset2, 0), big_num(offset, 0));
|
||||
}
|
||||
|
||||
if (mapbuf) {
|
||||
@@ -265,9 +265,9 @@ static int receive_data(int f_in, char *fname_r, int fd_r, OFF_T size_r,
|
||||
offset += len;
|
||||
if ((pos = do_lseek(fd, len, SEEK_CUR)) != offset) {
|
||||
rsyserr(FERROR_XFER, errno,
|
||||
"lseek of %s returned %.0f, not %.0f",
|
||||
"lseek of %s returned %s, not %s",
|
||||
full_fname(fname),
|
||||
(double)pos, (double)offset);
|
||||
big_num(pos, 0), big_num(offset, 0));
|
||||
exit_cleanup(RERR_FILEIO);
|
||||
}
|
||||
continue;
|
||||
|
||||
12
sender.c
12
sender.c
@@ -70,8 +70,8 @@ static struct sum_struct *receive_sums(int f)
|
||||
s->sums = NULL;
|
||||
|
||||
if (DEBUG_GTE(CHKSUM, 3)) {
|
||||
rprintf(FINFO, "count=%.0f n=%ld rem=%ld\n",
|
||||
(double)s->count, (long)s->blength, (long)s->remainder);
|
||||
rprintf(FINFO, "count=%s n=%ld rem=%ld\n",
|
||||
big_num(s->count, 0), (long)s->blength, (long)s->remainder);
|
||||
}
|
||||
|
||||
if (append_mode > 0) {
|
||||
@@ -105,8 +105,8 @@ static struct sum_struct *receive_sums(int f)
|
||||
|
||||
if (DEBUG_GTE(CHKSUM, 3)) {
|
||||
rprintf(FINFO,
|
||||
"chunk[%d] len=%d offset=%.0f sum1=%08x\n",
|
||||
i, s->sums[i].len, (double)s->sums[i].offset,
|
||||
"chunk[%d] len=%d offset=%s sum1=%08x\n",
|
||||
i, s->sums[i].len, big_num(s->sums[i].offset, 0),
|
||||
s->sums[i].sum1);
|
||||
}
|
||||
}
|
||||
@@ -324,8 +324,8 @@ void send_files(int f_in, int f_out)
|
||||
mbuf = NULL;
|
||||
|
||||
if (DEBUG_GTE(CHKSUM, 2)) {
|
||||
rprintf(FINFO, "send_files mapped %s%s%s of size %.0f\n",
|
||||
path,slash,fname, (double)st.st_size);
|
||||
rprintf(FINFO, "send_files mapped %s%s%s of size %s\n",
|
||||
path,slash,fname, big_num(st.st_size, 0));
|
||||
}
|
||||
|
||||
write_ndx_and_attrs(f_out, ndx, iflags, fname, file,
|
||||
|
||||
20
util.c
20
util.c
@@ -1188,10 +1188,10 @@ int unsafe_symlink(const char *dest, const char *src)
|
||||
return (depth < 0);
|
||||
}
|
||||
|
||||
/* Return the int64 number as a string. If the --human-readable option was
|
||||
* specified, we may output the number in K, M, or G units. We can return
|
||||
* up to 4 buffers at a time. */
|
||||
char *human_num(int64 num)
|
||||
/* Return the int64 number as a string. If the human_flag arg is non-zero,
|
||||
* we may output the number in K, M, or G units. We can return up to 4
|
||||
* buffers at a time. */
|
||||
char *big_num(int64 num, int human_flag)
|
||||
{
|
||||
static char bufs[4][128]; /* more than enough room */
|
||||
static unsigned int n;
|
||||
@@ -1199,9 +1199,9 @@ char *human_num(int64 num)
|
||||
|
||||
n = (n + 1) % (sizeof bufs / sizeof bufs[0]);
|
||||
|
||||
if (human_readable) {
|
||||
if (human_flag) {
|
||||
char units = '\0';
|
||||
int mult = human_readable == 1 ? 1000 : 1024;
|
||||
int mult = human_flag == 1 ? 1000 : 1024;
|
||||
double dnum = 0;
|
||||
if (num > mult*mult*mult) {
|
||||
dnum = (double)num / (mult*mult*mult);
|
||||
@@ -1233,10 +1233,10 @@ char *human_num(int64 num)
|
||||
|
||||
/* Return the double number as a string. If the --human-readable option was
|
||||
* specified, we may output the number in K, M, or G units. We use a buffer
|
||||
* from human_num() to return our result. */
|
||||
* from big_num() to return our result. */
|
||||
char *human_dnum(double dnum, int decimal_digits)
|
||||
{
|
||||
char *buf = human_num(dnum);
|
||||
char *buf = big_num(dnum, human_readable);
|
||||
int len = strlen(buf);
|
||||
if (isDigit(buf + len - 1)) {
|
||||
/* There's extra room in buf prior to the start of the num. */
|
||||
@@ -1583,8 +1583,8 @@ void *expand_item_list(item_list *lp, size_t item_size,
|
||||
/* Using _realloc_array() lets us pass the size, not a type. */
|
||||
new_ptr = _realloc_array(lp->items, item_size, new_size);
|
||||
if (DEBUG_GTE(FLIST, 3)) {
|
||||
rprintf(FINFO, "[%s] expand %s to %.0f bytes, did%s move\n",
|
||||
who_am_i(), desc, (double)new_size * item_size,
|
||||
rprintf(FINFO, "[%s] expand %s to %s bytes, did%s move\n",
|
||||
who_am_i(), desc, big_num(new_size * item_size, 0),
|
||||
new_ptr == lp->items ? " not" : "");
|
||||
}
|
||||
if (!new_ptr)
|
||||
|
||||
8
xattrs.c
8
xattrs.c
@@ -114,7 +114,7 @@ static int rsync_xal_compare_names(const void *x1, const void *x2)
|
||||
static ssize_t get_xattr_names(const char *fname)
|
||||
{
|
||||
ssize_t list_len;
|
||||
double arg;
|
||||
int64 arg;
|
||||
|
||||
if (!namebuf) {
|
||||
namebuf_len = 1024;
|
||||
@@ -132,11 +132,11 @@ static ssize_t get_xattr_names(const char *fname)
|
||||
} else if (errno == ENOTSUP)
|
||||
return 0;
|
||||
else if (errno != ERANGE) {
|
||||
arg = (double)namebuf_len;
|
||||
arg = namebuf_len;
|
||||
got_error:
|
||||
rsyserr(FERROR_XFER, errno,
|
||||
"get_xattr_names: llistxattr(\"%s\",%.0f) failed",
|
||||
fname, arg);
|
||||
"get_xattr_names: llistxattr(\"%s\",%s) failed",
|
||||
fname, big_num(arg, 0));
|
||||
return -1;
|
||||
}
|
||||
list_len = sys_llistxattr(fname, NULL, 0);
|
||||
|
||||
Reference in New Issue
Block a user