From fc3ff2c065fc9d12cf73b2179ff4b4173e522661 Mon Sep 17 00:00:00 2001 From: Neil Berkman Date: Sun, 8 Mar 2026 17:22:48 -0700 Subject: [PATCH] boot/nxboot: fix Clang warnings for format and va_start Use PRIdOFF instead of %ld for off_t arguments in flash.c syslog calls, fixing -Wformat errors when off_t is not long. Change nxboot_progress parameter from enum progress_type_e to int to avoid undefined behavior from va_start on a parameter that undergoes default argument promotion (-Wvarargs). Signed-off-by: Neil Berkman --- boot/nxboot/include/nxboot.h | 2 +- boot/nxboot/loader/flash.c | 13 ++++++++----- boot/nxboot/nxboot_main.c | 2 +- 3 files changed, 10 insertions(+), 7 deletions(-) diff --git a/boot/nxboot/include/nxboot.h b/boot/nxboot/include/nxboot.h index 6821cc7030b..3d92e9753ad 100644 --- a/boot/nxboot/include/nxboot.h +++ b/boot/nxboot/include/nxboot.h @@ -169,7 +169,7 @@ enum progress_msg_e ****************************************************************************/ #ifdef CONFIG_NXBOOT_PROGRESS -void nxboot_progress(enum progress_type_e type, ...); +void nxboot_progress(int type, ...); #else #define nxboot_progress(type, ...) do {} while (0) #endif diff --git a/boot/nxboot/loader/flash.c b/boot/nxboot/loader/flash.c index 9142b25d9f0..f1a3595737f 100644 --- a/boot/nxboot/loader/flash.c +++ b/boot/nxboot/loader/flash.c @@ -28,6 +28,7 @@ #include #include +#include #include #include #include @@ -137,14 +138,15 @@ int flash_partition_write(int fd, const void *buf, size_t count, off_t off) pos = lseek(fd, off, SEEK_SET); if (pos != off) { - syslog(LOG_ERR, "Could not seek to %ld: %s\n", off, strerror(errno)); + syslog(LOG_ERR, "Could not seek to %" PRIdOFF ": %s\n", + off, strerror(errno)); return ERROR; } nbytes = write(fd, buf, count); if (nbytes != count) { - syslog(LOG_ERR, "Write to offset %ld failed %s\n", + syslog(LOG_ERR, "Write to offset %" PRIdOFF " failed %s\n", off, strerror(errno)); return ERROR; } @@ -195,15 +197,16 @@ int flash_partition_read(int fd, void *buf, size_t count, off_t off) pos = lseek(fd, off, SEEK_SET); if (pos != off) { - syslog(LOG_ERR, "Could not seek to %ld: %s\n", off, strerror(errno)); + syslog(LOG_ERR, "Could not seek to %" PRIdOFF ": %s\n", + off, strerror(errno)); return ERROR; } nbytes = read(fd, buf, count); if (nbytes != count) { - syslog(LOG_ERR, "Read from offset %ld failed %s\n", off, - strerror(errno)); + syslog(LOG_ERR, "Read from offset %" PRIdOFF " failed %s\n", + off, strerror(errno)); return ERROR; } diff --git a/boot/nxboot/nxboot_main.c b/boot/nxboot/nxboot_main.c index ddc2f228422..976b03b4cfe 100644 --- a/boot/nxboot/nxboot_main.c +++ b/boot/nxboot/nxboot_main.c @@ -124,7 +124,7 @@ static const char *progress_msgs[] = ****************************************************************************/ #ifdef CONFIG_NXBOOT_PROGRESS -void nxboot_progress(enum progress_type_e type, ...) +void nxboot_progress(int type, ...) { #ifdef CONFIG_NXBOOT_PRINTF_PROGRESS va_list arg;