Skip to content

Commit d1c0eb1

Browse files
de-nordiccfriedt
authored andcommitted
samples: littlefs: Fix printk messages for native_posix_64
The formatting options, passed to the printk, caused warnings when compiling for native_posix_64. Signed-off-by: Dominik Ermel <[email protected]>
1 parent 8e97055 commit d1c0eb1

File tree

1 file changed

+14
-4
lines changed
  • samples/subsys/fs/littlefs/src

1 file changed

+14
-4
lines changed

samples/subsys/fs/littlefs/src/main.c

Lines changed: 14 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,16 @@
1414
#include <fs/littlefs.h>
1515
#include <storage/flash_map.h>
1616

17+
/*
18+
* FIXME: The Zephyr always overrides uintptr_t as long int, which causes type size mismatch with
19+
* 32bit tools that may define PRIuPTR as "u".
20+
* See: include/toolchain/zephyr_stdint.h.
21+
* The UINTPTR_T_CAST should be replaced with cast to uintptr_t when this thing gets fixed.
22+
*/
23+
#undef PRIuPTR
24+
#define PRIuPTR "lu"
25+
#define UINTPTR_T_CAST(t) ((unsigned long)(t))
26+
1727
/* Matches LFS_NAME_MAX */
1828
#define MAX_PATH_LEN 255
1929

@@ -73,8 +83,8 @@ void main(void)
7383
!(FSTAB_ENTRY_DT_MOUNT_FLAGS(PARTITION_NODE) & FS_MOUNT_FLAG_AUTOMOUNT)
7484
rc = fs_mount(mp);
7585
if (rc < 0) {
76-
printk("FAIL: mount id %u at %s: %d\n",
77-
(unsigned int)mp->storage_dev, mp->mnt_point,
86+
printk("FAIL: mount id %" PRIuPTR " at %s: %d\n",
87+
UINTPTR_T_CAST(mp->storage_dev), mp->mnt_point,
7888
rc);
7989
return;
8090
}
@@ -100,7 +110,7 @@ void main(void)
100110
rc = fs_stat(fname, &dirent);
101111
printk("%s stat: %d\n", fname, rc);
102112
if (rc >= 0) {
103-
printk("\tfn '%s' siz %u\n", dirent.name, dirent.size);
113+
printk("\tfn '%s' size %zu\n", dirent.name, dirent.size);
104114
}
105115

106116
struct fs_file_t file;
@@ -149,7 +159,7 @@ void main(void)
149159
printk("End of files\n");
150160
break;
151161
}
152-
printk(" %c %u %s\n",
162+
printk(" %c %zu %s\n",
153163
(ent.type == FS_DIR_ENTRY_FILE) ? 'F' : 'D',
154164
ent.size,
155165
ent.name);

0 commit comments

Comments
 (0)