diff options
author | Stef Walter <stefw@gnome.org> | 2012-05-13 22:27:07 +0200 |
---|---|---|
committer | Stef Walter <stefw@gnome.org> | 2012-05-13 22:27:07 +0200 |
commit | caa953cba4d2d0cdd4823eb2f1c4f24bbf18a231 (patch) | |
tree | f303e5018500104b9d807628f196d5baf2c9336f /p11-kit/debug.c | |
parent | 7bd4114182fcc86cd2515708fdf4d76622e0237d (diff) |
Preconditions to check for input probs and out of memory
* We don't try to guarantee completely robust and problem
free behavior in cases where the caller or process isn't
behaving. We consider these to be outside of our control.
Diffstat (limited to 'p11-kit/debug.c')
-rw-r--r-- | p11-kit/debug.c | 19 |
1 files changed, 19 insertions, 0 deletions
diff --git a/p11-kit/debug.c b/p11-kit/debug.c index 37095be..a665d0f 100644 --- a/p11-kit/debug.c +++ b/p11-kit/debug.c @@ -59,6 +59,7 @@ static struct DebugKey debug_keys[] = { }; static int debug_inited = 0; +static int debug_strict = 0; /* global variable exported in debug.h */ int _p11_debug_current_flags = ~0; @@ -72,6 +73,10 @@ parse_environ_flags (void) const char *q; int i; + env = getenv ("P11_KIT_STRICT"); + if (env && env[0] != '\0') + debug_strict = 1; + env = getenv ("P11_KIT_DEBUG"); if (!env) return 0; @@ -130,3 +135,17 @@ _p11_debug_message (int flag, fprintf (stderr, "(p11-kit:%d) %s\n", getpid(), buffer); } } + +void +_p11_debug_precond (const char *format, + ...) +{ + va_list va; + + va_start (va, format); + vfprintf (stderr, format, va); + va_end (va); + + if (debug_strict) + abort (); +} |