Skip to content

Commit 4bf5383

Browse files
raalkmlgitster
authored andcommitted
Avoid using va_copy in fast-import: it seems to be unportable.
[sp: minor change to use fputs, thus reducing the patch size] Signed-off-by: Alex Riesen <raa.lkml@gmail.com> Signed-off-by: Shawn O. Pearce <spearce@spearce.org> Signed-off-by: Junio C Hamano <gitster@pobox.com>
1 parent 23d5335 commit 4bf5383

File tree

1 file changed

+6
-7
lines changed

1 file changed

+6
-7
lines changed

fast-import.c

Lines changed: 6 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -375,7 +375,7 @@ static void write_branch_report(FILE *rpt, struct branch *b)
375375
fputc('\n', rpt);
376376
}
377377

378-
static void write_crash_report(const char *err, va_list params)
378+
static void write_crash_report(const char *err)
379379
{
380380
char *loc = git_path("fast_import_crash_%d", getpid());
381381
FILE *rpt = fopen(loc, "w");
@@ -397,7 +397,7 @@ static void write_crash_report(const char *err, va_list params)
397397
fputc('\n', rpt);
398398

399399
fputs("fatal: ", rpt);
400-
vfprintf(rpt, err, params);
400+
fputs(err, rpt);
401401
fputc('\n', rpt);
402402

403403
fputc('\n', rpt);
@@ -442,18 +442,17 @@ static void write_crash_report(const char *err, va_list params)
442442
static NORETURN void die_nicely(const char *err, va_list params)
443443
{
444444
static int zombie;
445-
va_list x_params;
445+
char message[2 * PATH_MAX];
446446

447-
va_copy(x_params, params);
447+
vsnprintf(message, sizeof(message), err, params);
448448
fputs("fatal: ", stderr);
449-
vfprintf(stderr, err, params);
449+
fputs(message, stderr);
450450
fputc('\n', stderr);
451451

452452
if (!zombie) {
453453
zombie = 1;
454-
write_crash_report(err, x_params);
454+
write_crash_report(message);
455455
}
456-
va_end(x_params);
457456
exit(128);
458457
}
459458

0 commit comments

Comments
 (0)