From 3a71d5a714f60d07990327f43155233e0fcd1fa7 Mon Sep 17 00:00:00 2001 From: Chen Wen Date: Sun, 28 Mar 2021 21:22:05 +0800 Subject: [PATCH] fs/spiffs: Fix syslog formats --- fs/spiffs/src/spiffs_core.c | 35 +++++++++++++++++++---------------- fs/spiffs/src/spiffs_gc.c | 17 ++++++++++------- fs/spiffs/src/spiffs_vfs.c | 5 +++-- fs/spiffs/src/spiffs_volume.c | 6 ++++-- 4 files changed, 36 insertions(+), 27 deletions(-) diff --git a/fs/spiffs/src/spiffs_core.c b/fs/spiffs/src/spiffs_core.c index be62d4bd97..35683e36eb 100644 --- a/fs/spiffs/src/spiffs_core.c +++ b/fs/spiffs/src/spiffs_core.c @@ -764,7 +764,7 @@ int spiffs_erase_block(FAR struct spiffs_s *fs, int16_t blkndx) while (size > 0) { - finfo("erase %08lx:%d\n", + finfo("erase %08lx:%" PRIu32 "\n", (unsigned long)addr, SPIFFS_GEO_EBLOCK_SIZE(fs)); spiffs_mtd_erase(fs, addr, SPIFFS_GEO_EBLOCK_SIZE(fs)); @@ -1542,7 +1542,7 @@ void spiffs_fobj_event(FAR struct spiffs_s *fs, FAR struct spiffs_file_s *next; int16_t objid = objid_raw & ~SPIFFS_OBJID_NDXFLAG; - finfo("Event=%s objid=%04x spndx=%04x npgndx=%04x nsz=%d\n", + finfo("Event=%s objid=%04x spndx=%04x npgndx=%04x nsz=%" PRIu32 "\n", evname[MIN(ev, 5)], objid_raw, spndx, new_pgndx, new_size); /* Update index caches in all file descriptors */ @@ -1570,8 +1570,8 @@ void spiffs_fobj_event(FAR struct spiffs_s *fs, if (ev != SPIFFS_EV_NDXDEL) { - finfo("Setting objid=%d (offset=%d) objhdr_pgndx " - "to %04x size=%d\n", + finfo("Setting objid=%d (offset=%" PRIu32 ") objhdr_pgndx " + "to %04x size=%" PRIu32 "\n", fobj->objid, fobj->offset, new_pgndx, new_size); fobj->objhdr_pgndx = new_pgndx; @@ -2008,7 +2008,7 @@ ssize_t spiffs_fobj_append(FAR struct spiffs_s *fs, } finfo("objid=%04x found object index at " - "page=%04x [fobj size=%d]\n", + "page=%04x [fobj size=%" PRIu32 "]\n", fobj->objid, pgndx, fobj->size); ret = spiffs_cache_read(fs, @@ -2924,8 +2924,9 @@ int spiffs_fobj_truncate(FAR struct spiffs_s *fs, if (!remove_full) { - finfo("Update objndx hdr page %04x:%04x to size=%d\n", - fobj->objhdr_pgndx, prev_objndx_spndx, cur_size); + finfo("Update objndx hdr page %04x:%04x to" + "size=%" PRIu32 "\n", + fobj->objhdr_pgndx, prev_objndx_spndx, cur_size); ret = spiffs_fobj_update_ndxhdr(fs, fobj, fobj->objid, @@ -3064,8 +3065,9 @@ int spiffs_fobj_truncate(FAR struct spiffs_s *fs, fobj->size = cur_size; fobj->offset = cur_size; - finfo("Delete data page %04x for data spndx=%04x, cur_size=%d\n", - data_pgndx, data_spndx, cur_size); + finfo("Delete data page %04x for data spndx=%04x," + "cur_size=%" PRIu32 "\n", + data_pgndx, data_spndx, cur_size); } else { @@ -3078,8 +3080,8 @@ int spiffs_fobj_truncate(FAR struct spiffs_s *fs, bytes_to_remove = SPIFFS_DATA_PAGE_SIZE(fs) - (new_size % SPIFFS_DATA_PAGE_SIZE(fs)); - finfo("Delete %d bytes from data page=%04x for data spndx=%04x, " - "cur_size=%d\n", + finfo("Delete %" PRIu32 " bytes from data page=%04x for " + "data spndx=%04x, cur_size=%" PRIu32 "\n", bytes_to_remove, data_pgndx, data_spndx, cur_size); ret = spiffs_page_data_check(fs, fobj, data_pgndx, data_spndx); @@ -3430,7 +3432,7 @@ ssize_t spiffs_object_read(FAR struct spiffs_s *fs, len_to_read = MIN(len_to_read, fobj->size); - finfo("Read offset=%d rd=%d data spndx=%d is " + finfo("Read offset=%" PRIu32 " rd=%" PRIu32 " data spndx=%d is " "data_pgndx=%d addr=%" PRIu32 "\n", cur_offset, len_to_read, data_spndx, data_pgndx, (uint32_t)(SPIFFS_PAGE_TO_PADDR(fs, data_pgndx) + @@ -3601,8 +3603,8 @@ int spiffs_objlu_find_free_objid(FAR struct spiffs_s *fs, int16_t *objid, return -ENOSPC; } - finfo("COMP select index=%d min_count=%d min=%04x max=%04x " - "compact:%d\n", + finfo("COMP select index=%" PRIu32 " min_count=%d min=%04x " + "max=%04x compact:%" PRIu32 "\n", min_i, min_count, state.min_objid, state.max_objid, state.compaction); @@ -3617,7 +3619,8 @@ int spiffs_objlu_find_free_objid(FAR struct spiffs_s *fs, int16_t *objid, } else { - finfo("COMP SEL chunk=%d min=%04x -> %04x\n", + finfo("COMP SEL chunk=%" PRIu32 " min=%04x " + "-> %04" PRIx32 "\n", state.compaction, state.min_objid, state.min_objid + min_i * state.compaction); @@ -3647,7 +3650,7 @@ int spiffs_objlu_find_free_objid(FAR struct spiffs_s *fs, int16_t *objid, state.compaction = (state.max_objid - state.min_objid) / ((SPIFFS_GEO_PAGE_SIZE(fs) / sizeof(uint8_t))); - finfo("COMP min=%04x max=%04x compact=%d\n", + finfo("COMP min=%04x max=%04x compact=%" PRIu32 "\n", state.min_objid, state.max_objid, state.compaction); memset(fs->work, 0, SPIFFS_GEO_PAGE_SIZE(fs)); diff --git a/fs/spiffs/src/spiffs_gc.c b/fs/spiffs/src/spiffs_gc.c index 166dda24d9..628437c77c 100644 --- a/fs/spiffs/src/spiffs_gc.c +++ b/fs/spiffs/src/spiffs_gc.c @@ -49,6 +49,7 @@ #include #include #include +#include #include "spiffs.h" #include "spiffs_core.h" @@ -205,7 +206,7 @@ static int spiffs_gc_epage_stats(FAR struct spiffs_s *fs, int16_t blkndx) obj_lookup_page++; } - spiffs_gcinfo("Wipe pallo=%d pdele=%d\n", allo, dele); + spiffs_gcinfo("Wipe pallo=%" PRIu32 " pdele=%" PRIu32 "\n", allo, dele); fs->alloc_pages -= allo; fs->deleted_pages -= dele; @@ -372,7 +373,7 @@ static int spiffs_gc_find_candidate(FAR struct spiffs_s *fs, candndx = 0; - spiffs_gcinfo("blkndx=%04x del=%d use=%d score=%d\n", + spiffs_gcinfo("blkndx=%04x del=%d use=%d score=%" PRIu32 "\n", cur_block, deleted_pages_in_block, used_pages_in_block, score); @@ -1169,7 +1170,8 @@ int spiffs_gc_check(FAR struct spiffs_s *fs, off_t len) if ((int32_t)needed_pages > (int32_t)(free_pages + fs->deleted_pages)) { - spiffs_gcinfo("Full freeblk=%d needed=%d free=%d dele=%d\n", + spiffs_gcinfo("Full freeblk=%" PRIu32 " needed=%" PRIu32 " " + "free=%" PRIu32 " dele=%" PRIu32 "\n", fs->free_blocks, needed_pages, free_pages, fs->deleted_pages); return -ENOSPC; @@ -1182,8 +1184,9 @@ int spiffs_gc_check(FAR struct spiffs_s *fs, off_t len) int16_t cand; int32_t prev_free_pages = free_pages; - spiffs_gcinfo("#%d: run gc free_blocks=%d pfree=%d pallo=%d pdele=%d " - "[%d] len=%d of %d\n", + spiffs_gcinfo("#%d: run gc free_blocks=%" PRIu32 " pfree=" + "%" PRIu32 " pallo=%" PRIu32 " pdele=%" PRIu32 "" + " [%" PRIu32 "] len=%" PRIu32 " of %" PRIu32 "\n", tries, fs->free_blocks, free_pages, fs->alloc_pages, fs->deleted_pages, (free_pages + fs->alloc_pages + fs->deleted_pages), @@ -1264,8 +1267,8 @@ int spiffs_gc_check(FAR struct spiffs_s *fs, off_t len) ret = -ENOSPC; } - spiffs_gcinfo("Finished, %d dirty, blocks, %d free, %d pages free, " - "%d tries, ret=%d\n", + spiffs_gcinfo("Finished, %" PRIu32 " dirty, blocks, %" PRIu32 " " + "free, %" PRIu32 " pages free, %d tries, ret=%d\n", fs->alloc_pages + fs->deleted_pages, fs->free_blocks, free_pages, tries, ret); diff --git a/fs/spiffs/src/spiffs_vfs.c b/fs/spiffs/src/spiffs_vfs.c index 85017e550b..f19dd4c0ca 100644 --- a/fs/spiffs/src/spiffs_vfs.c +++ b/fs/spiffs/src/spiffs_vfs.c @@ -55,6 +55,7 @@ #include #include #include +#include #include #include @@ -726,7 +727,7 @@ static ssize_t spiffs_write(FAR struct file *filep, FAR const char *buffer, */ spiffs_cacheinfo("Cache page=%d for fobj ID=%d " - "Boundary violation, offset=%d size=%d\n", + "Boundary violation, offset=%" PRIu32 " size=%d\n", fobj->cache_page->cpndx, fobj->objid, fobj->cache_page->offset, fobj->cache_page->size); @@ -815,7 +816,7 @@ static ssize_t spiffs_write(FAR struct file *filep, FAR const char *buffer, /* Write back cache first */ spiffs_cacheinfo("Cache page=%d for fobj ID=%d " - "Boundary violation, offset=%d size=%d\n", + "Boundary violation, offset=%" PRIu32 " size=%d\n", fobj->cache_page->cpndx, fobj->objid, fobj->cache_page->offset, fobj->cache_page->size); diff --git a/fs/spiffs/src/spiffs_volume.c b/fs/spiffs/src/spiffs_volume.c index 5e7cb77fdb..2f2ca7d30f 100644 --- a/fs/spiffs/src/spiffs_volume.c +++ b/fs/spiffs/src/spiffs_volume.c @@ -49,6 +49,7 @@ #include #include #include +#include #include @@ -245,7 +246,8 @@ ssize_t spiffs_fobj_flush(FAR struct spiffs_s *fs, if (fobj->cache_page) { - spiffs_cacheinfo("Flushing cache page %d for objid=%d offset=%d size=%d\n", + spiffs_cacheinfo("Flushing cache page %d for objid=%d " + "offset=%" PRIu32 " size=%d\n", fobj->cache_page->cpndx, fobj->objid, fobj->cache_page->offset, fobj->cache_page->size); @@ -253,7 +255,7 @@ ssize_t spiffs_fobj_flush(FAR struct spiffs_s *fs, spiffs_fobj_write(fs, fobj, spiffs_get_cache_page(fs, spiffs_get_cache(fs), fobj->cache_page->cpndx), - fobj->cache_page->offset, fobj->cache_page->size); + fobj->cache_page->offset, fobj->cache_page->size); if (nwritten < 0) { ferr("ERROR: spiffs_fobj_write failed %d\n", (int)nwritten);