X-Git-Url: https://mattmccutchen.net/rsync/rsync.git/blobdiff_plain/654175798bdbdd6403e10c8fa74e8586b3612ea1..d1be231290b3867648ee417fad341fdf1caaa94b:/log.c diff --git a/log.c b/log.c index 18e1da06..86da03a7 100644 --- a/log.c +++ b/log.c @@ -90,7 +90,7 @@ void log_open(void) /* recursion can happen with certain fatal conditions */ va_start(ap, format); - len = vslprintf(buf, sizeof(buf)-1, format, ap); + len = vslprintf(buf, sizeof(buf), format, ap); va_end(ap); if (len < 0) exit_cleanup(RERR_MESSAGEIO); @@ -186,9 +186,10 @@ static void log_formatted(int fd, int l; extern struct stats stats; extern int am_sender; + extern int am_daemon; int64 b; - strlcpy(buf, format, sizeof(buf)-1); + strlcpy(buf, format, sizeof(buf)); for (s=&buf[0]; s && (p=strchr(s,'%')); ) { @@ -196,21 +197,21 @@ static void log_formatted(int fd, s = p + 1; switch (p[1]) { - case 'h': n = client_name(0); break; - case 'a': n = client_addr(0); break; + case 'h': if (am_daemon) n = client_name(0); break; + case 'a': if (am_daemon) n = client_addr(0); break; case 'l': - slprintf(buf2,sizeof(buf2)-1,"%.0f", + slprintf(buf2,sizeof(buf2),"%.0f", (double)file->length); n = buf2; break; case 'p': - slprintf(buf2,sizeof(buf2)-1,"%d", + slprintf(buf2,sizeof(buf2),"%d", (int)getpid()); n = buf2; break; case 'o': n = op; break; case 'f': - slprintf(buf2, sizeof(buf2)-1, "%s/%s", + slprintf(buf2, sizeof(buf2), "%s/%s", file->basedir?file->basedir:"", f_name(file)); clean_fname(buf2); @@ -229,7 +230,7 @@ static void log_formatted(int fd, b = stats.total_read - initial_stats->total_read; } - slprintf(buf2,sizeof(buf2)-1,"%.0f", (double)b); + slprintf(buf2,sizeof(buf2),"%.0f", (double)b); n = buf2; break; case 'c': @@ -240,7 +241,7 @@ static void log_formatted(int fd, b = stats.total_read - initial_stats->total_read; } - slprintf(buf2,sizeof(buf2)-1,"%.0f", (double)b); + slprintf(buf2,sizeof(buf2),"%.0f", (double)b); n = buf2; break; } @@ -295,7 +296,7 @@ void log_recv(struct file_struct *file, struct stats *initial_stats) } /* called when the transfer is interrupted for some reason */ -void log_exit(int code) +void log_exit(int code, const char *file, int line) { if (code == 0) { extern struct stats stats; @@ -304,7 +305,8 @@ void log_exit(int code) (double)stats.total_read, (double)stats.total_size); } else { - rprintf(FLOG,"transfer interrupted (code %d)\n", code); + rprintf(FLOG,"transfer interrupted (code %d) at %s(%d)\n", + code, file, line); } } @@ -313,7 +315,7 @@ void log_exit(int code) it i called when a file starts to be transferred */ -void log_transfer(struct file_struct *file, char *fname) +void log_transfer(struct file_struct *file, const char *fname) { extern int verbose;