[SCM] The rsync repository. - branch master updated
Rsync CVS commit messages
rsync-cvs at lists.samba.org
Sat Oct 8 10:15:40 MDT 2011
The branch, master has been updated
via 7c8f180 Test asprintf() failure with < 0, not <= 0.
via 3527677 Let's cast getpid() to an int instead of a long for snprintf().
from fd91c3b Fix two unused-variable compiler warnings.
;a=shortlog;h=master
- Log -----------------------------------------------------------------
commit 7c8f180900432e646c0a4bd02e2c4033068dbb7c
Author: Wayne Davison <wayned at samba.org>
Date: Sat Oct 8 09:16:43 2011 -0700
Test asprintf() failure with < 0, not <= 0.
commit 3527677043f5a995b6a49e318d0f029ac187a97e
Author: Wayne Davison <wayned at samba.org>
Date: Sat Oct 8 09:15:36 2011 -0700
Let's cast getpid() to an int instead of a long for snprintf().
-----------------------------------------------------------------------
Summary of changes:
clientserver.c | 2 +-
generator.c | 2 +-
log.c | 8 +++-----
main.c | 19 +++++++------------
testrun.c | 4 ++--
util.c | 12 +++++++-----
6 files changed, 21 insertions(+), 26 deletions(-)
Changeset truncated at 500 lines:
diff --git a/clientserver.c b/clientserver.c
index 52ce44f..d63aa96 100644
--- a/clientserver.c
+++ b/clientserver.c
@@ -1121,7 +1121,7 @@ static void create_pid_file(void)
rsyserr(FLOG, errno, "failed to create pid file %s", pid_file);
exit_cleanup(RERR_FILEIO);
}
- snprintf(pidbuf, sizeof pidbuf, "%ld\n", (long)pid);
+ snprintf(pidbuf, sizeof pidbuf, "%d\n", (int)pid);
len = strlen(pidbuf);
if (write(fd, pidbuf, len) != len)
goto failure;
diff --git a/generator.c b/generator.c
index 30e3f32..25648ce 100644
--- a/generator.c
+++ b/generator.c
@@ -2124,7 +2124,7 @@ void generate_files(int f_out, const char *local_name)
implied_dirs_are_missing = relative_paths && !implied_dirs && protocol_version < 30;
if (DEBUG_GTE(GENR, 1))
- rprintf(FINFO, "generator starting pid=%ld\n", (long)getpid());
+ rprintf(FINFO, "generator starting pid=%d\n", (int)getpid());
if (delete_before && !solo_file && cur_flist->used > 0)
do_delete_pass();
diff --git a/log.c b/log.c
index f842e55..ab85877 100644
--- a/log.c
+++ b/log.c
@@ -123,8 +123,7 @@ static void logit(int priority, const char *buf)
if (logfile_was_closed)
logfile_reopen();
if (logfile_fp) {
- fprintf(logfile_fp, "%s [%d] %s",
- timestring(time(NULL)), (int)getpid(), buf);
+ fprintf(logfile_fp, "%s [%d] %s", timestring(time(NULL)), (int)getpid(), buf);
fflush(logfile_fp);
} else {
syslog(priority, "%s", buf);
@@ -569,9 +568,8 @@ static void log_formatted(enum logcode code, const char *format, const char *op,
}
break;
case 'p':
- strlcat(fmt, "ld", sizeof fmt);
- snprintf(buf2, sizeof buf2, fmt,
- (long)getpid());
+ strlcat(fmt, "d", sizeof fmt);
+ snprintf(buf2, sizeof buf2, fmt, (int)getpid());
n = buf2;
break;
case 'M':
diff --git a/main.c b/main.c
index c5e106c..17ba62d 100644
--- a/main.c
+++ b/main.c
@@ -364,7 +364,7 @@ static void show_malloc_stats(void)
rprintf(FCLIENT, "\n");
rprintf(FINFO, RSYNC_NAME "[%d] (%s%s%s) heap statistics:\n",
- getpid(), am_server ? "server " : "",
+ (int)getpid(), am_server ? "server " : "",
am_daemon ? "daemon " : "", who_am_i());
rprintf(FINFO, " arena: %10ld (bytes from sbrk)\n",
(long)mi.arena);
@@ -774,10 +774,8 @@ static void do_server_sender(int f_in, int f_out, int argc, char *argv[])
struct file_list *flist;
char *dir = argv[0];
- if (DEBUG_GTE(SEND, 1)) {
- rprintf(FINFO, "server_sender starting pid=%ld\n",
- (long)getpid());
- }
+ if (DEBUG_GTE(SEND, 1))
+ rprintf(FINFO, "server_sender starting pid=%d\n", (int)getpid());
if (am_daemon && lp_write_only(module_id)) {
rprintf(FERROR, "ERROR: module is write only\n");
@@ -972,10 +970,8 @@ static void do_server_recv(int f_in, int f_out, int argc, char *argv[])
} else
negated_levels = 0;
- if (DEBUG_GTE(RECV, 1)) {
- rprintf(FINFO, "server_recv(%d) starting pid=%ld\n",
- argc, (long)getpid());
- }
+ if (DEBUG_GTE(RECV, 1))
+ rprintf(FINFO, "server_recv(%d) starting pid=%d\n", argc, (int)getpid());
if (am_daemon && read_only) {
rprintf(FERROR,"ERROR: module is read only\n");
@@ -1491,10 +1487,9 @@ const char *get_panic_action(void)
static RETSIGTYPE rsync_panic_handler(UNUSED(int whatsig))
{
char cmd_buf[300];
- int ret;
+ int ret, pid_int = getpid();
- snprintf(cmd_buf, sizeof cmd_buf, get_panic_action(),
- getpid(), getpid());
+ snprintf(cmd_buf, sizeof cmd_buf, get_panic_action(), pid_int, pid_int);
/* Unless we failed to execute gdb, we allow the process to
* continue. I'm not sure if that's right. */
diff --git a/testrun.c b/testrun.c
index ddf596d..049e3eb 100644
--- a/testrun.c
+++ b/testrun.c
@@ -46,9 +46,9 @@
if (slept++ > timeout_secs) {
fprintf(stderr, "TESTRUN TIMEOUT: test took over %d seconds.\n", timeout_secs);
if (kill(pid, SIGTERM) < 0)
- fprintf(stderr, "TESTRUN ERROR: failed to kill pid %ld: %s\n", (long)pid, strerror(errno));
+ fprintf(stderr, "TESTRUN ERROR: failed to kill pid %d: %s\n", (int)pid, strerror(errno));
else
- fprintf(stderr, "TESTRUN INFO: killed pid %ld\n", (long)pid);
+ fprintf(stderr, "TESTRUN INFO: killed pid %d\n", (int)pid);
exit(1);
}
sleep(1);
diff --git a/util.c b/util.c
index abf0cd4..ea9ca7d 100644
--- a/util.c
+++ b/util.c
@@ -762,7 +762,7 @@ void glob_expand_module(char *base1, char *arg, char ***argv_p, int *argc_p, int
if (!(arg = strdup(arg)))
out_of_memory("glob_expand_module");
- if (asprintf(&base," %s/", base1) <= 0)
+ if (asprintf(&base," %s/", base1) < 0)
out_of_memory("glob_expand_module");
base_len++;
@@ -1144,7 +1144,7 @@ char *full_fname(const char *fn)
} else
m1 = m2 = m3 = "";
- if (asprintf(&result, "\"%s%s%s\"%s%s%s", p1, p2, fn, m1, m2, m3) <= 0)
+ if (asprintf(&result, "\"%s%s%s\"%s%s%s", p1, p2, fn, m1, m2, m3) < 0)
out_of_memory("full_fname");
return result;
@@ -1358,11 +1358,13 @@ int cmp_time(time_t file1, time_t file2)
int _Insure_trap_error(int a1, int a2, int a3, int a4, int a5, int a6)
{
static int (*fn)();
- int ret;
+ int ret, pid_int = getpid();
char *cmd;
- asprintf(&cmd, "/usr/X11R6/bin/xterm -display :0 -T Panic -n Panic -e /bin/sh -c 'cat /tmp/ierrs.*.%d ; gdb /proc/%d/exe %d'",
- getpid(), getpid(), getpid());
+ if (asprintf(&cmd,
+ "/usr/X11R6/bin/xterm -display :0 -T Panic -n Panic -e /bin/sh -c 'cat /tmp/ierrs.*.%d ; "
+ "gdb /proc/%d/exe %d'", pid_int, pid_int, pid_int) < 0)
+ return -1;
if (!fn) {
static void *h;
--
The rsync repository.
More information about the rsync-cvs
mailing list