fs/spiffs: Fix syslog formats

This commit is contained in:
Chen Wen 2021-03-28 21:22:05 +08:00 committed by Xiang Xiao
parent 91eb70b5ef
commit 3a71d5a714
4 changed files with 36 additions and 27 deletions

View File

@ -764,7 +764,7 @@ int spiffs_erase_block(FAR struct spiffs_s *fs, int16_t blkndx)
while (size > 0) while (size > 0)
{ {
finfo("erase %08lx:%d\n", finfo("erase %08lx:%" PRIu32 "\n",
(unsigned long)addr, SPIFFS_GEO_EBLOCK_SIZE(fs)); (unsigned long)addr, SPIFFS_GEO_EBLOCK_SIZE(fs));
spiffs_mtd_erase(fs, 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; FAR struct spiffs_file_s *next;
int16_t objid = objid_raw & ~SPIFFS_OBJID_NDXFLAG; 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); evname[MIN(ev, 5)], objid_raw, spndx, new_pgndx, new_size);
/* Update index caches in all file descriptors */ /* 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) if (ev != SPIFFS_EV_NDXDEL)
{ {
finfo("Setting objid=%d (offset=%d) objhdr_pgndx " finfo("Setting objid=%d (offset=%" PRIu32 ") objhdr_pgndx "
"to %04x size=%d\n", "to %04x size=%" PRIu32 "\n",
fobj->objid, fobj->offset, new_pgndx, new_size); fobj->objid, fobj->offset, new_pgndx, new_size);
fobj->objhdr_pgndx = new_pgndx; 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 " finfo("objid=%04x found object index at "
"page=%04x [fobj size=%d]\n", "page=%04x [fobj size=%" PRIu32 "]\n",
fobj->objid, pgndx, fobj->size); fobj->objid, pgndx, fobj->size);
ret = spiffs_cache_read(fs, ret = spiffs_cache_read(fs,
@ -2924,7 +2924,8 @@ int spiffs_fobj_truncate(FAR struct spiffs_s *fs,
if (!remove_full) if (!remove_full)
{ {
finfo("Update objndx hdr page %04x:%04x to size=%d\n", finfo("Update objndx hdr page %04x:%04x to"
"size=%" PRIu32 "\n",
fobj->objhdr_pgndx, prev_objndx_spndx, cur_size); fobj->objhdr_pgndx, prev_objndx_spndx, cur_size);
ret = spiffs_fobj_update_ndxhdr(fs, fobj, ret = spiffs_fobj_update_ndxhdr(fs, fobj,
@ -3064,7 +3065,8 @@ int spiffs_fobj_truncate(FAR struct spiffs_s *fs,
fobj->size = cur_size; fobj->size = cur_size;
fobj->offset = cur_size; fobj->offset = cur_size;
finfo("Delete data page %04x for data spndx=%04x, cur_size=%d\n", finfo("Delete data page %04x for data spndx=%04x,"
"cur_size=%" PRIu32 "\n",
data_pgndx, data_spndx, cur_size); data_pgndx, data_spndx, cur_size);
} }
else else
@ -3078,8 +3080,8 @@ int spiffs_fobj_truncate(FAR struct spiffs_s *fs,
bytes_to_remove = SPIFFS_DATA_PAGE_SIZE(fs) - bytes_to_remove = SPIFFS_DATA_PAGE_SIZE(fs) -
(new_size % SPIFFS_DATA_PAGE_SIZE(fs)); (new_size % SPIFFS_DATA_PAGE_SIZE(fs));
finfo("Delete %d bytes from data page=%04x for data spndx=%04x, " finfo("Delete %" PRIu32 " bytes from data page=%04x for "
"cur_size=%d\n", "data spndx=%04x, cur_size=%" PRIu32 "\n",
bytes_to_remove, data_pgndx, data_spndx, cur_size); bytes_to_remove, data_pgndx, data_spndx, cur_size);
ret = spiffs_page_data_check(fs, fobj, data_pgndx, data_spndx); 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); 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", "data_pgndx=%d addr=%" PRIu32 "\n",
cur_offset, len_to_read, data_spndx, data_pgndx, cur_offset, len_to_read, data_spndx, data_pgndx,
(uint32_t)(SPIFFS_PAGE_TO_PADDR(fs, 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; return -ENOSPC;
} }
finfo("COMP select index=%d min_count=%d min=%04x max=%04x " finfo("COMP select index=%" PRIu32 " min_count=%d min=%04x "
"compact:%d\n", "max=%04x compact:%" PRIu32 "\n",
min_i, min_count, state.min_objid, state.max_objid, min_i, min_count, state.min_objid, state.max_objid,
state.compaction); state.compaction);
@ -3617,7 +3619,8 @@ int spiffs_objlu_find_free_objid(FAR struct spiffs_s *fs, int16_t *objid,
} }
else 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.compaction, state.min_objid,
state.min_objid + min_i * state.compaction); 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) / state.compaction = (state.max_objid - state.min_objid) /
((SPIFFS_GEO_PAGE_SIZE(fs) / sizeof(uint8_t))); ((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); state.min_objid, state.max_objid, state.compaction);
memset(fs->work, 0, SPIFFS_GEO_PAGE_SIZE(fs)); memset(fs->work, 0, SPIFFS_GEO_PAGE_SIZE(fs));

View File

@ -49,6 +49,7 @@
#include <stdbool.h> #include <stdbool.h>
#include <string.h> #include <string.h>
#include <debug.h> #include <debug.h>
#include <inttypes.h>
#include "spiffs.h" #include "spiffs.h"
#include "spiffs_core.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++; 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->alloc_pages -= allo;
fs->deleted_pages -= dele; fs->deleted_pages -= dele;
@ -372,7 +373,7 @@ static int spiffs_gc_find_candidate(FAR struct spiffs_s *fs,
candndx = 0; 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, cur_block, deleted_pages_in_block,
used_pages_in_block, score); 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)) 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->free_blocks, needed_pages, free_pages,
fs->deleted_pages); fs->deleted_pages);
return -ENOSPC; return -ENOSPC;
@ -1182,8 +1184,9 @@ int spiffs_gc_check(FAR struct spiffs_s *fs, off_t len)
int16_t cand; int16_t cand;
int32_t prev_free_pages = free_pages; int32_t prev_free_pages = free_pages;
spiffs_gcinfo("#%d: run gc free_blocks=%d pfree=%d pallo=%d pdele=%d " spiffs_gcinfo("#%d: run gc free_blocks=%" PRIu32 " pfree="
"[%d] len=%d of %d\n", "%" PRIu32 " pallo=%" PRIu32 " pdele=%" PRIu32 ""
" [%" PRIu32 "] len=%" PRIu32 " of %" PRIu32 "\n",
tries, fs->free_blocks, free_pages, tries, fs->free_blocks, free_pages,
fs->alloc_pages, fs->deleted_pages, fs->alloc_pages, fs->deleted_pages,
(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; ret = -ENOSPC;
} }
spiffs_gcinfo("Finished, %d dirty, blocks, %d free, %d pages free, " spiffs_gcinfo("Finished, %" PRIu32 " dirty, blocks, %" PRIu32 " "
"%d tries, ret=%d\n", "free, %" PRIu32 " pages free, %d tries, ret=%d\n",
fs->alloc_pages + fs->deleted_pages, fs->alloc_pages + fs->deleted_pages,
fs->free_blocks, free_pages, tries, ret); fs->free_blocks, free_pages, tries, ret);

View File

@ -55,6 +55,7 @@
#include <assert.h> #include <assert.h>
#include <queue.h> #include <queue.h>
#include <debug.h> #include <debug.h>
#include <inttypes.h>
#include <nuttx/kmalloc.h> #include <nuttx/kmalloc.h>
#include <nuttx/fs/fs.h> #include <nuttx/fs/fs.h>
@ -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 " 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->cpndx, fobj->objid,
fobj->cache_page->offset, fobj->cache_page->offset,
fobj->cache_page->size); 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 */ /* Write back cache first */
spiffs_cacheinfo("Cache page=%d for fobj ID=%d " 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->cpndx, fobj->objid,
fobj->cache_page->offset, fobj->cache_page->offset,
fobj->cache_page->size); fobj->cache_page->size);

View File

@ -49,6 +49,7 @@
#include <sys/stat.h> #include <sys/stat.h>
#include <string.h> #include <string.h>
#include <fcntl.h> #include <fcntl.h>
#include <inttypes.h>
#include <nuttx/kmalloc.h> #include <nuttx/kmalloc.h>
@ -245,7 +246,8 @@ ssize_t spiffs_fobj_flush(FAR struct spiffs_s *fs,
if (fobj->cache_page) 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->cpndx, fobj->objid,
fobj->cache_page->offset, fobj->cache_page->size); fobj->cache_page->offset, fobj->cache_page->size);