Skip to content

Commit 7f20778

Browse files
authored
Merge pull request libgit2#5311 from pks-t/pks/clar-trace-warning
tests: fix compiler warning if tracing is disabled
2 parents 6103842 + 1d470a7 commit 7f20778

File tree

1 file changed

+16
-10
lines changed

1 file changed

+16
-10
lines changed

tests/clar_libgit2_trace.c

Lines changed: 16 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,11 @@
1-
#include "clar_libgit2.h"
21
#include "clar_libgit2_trace.h"
2+
3+
#if defined(GIT_TRACE)
4+
5+
#include "clar_libgit2.h"
36
#include "clar_libgit2_timer.h"
47
#include "trace.h"
58

6-
79
struct method {
810
const char *name;
911
void (*git_trace_cb)(git_trace_level_t level, const char *msg);
@@ -32,7 +34,6 @@ static const char *message_prefix(git_trace_level_t level)
3234
}
3335
}
3436

35-
#if defined(GIT_TRACE)
3637
static void _git_trace_cb__printf(git_trace_level_t level, const char *msg)
3738
{
3839
printf("%s%s\n", message_prefix(level), msg);
@@ -225,15 +226,11 @@ void _cl_trace_cb__event_handler(
225226
}
226227
}
227228

228-
#endif /*GIT_TRACE*/
229-
230229
/**
231230
* Setup/Enable git_trace() based upon settings user's environment.
232-
*
233231
*/
234232
void cl_global_trace_register(void)
235233
{
236-
#if defined(GIT_TRACE)
237234
if (!s_trace_loaded)
238235
_load_trace_params();
239236

@@ -246,7 +243,6 @@ void cl_global_trace_register(void)
246243

247244
git_trace_set(s_trace_level, s_trace_method->git_trace_cb);
248245
cl_trace_register(_cl_trace_cb__event_handler, NULL);
249-
#endif
250246
}
251247

252248
/**
@@ -258,7 +254,6 @@ void cl_global_trace_register(void)
258254
*/
259255
void cl_global_trace_disable(void)
260256
{
261-
#if defined(GIT_TRACE)
262257
cl_trace_register(NULL, NULL);
263258
git_trace_set(GIT_TRACE_NONE, NULL);
264259
if (s_trace_method && s_trace_method->close)
@@ -268,5 +263,16 @@ void cl_global_trace_disable(void)
268263
* since we only want to hit the environment variables
269264
* once.
270265
*/
271-
#endif
272266
}
267+
268+
#else /* GIT_TRACE */
269+
270+
void cl_global_trace_register(void)
271+
{
272+
}
273+
274+
void cl_global_trace_disable(void)
275+
{
276+
}
277+
278+
#endif /* GIT_TRACE*/

0 commit comments

Comments
 (0)