Minor fixes to debug functions
authorArran Cudbard-Bell <a.cudbardb@freeradius.org>
Sun, 26 Jan 2014 16:17:41 +0000 (16:17 +0000)
committerArran Cudbard-Bell <a.cudbardb@freeradius.org>
Sun, 26 Jan 2014 17:04:22 +0000 (17:04 +0000)
src/lib/debug.c
src/lib/log.c
src/main/mainconfig.c
src/main/radiusd.c

index 94e47ff..1808e70 100644 (file)
@@ -41,7 +41,7 @@
 
 #ifdef HAVE_EXECINFO_H
 #  define MAX_BT_FRAMES 128
-#  define MAX_BT_ENTRIES 65536                 //!< Should be a power of 2
+#  define MAX_BT_CBUFF  65536                  //!< Should be a power of 2
 
 #  ifdef HAVE_PTHREAD_H
 static pthread_mutex_t fr_debug_init = PTHREAD_MUTEX_INITIALIZER;
@@ -132,7 +132,7 @@ void backtrace_print(fr_cbuff_t *cbuff, void *obj)
 
                        fprintf(stderr, "Stacktrace for: %p\n", p);
                        for (i = 0; i < p->count; i++) {
-                               fprintf(stdout, "%s\n", frames[i]);
+                               fprintf(stderr, "%s\n", frames[i]);
                        }
 
                        /* We were only asked to look for one */
@@ -190,7 +190,7 @@ fr_bt_marker_t *fr_backtrace_attach(fr_cbuff_t **cbuff, TALLOC_CTX *obj)
                        TALLOC_CTX *ctx;
 
                        ctx = fr_autofree_ctx();
-                       *cbuff = fr_cbuff_alloc(ctx, MAX_BT_ENTRIES, true);
+                       *cbuff = fr_cbuff_alloc(ctx, MAX_BT_CBUFF, true);
                }
                PTHREAD_MUTEX_UNLOCK(&fr_debug_init);
        }
@@ -210,11 +210,11 @@ fr_bt_marker_t *fr_backtrace_attach(fr_cbuff_t **cbuff, TALLOC_CTX *obj)
 #else
 void backtrace_print(UNUSED fr_cbuff_t *cbuff, UNUSED void *obj)
 {
-       fr_perror("Server built without fr_backtrace_* support, requires execinfo.h and possibly -lexecinfo");
+       fprintf(stderr, "Server built without fr_backtrace_* support, requires execinfo.h and possibly -lexecinfo\n");
 }
 fr_bt_marker_t *fr_backtrace_attach(UNUSED fr_cbuff_t **cbuff, UNUSED TALLOC_CTX *obj)
 {
-       fr_perror("Server built without fr_backtrace_* support, requires execinfo.h and possibly -lexecinfo");
+       fprintf(stderr, "Server built without fr_backtrace_* support, requires execinfo.h and possibly -lexecinfo\n");
        abort();
 }
 #endif /* ifdef HAVE_EXECINFO_H */
index 467ad54..596fc44 100644 (file)
@@ -191,7 +191,7 @@ void fr_perror(char const *fmt, ...)
 bool fr_assert_cond(char const *file, int line, char const *expr, bool cond)
 {
        if (!cond) {
-               fr_perror("SOFT ASSERT FAILED %s[%u]: %s", file, line, expr);
+               fr_perror("SOFT ASSERT FAILED %s[%u]: %s", file, line, expr);
                return false;
        }
 
@@ -201,7 +201,7 @@ bool fr_assert_cond(char const *file, int line, char const *expr, bool cond)
 void NEVER_RETURNS _fr_exit(char const *file, int line, int status)
 {
 #ifndef NDEBUG
-       fr_perror("EXIT CALLED %s[%u]: %i", file, line, status);
+       fr_perror("EXIT CALLED %s[%u]: %i", file, line, status);
 #endif
        fflush(stderr);
 
@@ -213,7 +213,7 @@ void NEVER_RETURNS _fr_exit(char const *file, int line, int status)
 void NEVER_RETURNS _fr_exit_now(char const *file, int line, int status)
 {
 #ifndef NDEBUG
-       fr_perror("_EXIT CALLED %s[%u]: %i", file, line, status);
+       fr_perror("_EXIT CALLED %s[%u]: %i", file, line, status);
 #endif
        fflush(stderr);
 
index 77bd237..9cc4508 100644 (file)
@@ -1002,6 +1002,9 @@ int read_mainconfig(int reload)
        rad_assert(cs_cache == NULL);
        cs_cache = cc;
 
+       /* Clear any unprocessed configuration errors */
+       (void) fr_strerror();
+
        return 0;
 }
 
index c2a1561..f104799 100644 (file)
@@ -121,8 +121,8 @@ int main(int argc, char *argv[])
        {
                WSADATA wsaData;
                if (WSAStartup(MAKEWORD(2, 0), &wsaData)) {
-                 fprintf(stderr, "%s: Unable to initialize socket library.\n", progname);
-                       return 1;
+                       fprintf(stderr, "%s: Unable to initialize socket library.\n", progname);
+                       exit(EXIT_FAILURE);
                }
        }
 #endif