Welcome to mirror list, hosted at ThFree Co, Russian Federation.

git.kernel.org/pub/scm/git/git.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
Diffstat (limited to 'usage.c')
-rw-r--r--usage.c32
1 files changed, 32 insertions, 0 deletions
diff --git a/usage.c b/usage.c
index ad6d2910fb..7e6cb20280 100644
--- a/usage.c
+++ b/usage.c
@@ -201,3 +201,35 @@ void warning(const char *warn, ...)
warn_routine(warn, params);
va_end(params);
}
+
+static NORETURN void BUG_vfl(const char *file, int line, const char *fmt, va_list params)
+{
+ char prefix[256];
+
+ /* truncation via snprintf is OK here */
+ if (file)
+ snprintf(prefix, sizeof(prefix), "BUG: %s:%d: ", file, line);
+ else
+ snprintf(prefix, sizeof(prefix), "BUG: ");
+
+ vreportf(prefix, fmt, params);
+ abort();
+}
+
+#ifdef HAVE_VARIADIC_MACROS
+void BUG_fl(const char *file, int line, const char *fmt, ...)
+{
+ va_list ap;
+ va_start(ap, fmt);
+ BUG_vfl(file, line, fmt, ap);
+ va_end(ap);
+}
+#else
+void BUG(const char *fmt, ...)
+{
+ va_list ap;
+ va_start(ap, fmt);
+ BUG_vfl(NULL, 0, fmt, ap);
+ va_end(ap);
+}
+#endif