From 835b293d35a209d38047126443d41fa7090daa4c Mon Sep 17 00:00:00 2001 From: Justus Winter Date: Mon, 19 Jun 2017 21:20:57 +0200 Subject: Use our own variant of 'assert' and 'assert_perror'. Our variants print stack traces on failures. This will make locating errors much easier. --- libfshelp/fetch-control.c | 4 ++-- libfshelp/fetch-root.c | 4 ++-- libfshelp/get-identity.c | 4 ++-- libfshelp/lock-acquire.c | 12 ++++++------ libfshelp/start-translator-long.c | 4 ++-- 5 files changed, 14 insertions(+), 14 deletions(-) (limited to 'libfshelp') diff --git a/libfshelp/fetch-control.c b/libfshelp/fetch-control.c index 91c65bb0..0a11197a 100644 --- a/libfshelp/fetch-control.c +++ b/libfshelp/fetch-control.c @@ -19,7 +19,7 @@ Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. */ #include "fshelp.h" -#include +#include error_t fshelp_fetch_control (struct transbox *box, @@ -34,7 +34,7 @@ fshelp_fetch_control (struct transbox *box, if (err == KERN_INVALID_RIGHT) { err = mach_port_deallocate (mach_task_self (), *control); - assert_perror (err); + assert_perror_backtrace (err); *control = box->active = MACH_PORT_NULL; } diff --git a/libfshelp/fetch-root.c b/libfshelp/fetch-root.c index 75aa2d37..0248f11d 100644 --- a/libfshelp/fetch-root.c +++ b/libfshelp/fetch-root.c @@ -18,7 +18,7 @@ along with this program; if not, write to the Free Software Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. */ -#include +#include #include #include #include @@ -47,7 +47,7 @@ fshelp_fetch_root (struct transbox *box, void *cookie, start_over: if (box->active != MACH_PORT_NULL) - assert ((box->flags & TRANSBOX_STARTING) == 0); + assert_backtrace ((box->flags & TRANSBOX_STARTING) == 0); else { uid_t uid, gid; diff --git a/libfshelp/get-identity.c b/libfshelp/get-identity.c index 2dbd254c..17244dee 100644 --- a/libfshelp/get-identity.c +++ b/libfshelp/get-identity.c @@ -23,7 +23,7 @@ #include #include #include -#include +#include static struct port_class *idclass = 0; static pthread_mutex_t idlock = PTHREAD_MUTEX_INITIALIZER; @@ -49,7 +49,7 @@ id_clean (void *cookie) static void id_initialize () { - assert (!idclass); + assert_backtrace (!idclass); idclass = ports_create_class (id_clean, NULL); } diff --git a/libfshelp/lock-acquire.c b/libfshelp/lock-acquire.c index 07df4283..47a63dab 100644 --- a/libfshelp/lock-acquire.c +++ b/libfshelp/lock-acquire.c @@ -19,7 +19,7 @@ /* Written by Michael I. Bushnell. */ -#include +#include #include #include "fshelp.h" @@ -60,9 +60,9 @@ fshelp_acquire_lock (struct lock_box *box, int *user, pthread_mutex_t *mut, if (*user & LOCK_UN) return 0; - assert (*user == box->type || + assert_backtrace (*user == box->type || (*user == LOCK_SH && box->type == (LOCK_SH | LOCK_EX))); - assert (*user == LOCK_SH || *user == LOCK_EX || + assert_backtrace (*user == LOCK_SH || *user == LOCK_EX || *user == (LOCK_SH | LOCK_EX)); if (*user == LOCK_SH) @@ -153,10 +153,10 @@ fshelp_acquire_lock (struct lock_box *box, int *user, pthread_mutex_t *mut, return EINTR; } - assert ((flags & LOCK_SH) || (flags & LOCK_EX)); + assert_backtrace ((flags & LOCK_SH) || (flags & LOCK_EX)); if (flags & LOCK_SH) { - assert (!(box->type & LOCK_EX)); + assert_backtrace (!(box->type & LOCK_EX)); *user = LOCK_SH; box->type = LOCK_SH; box->shcount++; @@ -182,7 +182,7 @@ fshelp_acquire_lock (struct lock_box *box, int *user, pthread_mutex_t *mut, } if (*user == LOCK_SH) { - assert (box->shcount == 1); + assert_backtrace (box->shcount == 1); box->shcount = 0; } box->type = LOCK_EX; diff --git a/libfshelp/start-translator-long.c b/libfshelp/start-translator-long.c index da6f52e3..e1aea3c4 100644 --- a/libfshelp/start-translator-long.c +++ b/libfshelp/start-translator-long.c @@ -26,7 +26,7 @@ #include #include #include -#include +#include #include "fshelp.h" @@ -247,7 +247,7 @@ fshelp_start_translator_long (fshelp_open_fn_t underlying_open_fn, if (err) goto lose_task; - assert (ports_len > INIT_PORT_BOOTSTRAP); + assert_backtrace (ports_len > INIT_PORT_BOOTSTRAP); switch (ports_type) { case MACH_MSG_TYPE_MAKE_SEND: -- cgit v1.2.3