libdvbsub/Debug.cpp: Fix format warnings for __suseconds64_t in Debug.cpp

- Added <inttypes.h> for correct format specifiers.
- Used PRIdMAX for formatting __suseconds64_t in print function.
- Updated sprintf call to handle __suseconds64_t correctly.
This commit is contained in:
2024-07-04 16:08:36 +02:00
parent ed29984d9f
commit 7308e50b77

View File

@@ -1,3 +1,4 @@
#include <inttypes.h>
#include <sys/time.h> #include <sys/time.h>
#include <time.h> #include <time.h>
#include <cstdio> #include <cstdio>
@@ -42,13 +43,11 @@ void Debug::print(int level, const char *fmt, ...)
if (level < level_) { if (level < level_) {
gettimeofday(&tv, NULL); gettimeofday(&tv, NULL);
strftime(tbuf, sizeof(tbuf), "%H:%M:%S", localtime(&tv.tv_sec)); strftime(tbuf, sizeof(tbuf), "%H:%M:%S", localtime(&tv.tv_sec));
len = sprintf(buf, "[ %s.%03ld ] ", tbuf, tv.tv_usec / 1000); len = sprintf(buf, "[ %s.%03" PRIdMAX " ] ", tbuf, static_cast<intmax_t>(tv.tv_usec / 1000));
va_start(argp, fmt); va_start(argp, fmt);
//vfprintf(fp_, fmt, argp); vsnprintf(&buf[len], sizeof(buf) - len, fmt, argp);
vsnprintf (&buf[len], 512, fmt, argp);
va_end(argp); va_end(argp);
fprintf(fp_, "%s", buf); fprintf(fp_, "%s", buf);
} }
} }