summaryrefslogtreecommitdiff
path: root/daemon.c
diff options
context:
space:
mode:
authorDavid Soria Parra <dsp@php.net>2008-08-31 14:09:39 +0200
committerJunio C Hamano <gitster@pobox.com>2008-08-31 16:56:22 -0700
commit85e72830697a23dd6b1af8b6bfb3c1a7be60dfae (patch)
tree79d92b09ff24b887bca91fa28f9d573efb2aed69 /daemon.c
parent7f314565fe20e324e8db1a7c233e43ca4e3683f0 (diff)
downloadgit-85e72830697a23dd6b1af8b6bfb3c1a7be60dfae.tar.gz
cast pid_t's to uintmax_t to improve portability
Some systems (like e.g. OpenSolaris) define pid_t as long, therefore all our sprintf that use %i/%d cause a compiler warning beacuse of the implicit long->int cast. To make sure that we fit the limits, we display pids as PRIuMAX and cast them explicitly to uintmax_t. Signed-off-by: David Soria Parra <dsp@php.net> Signed-off-by: Junio C Hamano <gitster@pobox.com>
Diffstat (limited to 'daemon.c')
-rw-r--r--daemon.c6
1 files changed, 3 insertions, 3 deletions
diff --git a/daemon.c b/daemon.c
index 23278e28dc..c315932ced 100644
--- a/daemon.c
+++ b/daemon.c
@@ -86,7 +86,7 @@ static void logreport(int priority, const char *err, va_list params)
* Since stderr is set to linebuffered mode, the
* logging of different processes will not overlap
*/
- fprintf(stderr, "[%d] ", (int)getpid());
+ fprintf(stderr, "[%"PRIuMAX"] ", (uintmax_t)getpid());
vfprintf(stderr, err, params);
fputc('\n', stderr);
}
@@ -658,7 +658,7 @@ static void check_dead_children(void)
remove_child(pid);
if (!WIFEXITED(status) || (WEXITSTATUS(status) > 0))
dead = " (with error)";
- loginfo("[%d] Disconnected%s", (int)pid, dead);
+ loginfo("[%"PRIuMAX"] Disconnected%s", (uintmax_t)pid, dead);
}
}
@@ -923,7 +923,7 @@ static void store_pid(const char *path)
FILE *f = fopen(path, "w");
if (!f)
die("cannot open pid file %s: %s", path, strerror(errno));
- if (fprintf(f, "%d\n", getpid()) < 0 || fclose(f) != 0)
+ if (fprintf(f, "%"PRIuMAX"\n", (uintmax_t) getpid()) < 0 || fclose(f) != 0)
die("failed to write pid file %s: %s", path, strerror(errno));
}