mirror of
https://github.com/clearml/dropbear
synced 2025-01-31 02:46:58 +00:00
Fix building with DEBUG_TRACE = 0
Also try a less repetitive way of specifying macros
This commit is contained in:
parent
0d4ab4fc09
commit
9411bc21a8
31
dbutil.c
31
dbutil.c
@ -187,7 +187,7 @@ static double time_since_start()
|
||||
|
||||
static void dropbear_tracelevel(int level, const char *format, va_list param)
|
||||
{
|
||||
if (debug_trace==0 || debug_trace < level) {
|
||||
if (debug_trace == 0 || debug_trace < level) {
|
||||
return;
|
||||
}
|
||||
|
||||
@ -195,55 +195,48 @@ static void dropbear_tracelevel(int level, const char *format, va_list param)
|
||||
vfprintf(stderr, format, param);
|
||||
fprintf(stderr, "\n");
|
||||
}
|
||||
#if (DEBUG_TRACE>=1)
|
||||
void dropbear_trace1(const char* format, ...) {
|
||||
va_list param;
|
||||
|
||||
va_start(param, format);
|
||||
dropbear_tracelevel(1,format, param);
|
||||
dropbear_tracelevel(1, format, param);
|
||||
va_end(param);
|
||||
}
|
||||
#if (DEBUG_TRACE>1)
|
||||
#endif
|
||||
#if (DEBUG_TRACE>=2)
|
||||
void dropbear_trace2(const char* format, ...) {
|
||||
va_list param;
|
||||
|
||||
va_start(param, format);
|
||||
dropbear_tracelevel(2,format,param);
|
||||
dropbear_tracelevel(2, format, param);
|
||||
va_end(param);
|
||||
}
|
||||
#endif
|
||||
#if (DEBUG_TRACE>2)
|
||||
#if (DEBUG_TRACE>=3)
|
||||
void dropbear_trace3(const char* format, ...) {
|
||||
va_list param;
|
||||
|
||||
va_start(param, format);
|
||||
dropbear_tracelevel(3,format,param);
|
||||
dropbear_tracelevel(3, format, param);
|
||||
va_end(param);
|
||||
}
|
||||
#endif
|
||||
#if (DEBUG_TRACE>3)
|
||||
#if (DEBUG_TRACE>=4)
|
||||
void dropbear_trace4(const char* format, ...) {
|
||||
va_list param;
|
||||
|
||||
va_start(param, format);
|
||||
dropbear_tracelevel(4,format,param);
|
||||
dropbear_tracelevel(4, format, param);
|
||||
va_end(param);
|
||||
}
|
||||
#endif
|
||||
#if (DEBUG_TRACE>4)
|
||||
#if (DEBUG_TRACE>=5)
|
||||
void dropbear_trace5(const char* format, ...) {
|
||||
static int trace_env = -1;
|
||||
va_list param;
|
||||
|
||||
if (trace_env == -1) {
|
||||
trace_env = getenv("DROPBEAR_TRACE2") ? 1 : 0;
|
||||
}
|
||||
|
||||
if (!(debug_trace && trace_env)) {
|
||||
return;
|
||||
}
|
||||
|
||||
va_start(param, format);
|
||||
dropbear_tracelevel(5,format,param);
|
||||
dropbear_tracelevel(5, format, param);
|
||||
va_end(param);
|
||||
}
|
||||
#endif
|
||||
|
45
debug.h
45
debug.h
@ -53,37 +53,34 @@
|
||||
extern int debug_trace;
|
||||
#endif
|
||||
|
||||
/* you don't need to touch this block */
|
||||
/* enable debug trace levels */
|
||||
#if (DEBUG_TRACE==1)
|
||||
#define DEBUG1(X) dropbear_trace1 X;
|
||||
/* Enable debug trace levels.
|
||||
We can't use __VA_ARGS_ here because Dropbear supports
|
||||
old ~C89 compilers */
|
||||
/* Default is to discard output ... */
|
||||
#define DEBUG1(X)
|
||||
#define DEBUG2(X)
|
||||
#define DEBUG3(X)
|
||||
#define TRACE(X)
|
||||
#define TRACE2(X)
|
||||
#elif (DEBUG_TRACE==2)
|
||||
#define DEBUG1(X) dropbear_trace1 X;
|
||||
#define DEBUG2(X) dropbear_trace2 X;
|
||||
#define DEBUG3(X)
|
||||
#define TRACE(X)
|
||||
#define TRACE2(X)
|
||||
#elif (DEBUG_TRACE==3)
|
||||
/* ... unless DEBUG_TRACE is high enough */
|
||||
#if (DEBUG_TRACE>=1)
|
||||
#undef DEBUG1
|
||||
#define DEBUG1(X) dropbear_trace1 X;
|
||||
#endif
|
||||
#if (DEBUG_TRACE>=2)
|
||||
#undef DEBUG2
|
||||
#define DEBUG2(X) dropbear_trace2 X;
|
||||
#endif
|
||||
#if (DEBUG_TRACE>=3)
|
||||
#undef DEBUG3
|
||||
#define DEBUG3(X) dropbear_trace3 X;
|
||||
#define TRACE(X)
|
||||
#define TRACE2(X)
|
||||
#elif (DEBUG_TRACE==4)
|
||||
#define DEBUG1(X) dropbear_trace1 X;
|
||||
#define DEBUG2(X) dropbear_trace2 X;
|
||||
#define DEBUG3(X) dropbear_trace3 X;
|
||||
#define TRACE(X) dropbear_trace4 X;
|
||||
#define TRACE2(X)
|
||||
#elif (DEBUG_TRACE==5)
|
||||
#define DEBUG1(X) dropbear_trace1 X;
|
||||
#define DEBUG2(X) dropbear_trace2 X;
|
||||
#define DEBUG3(X) dropbear_trace3 X;
|
||||
#define TRACE(X) dropbear_trace4 X;
|
||||
#endif
|
||||
#if (DEBUG_TRACE>=4)
|
||||
#undef TRACE
|
||||
#define TRACE(X) dropbear_trace4 X;
|
||||
#endif
|
||||
#if (DEBUG_TRACE>=5)
|
||||
#undef TRACE2
|
||||
#define TRACE2(X) dropbear_trace5 X;
|
||||
#endif
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user