X-Git-Url: https://mattmccutchen.net/rsync/rsync.git/blobdiff_plain/b60626549181401ddf8ed57bd21f2b9f43dfdbf6..5a788adec19043d4d93c4fa2713f9f633bfd35ab:/log.c diff --git a/log.c b/log.c index 62572da5..6594d454 100644 --- a/log.c +++ b/log.c @@ -90,12 +90,12 @@ 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(1); + if (len < 0) exit_cleanup(RERR_MESSAGEIO); - if (len > sizeof(buf)-1) exit_cleanup(1); + if (len > sizeof(buf)-1) exit_cleanup(RERR_MESSAGEIO); buf[len] = 0; @@ -134,9 +134,9 @@ void log_open(void) f = stdout; } - if (!f) exit_cleanup(1); + if (!f) exit_cleanup(RERR_MESSAGEIO); - if (fwrite(buf, len, 1, f) != 1) exit_cleanup(1); + if (fwrite(buf, len, 1, f) != 1) exit_cleanup(RERR_MESSAGEIO); if (buf[len-1] == '\r' || buf[len-1] == '\n') fflush(f); } @@ -166,7 +166,7 @@ void rflush(int fd) f = stdout; } - if (!f) exit_cleanup(1); + if (!f) exit_cleanup(RERR_MESSAGEIO); fflush(f); } @@ -188,7 +188,7 @@ static void log_formatted(int fd, extern int am_sender; int64 b; - strlcpy(buf, format, sizeof(buf)-1); + strlcpy(buf, format, sizeof(buf)); for (s=&buf[0]; s && (p=strchr(s,'%')); ) { @@ -199,18 +199,18 @@ static void log_formatted(int fd, case 'h': n = client_name(0); break; case 'a': 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 +229,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 +240,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; } @@ -252,7 +252,7 @@ static void log_formatted(int fd, if ((l-1) + ((int)(s - &buf[0])) > sizeof(buf)) { rprintf(FERROR,"buffer overflow expanding %%%c - exiting\n", p[0]); - exit_cleanup(1); + exit_cleanup(RERR_MESSAGEIO); } if (l != 2) { @@ -304,7 +304,7 @@ void log_exit(int code) (double)stats.total_read, (double)stats.total_size); } else { - rprintf(FLOG,"transfer interrupted\n"); + rprintf(FLOG,"transfer interrupted (code %d)\n", code); } }