Commit 35276770 authored by Wayne Davison's avatar Wayne Davison

Let's cast getpid() to an int instead of a long for snprintf().

parent fd91c3b6
......@@ -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;
......
......@@ -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();
......
......@@ -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':
......
......@@ -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. */
......
......@@ -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);
......
......@@ -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;
......
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