Make report() from usage.c public as vreportf() and use it.

There exist already a number of static functions named 'report', therefore,
the function name was changed.

Signed-off-by: Johannes Sixt <j6t@kdbg.org>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
This commit is contained in:
Johannes Sixt 2010-03-06 16:40:39 +01:00 committed by Junio C Hamano
parent 1d8cd418b4
commit ebaa79f462
4 changed files with 10 additions and 14 deletions

View File

@ -483,14 +483,12 @@ static void dump_marks(void);
static NORETURN void die_nicely(const char *err, va_list params) static NORETURN void die_nicely(const char *err, va_list params)
{ {
static int zombie; static int zombie;
char message[2 * PATH_MAX];
vsnprintf(message, sizeof(message), err, params); vreportf("fatal: ", err, params);
fputs("fatal: ", stderr);
fputs(message, stderr);
fputc('\n', stderr);
if (!zombie) { if (!zombie) {
char message[2 * PATH_MAX];
zombie = 1; zombie = 1;
write_crash_report(message); write_crash_report(message);
end_packfile(); end_packfile();

View File

@ -192,6 +192,7 @@ extern char *gitbasename(char *);
#include "compat/bswap.h" #include "compat/bswap.h"
/* General helper functions */ /* General helper functions */
extern void vreportf(const char *prefix, const char *err, va_list params);
extern NORETURN void usage(const char *err); extern NORETURN void usage(const char *err);
extern NORETURN void usagef(const char *err, ...) __attribute__((format (printf, 1, 2))); extern NORETURN void usagef(const char *err, ...) __attribute__((format (printf, 1, 2)));
extern NORETURN void die(const char *err, ...) __attribute__((format (printf, 1, 2))); extern NORETURN void die(const char *err, ...) __attribute__((format (printf, 1, 2)));

View File

@ -538,14 +538,11 @@ static void service_rpc(char *service_name)
static NORETURN void die_webcgi(const char *err, va_list params) static NORETURN void die_webcgi(const char *err, va_list params)
{ {
char buffer[1000];
http_status(500, "Internal Server Error"); http_status(500, "Internal Server Error");
hdr_nocache(); hdr_nocache();
end_headers(); end_headers();
vsnprintf(buffer, sizeof(buffer), err, params); vreportf("fatal: ", err, params);
fprintf(stderr, "fatal: %s\n", buffer);
exit(0); exit(0);
} }

10
usage.c
View File

@ -5,7 +5,7 @@
*/ */
#include "git-compat-util.h" #include "git-compat-util.h"
static void report(const char *prefix, const char *err, va_list params) void vreportf(const char *prefix, const char *err, va_list params)
{ {
char msg[4096]; char msg[4096];
vsnprintf(msg, sizeof(msg), err, params); vsnprintf(msg, sizeof(msg), err, params);
@ -14,24 +14,24 @@ static void report(const char *prefix, const char *err, va_list params)
static NORETURN void usage_builtin(const char *err, va_list params) static NORETURN void usage_builtin(const char *err, va_list params)
{ {
report("usage: ", err, params); vreportf("usage: ", err, params);
exit(129); exit(129);
} }
static NORETURN void die_builtin(const char *err, va_list params) static NORETURN void die_builtin(const char *err, va_list params)
{ {
report("fatal: ", err, params); vreportf("fatal: ", err, params);
exit(128); exit(128);
} }
static void error_builtin(const char *err, va_list params) static void error_builtin(const char *err, va_list params)
{ {
report("error: ", err, params); vreportf("error: ", err, params);
} }
static void warn_builtin(const char *warn, va_list params) static void warn_builtin(const char *warn, va_list params)
{ {
report("warning: ", warn, params); vreportf("warning: ", warn, params);
} }
/* If we are in a dlopen()ed .so write to a global variable would segfault /* If we are in a dlopen()ed .so write to a global variable would segfault