Commit 25f637a3 authored by Wayne Davison's avatar Wayne Davison

Got rid of EXIT_OR_RETURN() macro again -- switching to a better

recursion-prevention heuristic in _exit_cleanup().
parent 2356d73b
...@@ -37,7 +37,6 @@ extern int msg_fd_out; ...@@ -37,7 +37,6 @@ extern int msg_fd_out;
extern int allow_8bit_chars; extern int allow_8bit_chars;
extern int protocol_version; extern int protocol_version;
extern int preserve_times; extern int preserve_times;
extern int in_exit_cleanup;
extern int stdout_format_has_i; extern int stdout_format_has_i;
extern int stdout_format_has_o_or_i; extern int stdout_format_has_o_or_i;
extern int logfile_format_has_i; extern int logfile_format_has_i;
...@@ -91,14 +90,6 @@ struct { ...@@ -91,14 +90,6 @@ struct {
{ 0, NULL } { 0, NULL }
}; };
#define EXIT_OR_RETURN(err) \
do { \
if (in_exit_cleanup) \
return; \
exit_cleanup(err); \
} while (0)
/* /*
* Map from rsync error code to name, or return NULL. * Map from rsync error code to name, or return NULL.
*/ */
...@@ -230,13 +221,13 @@ static void filtered_fwrite(FILE *f, const char *buf, int len, int use_isprint) ...@@ -230,13 +221,13 @@ static void filtered_fwrite(FILE *f, const char *buf, int len, int use_isprint)
&& ((use_isprint && !isprint(*(uchar*)s)) && ((use_isprint && !isprint(*(uchar*)s))
|| *(uchar*)s < ' '))) { || *(uchar*)s < ' '))) {
if (s != buf && fwrite(buf, s - buf, 1, f) != 1) if (s != buf && fwrite(buf, s - buf, 1, f) != 1)
EXIT_OR_RETURN(RERR_MESSAGEIO); exit_cleanup(RERR_MESSAGEIO);
fprintf(f, "\\#%03o", *(uchar*)s); fprintf(f, "\\#%03o", *(uchar*)s);
buf = s + 1; buf = s + 1;
} }
} }
if (buf != end && fwrite(buf, end - buf, 1, f) != 1) if (buf != end && fwrite(buf, end - buf, 1, f) != 1)
EXIT_OR_RETURN(RERR_MESSAGEIO); exit_cleanup(RERR_MESSAGEIO);
} }
/* this is the underlying (unformatted) rsync debugging function. Call /* this is the underlying (unformatted) rsync debugging function. Call
...@@ -248,7 +239,7 @@ void rwrite(enum logcode code, char *buf, int len) ...@@ -248,7 +239,7 @@ void rwrite(enum logcode code, char *buf, int len)
FILE *f = NULL; FILE *f = NULL;
if (len < 0) if (len < 0)
EXIT_OR_RETURN(RERR_MESSAGEIO); exit_cleanup(RERR_MESSAGEIO);
if (am_server && msg_fd_out >= 0) { if (am_server && msg_fd_out >= 0) {
/* Pass the message to our sibling. */ /* Pass the message to our sibling. */
...@@ -302,7 +293,7 @@ void rwrite(enum logcode code, char *buf, int len) ...@@ -302,7 +293,7 @@ void rwrite(enum logcode code, char *buf, int len)
f = am_server ? stderr : stdout; f = am_server ? stderr : stdout;
break; break;
default: default:
EXIT_OR_RETURN(RERR_MESSAGEIO); exit_cleanup(RERR_MESSAGEIO);
} }
trailing_CR_or_NL = len && (buf[len-1] == '\n' || buf[len-1] == '\r') trailing_CR_or_NL = len && (buf[len-1] == '\n' || buf[len-1] == '\r')
...@@ -406,7 +397,7 @@ void rsyserr(enum logcode code, int errcode, const char *format, ...) ...@@ -406,7 +397,7 @@ void rsyserr(enum logcode code, int errcode, const char *format, ...)
": %s (%d)\n", strerror(errcode), errcode); ": %s (%d)\n", strerror(errcode), errcode);
} }
if (len >= sizeof buf) if (len >= sizeof buf)
EXIT_OR_RETURN(RERR_MESSAGEIO); exit_cleanup(RERR_MESSAGEIO);
rwrite(code, buf, len); rwrite(code, buf, len);
} }
...@@ -444,7 +435,7 @@ static void log_formatted(enum logcode code, char *format, char *op, ...@@ -444,7 +435,7 @@ static void log_formatted(enum logcode code, char *format, char *op,
total = strlcpy(buf, format, sizeof buf); total = strlcpy(buf, format, sizeof buf);
if (total > MAXPATHLEN) { if (total > MAXPATHLEN) {
rprintf(FERROR, "log-format string is WAY too long!\n"); rprintf(FERROR, "log-format string is WAY too long!\n");
EXIT_OR_RETURN(RERR_MESSAGEIO); exit_cleanup(RERR_MESSAGEIO);
} }
buf[total++] = '\n'; buf[total++] = '\n';
buf[total] = '\0'; buf[total] = '\0';
...@@ -655,7 +646,7 @@ static void log_formatted(enum logcode code, char *format, char *op, ...@@ -655,7 +646,7 @@ static void log_formatted(enum logcode code, char *format, char *op,
rprintf(FERROR, rprintf(FERROR,
"buffer overflow expanding %%%c -- exiting\n", "buffer overflow expanding %%%c -- exiting\n",
p[0]); p[0]);
EXIT_OR_RETURN(RERR_MESSAGEIO); exit_cleanup(RERR_MESSAGEIO);
} }
/* Shuffle the rest of the string along to make space for n */ /* Shuffle the rest of the string along to make space for n */
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment