summaryrefslogtreecommitdiffstats
path: root/src/util/support/errors.c
diff options
context:
space:
mode:
authorGreg Hudson <ghudson@mit.edu>2009-04-29 23:21:21 +0000
committerGreg Hudson <ghudson@mit.edu>2009-04-29 23:21:21 +0000
commit41d6e61e7a953d6ef5e77a3271208b1b6c4e4921 (patch)
tree7dbf3d53b8a58345edf9ae044f3f73dce5b6737d /src/util/support/errors.c
parent16aaf27414aaf5478b774e4c504128ef38faa307 (diff)
downloadkrb5-41d6e61e7a953d6ef5e77a3271208b1b6c4e4921.tar.gz
krb5-41d6e61e7a953d6ef5e77a3271208b1b6c4e4921.tar.xz
krb5-41d6e61e7a953d6ef5e77a3271208b1b6c4e4921.zip
Add DEBUG_ERROR_LOCATIONS support
If DEBUG_ERROR_LOCATIONS is defined, replace uses of krb5_set_error_message and krb5int_set_error with calls to the new _fl variants of those functions, and include filename and line number information in the calls. Requires C99-style variadic macros if defined. ticket: 6479 git-svn-id: svn://anonsvn.mit.edu/krb5/trunk@22291 dc483132-0cff-0310-8789-dd5450dbe970
Diffstat (limited to 'src/util/support/errors.c')
-rw-r--r--src/util/support/errors.c34
1 files changed, 32 insertions, 2 deletions
diff --git a/src/util/support/errors.c b/src/util/support/errors.c
index 4111ed478..8d523b98b 100644
--- a/src/util/support/errors.c
+++ b/src/util/support/errors.c
@@ -34,12 +34,23 @@ krb5int_err_init (void)
#define lock() k5_mutex_lock(&krb5int_error_info_support_mutex)
#define unlock() k5_mutex_unlock(&krb5int_error_info_support_mutex)
+#undef krb5int_set_error
void
krb5int_set_error (struct errinfo *ep, long code, const char *fmt, ...)
{
va_list args;
va_start (args, fmt);
- krb5int_vset_error (ep, code, fmt, args);
+ krb5int_vset_error_fl (ep, code, NULL, 0, fmt, args);
+ va_end (args);
+}
+
+void
+krb5int_set_error_fl (struct errinfo *ep, long code,
+ const char *file, int line, const char *fmt, ...)
+{
+ va_list args;
+ va_start (args, fmt);
+ krb5int_vset_error_fl (ep, code, file, line, fmt, args);
va_end (args);
}
@@ -47,8 +58,16 @@ void
krb5int_vset_error (struct errinfo *ep, long code,
const char *fmt, va_list args)
{
+ krb5int_vset_error_fl(ep, code, NULL, 0, fmt, args);
+}
+
+void
+krb5int_vset_error_fl (struct errinfo *ep, long code,
+ const char *file, int line,
+ const char *fmt, va_list args)
+{
va_list args2;
- char *str = NULL;
+ char *str = NULL, *str2, *slash;
const char *loc_fmt = NULL;
#ifdef USE_KIM
@@ -66,6 +85,17 @@ krb5int_vset_error (struct errinfo *ep, long code,
str = NULL;
}
va_end(args2);
+
+ if (str && line) {
+ /* Try to add file and line suffix. */
+ slash = strrchr(file, '/');
+ if (slash)
+ file = slash + 1;
+ if (asprintf(&str2, "%s (%s: %d)", str, file, line) > 0) {
+ free(str);
+ str = str2;
+ }
+ }
/* If that failed, try using scratch_buf */
if (str == NULL) {