diff error.c @ 582:15b3b9cb1f37

error: wrap assfail/__assert in a helper function Instead of mimicking a very specific function signature, let's make our own function that we can change as we please. Signed-off-by: Josef 'Jeff' Sipek <jeffpc@josefsipek.net>
author Josef 'Jeff' Sipek <jeffpc@josefsipek.net>
date Wed, 17 Oct 2018 12:56:56 -0400
parents d53c1436a171
children 761ed4ccdc85
line wrap: on
line diff
--- a/error.c	Tue Oct 16 20:23:50 2018 -0400
+++ b/error.c	Wed Oct 17 12:56:56 2018 -0400
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2013-2017 Josef 'Jeff' Sipek <jeffpc@josefsipek.net>
+ * Copyright (c) 2013-2018 Josef 'Jeff' Sipek <jeffpc@josefsipek.net>
  *
  * Permission is hereby granted, free of charge, to any person obtaining a copy
  * of this software and associated documentation files (the "Software"), to deal
@@ -34,17 +34,21 @@
 
 #include "init.h"
 
-#ifndef HAVE_ASSFAIL
-static int assfail(const char *assertion, const char *file, int line)
-{
-	__assert(assertion, file, line);
-
-	return 0; /* not reached */
-}
-#else
+#ifdef HAVE_ASSFAIL
+/* See comment at the end of this file about assfail type checking */
 extern int assfail(const char *a, const char *f, int l);
 #endif
 
+static inline void assertion_failed(const char *assertion, const char *file,
+				    int line)
+{
+#if defined(HAVE_ASSFAIL)
+	assfail(assertion, file, line);
+#else
+	__assert(assertion, file, line);
+#endif
+}
+
 void default_print(enum errlevel level, const char *fmt, va_list ap)
 {
 	FILE *out;
@@ -113,7 +117,7 @@
 
 	print_stacktrace(CE_CRIT, NULL);
 
-	assfail(a, f, l);
+	assertion_failed(a, f, l);
 }
 
 void jeffpc_assfail(const char *a, const char *f, int l)
@@ -137,7 +141,7 @@
 
 	print_stacktrace(CE_CRIT, NULL);
 
-	assfail(msg, f, l);
+	assertion_failed(msg, f, l);
 }
 
 void jeffpc_assfail3(const char *a, uintmax_t lv, const char *op, uintmax_t rv,