1
0
mirror of https://github.com/postgres/postgres.git synced 2025-07-28 23:42:10 +03:00

pg_upgrade: Split off pg_fatal() from pg_log()

This allows decorating pg_fatal() with noreturn compiler hints, leading
to better diagnostics.

Reviewed-by: Marko Tiikkaja <marko@joh.to>
This commit is contained in:
Peter Eisentraut
2013-10-01 21:24:56 -04:00
parent 261c7d4b65
commit 264aa14a2f
17 changed files with 166 additions and 174 deletions

View File

@ -80,15 +80,14 @@ prep_status(const char *fmt,...)
}
static
__attribute__((format(PG_PRINTF_ATTRIBUTE, 2, 0)))
void
pg_log(eLogType type, char *fmt,...)
pg_log_v(eLogType type, const char *fmt, va_list ap)
{
va_list args;
char message[MAX_STRING];
va_start(args, fmt);
vsnprintf(message, sizeof(message), fmt, args);
va_end(args);
vsnprintf(message, sizeof(message), fmt, ap);
/* PG_VERBOSE and PG_STATUS are only output in verbose mode */
/* fopen() on log_opts.internal might have failed, so check it */
@ -132,8 +131,6 @@ pg_log(eLogType type, char *fmt,...)
case PG_FATAL:
printf("\n%s", _(message));
printf("Failure, exiting\n");
exit(1);
break;
default:
@ -143,6 +140,30 @@ pg_log(eLogType type, char *fmt,...)
}
void
pg_log(eLogType type, const char *fmt,...)
{
va_list args;
va_start(args, fmt);
pg_log_v(type, fmt, args);
va_end(args);
}
void
pg_fatal(const char *fmt,...)
{
va_list args;
va_start(args, fmt);
pg_log_v(PG_FATAL, fmt, args);
va_end(args);
printf("Failure, exiting\n");
exit(1);
}
void
check_ok(void)
{