Point out that the file_struct in log_delete is zero-initialized because
[rsync/rsync.git] / log.c
diff --git a/log.c b/log.c
index 7be4cec..46e0a63 100644 (file)
--- a/log.c
+++ b/log.c
@@ -37,8 +37,6 @@ extern int protocol_version;
 extern int always_checksum;
 extern int preserve_times;
 extern int msgs2stderr;
-extern int uid_ndx;
-extern int gid_ndx;
 extern int stdout_format_has_i;
 extern int stdout_format_has_o_or_i;
 extern int logfile_format_has_i;
@@ -97,13 +95,13 @@ struct {
        { RERR_MALLOC     , "error allocating core memory buffers" },
        { RERR_PARTIAL    , "some files/attrs were not transferred (see previous errors)" },
        { RERR_VANISHED   , "some files vanished before they could be transferred" },
+       { RERR_DEL_LIMIT  , "the --max-delete limit stopped deletions" },
        { RERR_TIMEOUT    , "timeout in data send/receive" },
        { RERR_CONTIMEOUT , "timeout waiting for daemon connection" },
        { RERR_CMD_FAILED , "remote shell failed" },
        { RERR_CMD_KILLED , "remote shell killed" },
        { RERR_CMD_RUN    , "remote command could not be run" },
        { RERR_CMD_NOTFOUND,"remote command not found" },
-       { RERR_DEL_LIMIT  , "the --max-delete limit stopped deletions" },
        { 0, NULL }
 };
 
@@ -265,10 +263,16 @@ void rwrite(enum logcode code, const char *buf, int len, int is_utf8)
        if (len < 0)
                exit_cleanup(RERR_MESSAGEIO);
 
-       if (msgs2stderr && code != FLOG)
-               goto output_msg;
-
-       if (send_msgs_to_gen) {
+       if (msgs2stderr) {
+               if (!am_daemon) {
+                       if (code == FLOG)
+                               return;
+                       goto output_msg;
+               }
+               if (code == FCLIENT)
+                       return;
+               code = FLOG;
+       } else if (send_msgs_to_gen) {
                assert(!is_utf8);
                /* Pass the message to our sibling in native charset. */
                send_msg((enum msgcode)code, buf, len, 0);
@@ -330,13 +334,17 @@ output_msg:
                got_xfer_error = 1;
                /* FALL THROUGH */
        case FERROR:
+       case FERROR_UTF8:
+       case FERROR_SOCKET:
        case FWARNING:
                f = stderr;
                break;
+       case FLOG:
        case FINFO:
        case FCLIENT:
                break;
        default:
+               fprintf(stderr, "Unknown logcode in rwrite(): %d [%s]\n", (int)code, who_am_i());
                exit_cleanup(RERR_MESSAGEIO);
        }
 
@@ -793,7 +801,7 @@ int log_format_has(const char *format, char esc)
                return 0;
 
        for (p = format; (p = strchr(p, '%')) != NULL; ) {
-               for (p++; *p == '\''; p++) {}
+               for (p++; *p == '\''; p++) {} /*SHARED ITERATOR*/
                if (*p == '-')
                        p++;
                while (isDigit(p))
@@ -840,10 +848,11 @@ void maybe_log_item(struct file_struct *file, int iflags, int itemizing,
 
 void log_delete(const char *fname, int mode)
 {
+       /* Zero-initialized */
        static struct {
                union file_extras ex[4]; /* just in case... */
                struct file_struct file;
-       } x;
+       } x; /* Zero-initialized due to static declaration. */
        int len = strlen(fname);
        const char *fmt;