1010/* logs of this severity or higher are flushed immediately after write */
1111#define LOG_FLUSH_LEVEL LOG_WARNING
1212
13- static FILE * logf = NULL ; // NOLINT(cppcoreguidelines-avoid-non-const-global-variables)
13+ static FILE * logfile = NULL ; // NOLINT(cppcoreguidelines-avoid-non-const-global-variables)
1414static int loglevel = LOG_ERROR ; // NOLINT(cppcoreguidelines-avoid-non-const-global-variables)
1515static ev_timer logging_timer ; // NOLINT(cppcoreguidelines-avoid-non-const-global-variables)
1616
@@ -23,11 +23,11 @@ static const char * const SeverityStr[] = {
2323 "[F]"
2424};
2525
26- static void logging_timer_cb (struct ev_loop __attribute__((unused )) * loop ,
26+ void logging_timer_cb (struct ev_loop __attribute__((unused )) * loop ,
2727 ev_timer __attribute__((unused )) * w ,
2828 int __attribute__((unused )) revents ) {
29- if (logf ) {
30- (void )fflush (logf );
29+ if (logfile ) {
30+ (void )fflush (logfile );
3131 }
3232}
3333
@@ -47,18 +47,18 @@ void logging_flush_cleanup(struct ev_loop *loop) {
4747}
4848
4949void logging_init (int fd , int level ) {
50- if (logf ) {
51- (void )fclose (logf );
50+ if (logfile ) {
51+ (void )fclose (logfile );
5252 }
53- logf = fdopen (fd , "a" );
53+ logfile = fdopen (fd , "a" );
5454 loglevel = level ;
5555}
5656
5757void logging_cleanup (void ) {
58- if (logf ) {
59- (void )fclose (logf );
58+ if (logfile ) {
59+ (void )fclose (logfile );
6060 }
61- logf = NULL ;
61+ logfile = NULL ;
6262}
6363
6464int logging_debug_enabled (void ) {
@@ -73,24 +73,28 @@ void _log(const char *file, int line, int severity, const char *fmt, ...) {
7373 if (severity < 0 || severity >= LOG_MAX ) {
7474 FLOG ("Unknown log severity: %d\n" , severity );
7575 }
76- if (!logf ) {
77- logf = fdopen (STDOUT_FILENO , "w" );
76+ if (!logfile ) {
77+ logfile = fdopen (STDOUT_FILENO , "w" );
7878 }
7979
8080 struct timeval tv ;
8181 gettimeofday (& tv , NULL );
82- (void )fprintf (logf , "%s %8" PRIu64 ".%06" PRIu64 " %s:%d " , SeverityStr [severity ],
82+
83+ // NOLINTNEXTLINE(clang-analyzer-security.insecureAPI.DeprecatedOrUnsafeBufferHandling)
84+ (void )fprintf (logfile , "%s %8" PRIu64 ".%06" PRIu64 " %s:%d " , SeverityStr [severity ],
8385 (uint64_t )tv .tv_sec ,
8486 (uint64_t )tv .tv_usec , file , line );
8587
8688 va_list args ;
8789 va_start (args , fmt );
88- (void )vfprintf (logf , fmt , args );
90+ (void )vfprintf (logfile , fmt , args );
8991 va_end (args );
90- (void )fprintf (logf , "\n" );
92+
93+ // NOLINTNEXTLINE(clang-analyzer-security.insecureAPI.DeprecatedOrUnsafeBufferHandling)
94+ (void )fprintf (logfile , "\n" );
9195
9296 if (severity >= LOG_FLUSH_LEVEL ) {
93- (void )fflush (logf );
97+ (void )fflush (logfile );
9498 }
9599 if (severity == LOG_FATAL ) {
96100#ifdef DEBUG
0 commit comments