isobusfs: fix printf format specifiers in log messages

Several log messages used format specifiers which did not match the
types of the provided arguments (e.g. %d or %i for size_t/ssize_t,
%ld for int64_t/time_t and size_t for the '.*' precision). On 64 bit
hosts (and for int64_t/time_t on 32 bit hosts) this leads to wrong
output or undefined behaviour when the log level is enabled.

Additionally the seek response position was compared to the requested
offset without le32toh() conversion which fails on big endian hosts.

Fix the format specifiers and add the missing le32toh() conversion.

Assisted-by: Claude:claude-opus-5-5
Signed-off-by: Oliver Hartkopp <socketcan@hartkopp.net>
This commit is contained in:
Oliver Hartkopp
2026-10-14 19:25:06 +02:00
parent 0f55228325
commit 8355b57133
8 changed files with 16 additions and 15 deletions
+4 -3
View File
@@ -2,6 +2,7 @@
// SPDX-FileCopyrightText: 2023 Oleksij Rempel <linux@rempel-privat.de>
#include <errno.h>
#include <inttypes.h>
#include <string.h>
#include <unistd.h>
@@ -95,7 +96,7 @@ int isobusfs_cli_ccm_send(struct isobusfs_priv *priv)
}
if (time_diff < -ISOBUSFS_CM_F_FS_STATUS_RATE_JITTER) {
pr_warn("too late to send next fs status message: %ld ms",
pr_warn("too late to send next fs status message: %" PRId64 " ms",
time_diff);
}
@@ -152,7 +153,7 @@ static int isobusfs_cli_rx_fs_status(struct isobusfs_priv *priv,
int ret = 0;
if (msg->len != sizeof(*fs_status)) {
pr_warn("wrong message length: %d", msg->len);
pr_warn("wrong message length: %zd", msg->len);
return -EINVAL;
}
@@ -178,7 +179,7 @@ static int isobusfs_cli_rx_fs_property_res(struct isobusfs_priv *priv,
}
if (msg->len != sizeof(*fs_prop)) {
pr_warn("wrong message length: %d", msg->len);
pr_warn("wrong message length: %zd", msg->len);
return -EINVAL;
}