weston-log: Fix warning on 32-bit architectures

On 32-bit ARM, tv_usec is of type long long int. Cast to int64_t and
use PRId64 from inttypes.h instead of %ld/%li to silence these format
warnings:

  .../libweston/weston-log.c: In function 'weston_log_scope_timestamp':
  .../libweston/weston-log.c:961:22: warning: format '%ld' expects argument of type 'long int', but argument 5 has type '__suseconds64_t' {aka 'long long int'} [-Wformat=]
  .../libweston/weston-log.c: In function 'weston_log_timestamp':
  .../libweston/weston-log.c:1015:27: warning: format '%li' expects argument of type 'long int', but argument 6 has type '__suseconds64_t' {aka 'long long int'} [-Wformat=]

Signed-off-by: Philipp Zabel <p.zabel@pengutronix.de>
This commit is contained in:
Philipp Zabel 2025-10-09 12:34:51 +02:00 committed by Daniel Stone
parent de3a3fca1b
commit 200f4cf461

View file

@ -34,6 +34,7 @@
#include "weston-debug-server-protocol.h"
#include <assert.h>
#include <inttypes.h>
#include <unistd.h>
#include <stdarg.h>
#include <string.h>
@ -958,8 +959,8 @@ weston_log_scope_timestamp(struct weston_log_scope *scope,
"%Y-%m-%d %H:%M:%S", bdt);
if (ret > 0) {
snprintf(buf, len, "[%s.%03ld][%s]", string,
tv.tv_usec / 1000,
snprintf(buf, len, "[%s.%03" PRId64 "][%s]", string,
(int64_t)(tv.tv_usec / 1000),
(scope) ? scope->name : "no scope");
} else {
snprintf(buf, len, "[?][%s]",
@ -1012,8 +1013,8 @@ weston_log_timestamp(char *buf, size_t len, int *cached_tm_mday)
strftime(timestr, sizeof(timestr), "%H:%M:%S", brokendown_time);
/* if datestr is empty it prints only timestr*/
snprintf(buf, len, "%s[%s.%03li]", datestr,
timestr, (tv.tv_usec / 1000));
snprintf(buf, len, "%s[%s.%03" PRId64 "]", datestr,
timestr, (int64_t)(tv.tv_usec / 1000));
return buf;
}