Coverage Report

Created: 2026-03-21 06:45

next uncovered line (L), next uncovered region (R), next uncovered branch (B)
/src/selinux/libsepol/src/debug.c
Line
Count
Source
1
#include <stdarg.h>
2
#include <stdlib.h>
3
#include <stdio.h>
4
#include "handle.h"
5
#include "debug.h"
6
7
/* Deprecated */
8
struct sepol_handle sepol_compat_handle = {
9
  .msg_callback = sepol_msg_default_handler,
10
  .msg_callback_arg = NULL,
11
};
12
13
void sepol_debug(int on)
14
11.9k
{
15
11.9k
  sepol_compat_handle.msg_callback = (on) ?
16
11.9k
      sepol_msg_default_handler : NULL;
17
11.9k
}
18
19
/* End deprecated */
20
21
int sepol_msg_get_level(sepol_handle_t * handle)
22
0
{
23
0
  return handle->msg_level;
24
0
}
25
26
27
const char *sepol_msg_get_channel(sepol_handle_t * handle)
28
0
{
29
0
  return handle->msg_channel;
30
0
}
31
32
33
const char *sepol_msg_get_fname(sepol_handle_t * handle)
34
0
{
35
0
  return handle->msg_fname;
36
0
}
37
38
#ifdef __GNUC__
39
    __attribute__ ((format(printf, 3, 4)))
40
#endif
41
void sepol_msg_default_handler(void *varg __attribute__ ((unused)),
42
              sepol_handle_t * handle,
43
              const char *fmt, ...)
44
0
{
45
46
0
  FILE *stream = NULL;
47
0
  va_list ap;
48
49
0
  switch (sepol_msg_get_level(handle)) {
50
51
0
  case SEPOL_MSG_ERR:
52
0
  case SEPOL_MSG_WARN:
53
0
    stream = stderr;
54
0
    break;
55
0
  case SEPOL_MSG_INFO:
56
0
  default:
57
0
    stream = stdout;
58
0
    break;
59
0
  }
60
61
0
  fprintf(stream, "%s.%s: ",
62
0
    sepol_msg_get_channel(handle), sepol_msg_get_fname(handle));
63
64
0
  va_start(ap, fmt);
65
0
  vfprintf(stream, fmt, ap);
66
0
  va_end(ap);
67
68
0
  fprintf(stream, "\n");
69
0
}
70
71
extern void sepol_msg_set_callback(sepol_handle_t * handle,
72
#ifdef __GNUC__
73
           __attribute__ ((format(printf, 3, 4)))
74
#endif
75
           void (*msg_callback) (void *varg,
76
               sepol_handle_t *
77
               handle,
78
               const char *fmt, ...),
79
           void *msg_callback_arg)
80
0
{
81
82
0
  handle->msg_callback = msg_callback;
83
0
  handle->msg_callback_arg = msg_callback_arg;
84
0
}