Skip to content

Commit 578cb13

Browse files
de-nordiccarlescufi
authored andcommitted
mgmt/mcumgr/lib: Make version string work with CONFIG_NEWLIB_LIBC
By default the newlib does not compile with %hhu processing, to avoid turning on additional options for newlib compilation this commit changes formatting string to use %hu instead. The commit fixes problem with malformed version string being returned, by smp_svr, when CONFIG_NEWLIB_LIBC=y is set together with CONFIG_NEWLIB_LIBC_NANO=y. Fixes #45261 Signed-off-by: Dominik Ermel <[email protected]>
1 parent 0c051d0 commit 578cb13

File tree

1 file changed

+3
-2
lines changed

1 file changed

+3
-2
lines changed

subsys/mgmt/mcumgr/lib/cmd/img_mgmt/src/img_mgmt_util.c

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -16,8 +16,9 @@ img_mgmt_ver_str(const struct image_version *ver, char *dst)
1616
int rc = 0;
1717
int rc1 = 0;
1818

19-
rc = snprintf(dst, IMG_MGMT_VER_MAX_STR_LEN, "%hhu.%hhu.%hu",
20-
ver->iv_major, ver->iv_minor, ver->iv_revision);
19+
rc = snprintf(dst, IMG_MGMT_VER_MAX_STR_LEN, "%hu.%hu.%hu",
20+
(uint16_t)ver->iv_major, (uint16_t)ver->iv_minor,
21+
ver->iv_revision);
2122

2223
if (rc >= 0 && ver->iv_build_num != 0) {
2324
rc1 = snprintf(&dst[rc], IMG_MGMT_VER_MAX_STR_LEN - rc, ".%u",

0 commit comments

Comments
 (0)