Skip to content

Commit 2ce9f1e

Browse files
committed
boot_serial: Fix incorrect format specifier for off_t
The `BOOT_LOG_INF` function, which uses the format specifiers defined by the C standard, was incorrectly printing a variable with the type of `off_t` using the `%x` format specifier, which is intended to be used with the `int` type. The `off_t` type, specified by the POSIX standard, is not guaranteed to be `int`, and it may be defined as `long` or `long long` depending on the toolchain and the target architecture. This commit updates the print routine such that it casts the arguments of the `off_t` type to `intmax_t` and prints them out using the corresponding `%jx` format specifier. Signed-off-by: Stephanos Ioannidis <[email protected]>
1 parent 78517db commit 2ce9f1e

File tree

1 file changed

+2
-1
lines changed

1 file changed

+2
-1
lines changed

boot/boot_serial/src/boot_serial.c

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -301,7 +301,8 @@ static off_t erase_range(const struct flash_area *fap, off_t start, off_t end)
301301
}
302302

303303
size = flash_sector_get_off(&sect) + flash_sector_get_size(&sect) - start;
304-
BOOT_LOG_INF("Erasing range 0x%x:0x%x", start, start + size - 1);
304+
BOOT_LOG_INF("Erasing range 0x%jx:0x%jx", (intmax_t)start,
305+
(intmax_t)(start + size - 1));
305306

306307
rc = flash_area_erase(fap, start, size);
307308
if (rc != 0) {

0 commit comments

Comments
 (0)