|
From: <sv...@va...> - 2014-12-10 16:08:16
|
Author: florian
Date: Wed Dec 10 16:08:09 2014
New Revision: 3037
Log:
New function vfatal which should be used for user messages
to indicate a situation that can legitimately occur but that
we cannot handle today. The function does not return.
Modified:
trunk/priv/main_util.c
trunk/priv/main_util.h
Modified: trunk/priv/main_util.c
==============================================================================
--- trunk/priv/main_util.c (original)
+++ trunk/priv/main_util.c Wed Dec 10 16:08:09 2014
@@ -263,6 +263,7 @@
(*vex_failure_exit)();
}
+/* To be used in assert-like (i.e. should never ever happen) situations */
__attribute__ ((noreturn))
void vpanic ( const HChar* str )
{
@@ -543,11 +544,9 @@
}
}
-UInt vex_printf ( const HChar* format, ... )
+static UInt vex_vprintf ( const HChar* format, va_list vargs )
{
UInt ret;
- va_list vargs;
- va_start(vargs,format);
n_myprintf_buf = 0;
myprintf_buf[n_myprintf_buf] = 0;
@@ -557,11 +556,33 @@
(*vex_log_bytes)( myprintf_buf, n_myprintf_buf );
}
+ return ret;
+}
+
+UInt vex_printf ( const HChar* format, ... )
+{
+ UInt ret;
+ va_list vargs;
+ va_start(vargs, format);
+ ret = vex_vprintf(format, vargs);
va_end(vargs);
return ret;
}
+/* Use this function to communicate to users that a (legitimate) situation
+ occured that we cannot handle (yet). */
+__attribute__ ((noreturn))
+void vfatal ( const HChar* format, ... )
+{
+ va_list vargs;
+ va_start(vargs, format);
+ vex_vprintf( format, vargs );
+ va_end(vargs);
+ vex_printf("Cannot continue. Good-bye\n\n");
+
+ (*vex_failure_exit)();
+}
/* A general replacement for sprintf(). */
Modified: trunk/priv/main_util.h
==============================================================================
--- trunk/priv/main_util.h (original)
+++ trunk/priv/main_util.h Wed Dec 10 16:08:09 2014
@@ -62,6 +62,9 @@
__attribute__ ((__noreturn__))
extern void vpanic ( const HChar* str );
+__attribute__ ((__noreturn__)) __attribute__ ((format (printf, 1, 2)))
+extern void vfatal ( const HChar* format, ... );
+
/* Printing */
|