Skip to content

Commit 12b1bf5

Browse files
committed
Fix pthread_t format warning for fprintf
This change fixes the following compilation build warning: logger.c:117:47: warning: format '%li' expects argument of type 'long int', but argument 7 has type 'pthread_t' {aka 'struct __pthread *'} [-Wformat=] 117 | fprintf(log_fp, "%s %s %s[%d.%li]: %s\n", time_buf, hostname, | ~~^ | | | long int 118 | log_ident, getpid(), pthread_self(), message); | ~~~~~~~~~~~~~~ | | | pthread_t {aka struct __pthread *} logger.c:124:47: warning: format '%li' expects argument of type 'long int', but argument 7 has type 'pthread_t' {aka 'struct __pthread *'} [-Wformat=] 124 | fprintf(stderr, "%s %s %s[%d.%li]: %s\n", time_buf, hostname, | ~~^ | | | long int 125 | log_ident, getpid(), pthread_self(), message); | ~~~~~~~~~~~~~~ | | | pthread_t {aka struct __pthread *} Signed-off-by: Florian Eckert <[email protected]>
1 parent 7f45d2c commit 12b1bf5

File tree

1 file changed

+2
-2
lines changed

1 file changed

+2
-2
lines changed

logger.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -115,14 +115,14 @@ void logger(int severity, const char *fmt, ...)
115115
if (log_fp)
116116
{
117117
fprintf(log_fp, "%s %s %s[%d.%li]: %s\n", time_buf, hostname,
118-
log_ident, getpid(), pthread_self(), message);
118+
log_ident, getpid(), (unsigned long int) pthread_self(), message);
119119
fflush(log_fp);
120120
}
121121
else if (log_syslog_is_open)
122122
syslog(severity, "%s", message);
123123
else
124124
fprintf(stderr, "%s %s %s[%d.%li]: %s\n", time_buf, hostname,
125-
log_ident, getpid(), pthread_self(), message);
125+
log_ident, getpid(), (unsigned long int) pthread_self(), message);
126126
}
127127
va_end(args);
128128
}

0 commit comments

Comments
 (0)