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 <neil@xuku.com>
This commit is contained in:
Neil Berkman 2026-03-08 17:22:48 -07:00 committed by Michal Lenc
parent 2964c8cc3d
commit 8579459bb0
3 changed files with 10 additions and 7 deletions

View file

@ -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

View file

@ -28,6 +28,7 @@
#include <stdio.h>
#include <errno.h>
#include <inttypes.h>
#include <string.h>
#include <stddef.h>
#include <fcntl.h>
@ -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;
}

View file

@ -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;