1
0
mirror of git://sourceware.org/git/lvm2.git synced 2025-01-03 05:18:29 +03:00

Use _LOG_FATAL when aborting on an internal error.

This commit is contained in:
Alasdair Kergon 2010-01-11 20:41:39 +00:00
parent e995e713f9
commit e55df6fee5

View File

@ -179,16 +179,20 @@ void print_log(int level, const char *file, int line, int dm_errno,
const char *trformat; /* Translated format string */ const char *trformat; /* Translated format string */
char *newbuf; char *newbuf;
int use_stderr = level & _LOG_STDERR; int use_stderr = level & _LOG_STDERR;
int internal_error = 0; int fatal_internal_error = 0;
level &= ~_LOG_STDERR; level &= ~_LOG_STDERR;
if (_abort_on_internal_errors && if (_abort_on_internal_errors &&
!strncmp(format, INTERNAL_ERROR, !strncmp(format, INTERNAL_ERROR,
strlen(INTERNAL_ERROR))) strlen(INTERNAL_ERROR))) {
internal_error = 1; fatal_internal_error = 1;
else if (_log_suppress == 2)
/* Internal errors triggering abort cannot be suppressed. */ /* Internal errors triggering abort cannot be suppressed. */
_log_suppress = 0;
level = _LOG_FATAL;
}
if (_log_suppress == 2)
return; return;
if (level <= _LOG_ERR) if (level <= _LOG_ERR)
@ -245,7 +249,7 @@ void print_log(int level, const char *file, int line, int dm_errno,
if (!strcmp("<backtrace>", format) && if (!strcmp("<backtrace>", format) &&
verbose_level() <= _LOG_DEBUG) verbose_level() <= _LOG_DEBUG)
break; break;
if (internal_error || verbose_level() >= _LOG_DEBUG) { if (verbose_level() >= _LOG_DEBUG) {
fprintf(stderr, "%s%s%s", locn, log_command_name(), fprintf(stderr, "%s%s%s", locn, log_command_name(),
_msg_prefix); _msg_prefix);
if (_indent) if (_indent)
@ -256,7 +260,7 @@ void print_log(int level, const char *file, int line, int dm_errno,
break; break;
case _LOG_INFO: case _LOG_INFO:
if (internal_error || verbose_level() >= _LOG_INFO) { if (verbose_level() >= _LOG_INFO) {
fprintf(stderr, "%s%s%s", locn, log_command_name(), fprintf(stderr, "%s%s%s", locn, log_command_name(),
_msg_prefix); _msg_prefix);
if (_indent) if (_indent)
@ -266,7 +270,7 @@ void print_log(int level, const char *file, int line, int dm_errno,
} }
break; break;
case _LOG_NOTICE: case _LOG_NOTICE:
if (internal_error || verbose_level() >= _LOG_NOTICE) { if (verbose_level() >= _LOG_NOTICE) {
fprintf(stderr, "%s%s%s", locn, log_command_name(), fprintf(stderr, "%s%s%s", locn, log_command_name(),
_msg_prefix); _msg_prefix);
if (_indent) if (_indent)
@ -276,7 +280,7 @@ void print_log(int level, const char *file, int line, int dm_errno,
} }
break; break;
case _LOG_WARN: case _LOG_WARN:
if (internal_error || verbose_level() >= _LOG_WARN) { if (verbose_level() >= _LOG_WARN) {
fprintf(use_stderr ? stderr : stdout, "%s%s", fprintf(use_stderr ? stderr : stdout, "%s%s",
log_command_name(), _msg_prefix); log_command_name(), _msg_prefix);
vfprintf(use_stderr ? stderr : stdout, trformat, ap); vfprintf(use_stderr ? stderr : stdout, trformat, ap);
@ -284,7 +288,7 @@ void print_log(int level, const char *file, int line, int dm_errno,
} }
break; break;
case _LOG_ERR: case _LOG_ERR:
if (internal_error || verbose_level() >= _LOG_ERR) { if (verbose_level() >= _LOG_ERR) {
fprintf(stderr, "%s%s%s", locn, log_command_name(), fprintf(stderr, "%s%s%s", locn, log_command_name(),
_msg_prefix); _msg_prefix);
vfprintf(stderr, trformat, ap); vfprintf(stderr, trformat, ap);
@ -293,7 +297,7 @@ void print_log(int level, const char *file, int line, int dm_errno,
break; break;
case _LOG_FATAL: case _LOG_FATAL:
default: default:
if (internal_error || verbose_level() >= _LOG_FATAL) { if (verbose_level() >= _LOG_FATAL) {
fprintf(stderr, "%s%s%s", locn, log_command_name(), fprintf(stderr, "%s%s%s", locn, log_command_name(),
_msg_prefix); _msg_prefix);
vfprintf(stderr, trformat, ap); vfprintf(stderr, trformat, ap);
@ -304,7 +308,7 @@ void print_log(int level, const char *file, int line, int dm_errno,
va_end(ap); va_end(ap);
} }
if (internal_error) if (fatal_internal_error)
abort(); abort();
if (level > debug_level()) if (level > debug_level())