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>
This commit is contained in:
committed by
Junio C Hamano
parent
7f314565fe
commit
85e7283069
@ -376,7 +376,7 @@ static void dump_marks_helper(FILE *, uintmax_t, struct mark_set *);
|
||||
|
||||
static void write_crash_report(const char *err)
|
||||
{
|
||||
char *loc = git_path("fast_import_crash_%d", getpid());
|
||||
char *loc = git_path("fast_import_crash_%"PRIuMAX, (uintmax_t) getpid());
|
||||
FILE *rpt = fopen(loc, "w");
|
||||
struct branch *b;
|
||||
unsigned long lu;
|
||||
@ -390,8 +390,8 @@ static void write_crash_report(const char *err)
|
||||
fprintf(stderr, "fast-import: dumping crash report to %s\n", loc);
|
||||
|
||||
fprintf(rpt, "fast-import crash report:\n");
|
||||
fprintf(rpt, " fast-import process: %d\n", getpid());
|
||||
fprintf(rpt, " parent process : %d\n", getppid());
|
||||
fprintf(rpt, " fast-import process: %"PRIuMAX"\n", (uintmax_t) getpid());
|
||||
fprintf(rpt, " parent process : %"PRIuMAX"\n", (uintmax_t) getppid());
|
||||
fprintf(rpt, " at %s\n", show_date(time(NULL), 0, DATE_LOCAL));
|
||||
fputc('\n', rpt);
|
||||
|
||||
|
||||
Reference in New Issue
Block a user