pellepl / spiffs

Wear-leveled SPI flash file system for embedded devices
MIT License
1.5k stars 402 forks source link

Wrong parameters to _spiffs_rd() #208

Open AndreasKretzer opened 6 years ago

AndreasKretzer commented 6 years ago

It looks like you where calling _spiffs_rd() with a misstyped parameter list in spiffs_obj_lu_find_id_and_span_v()! The parameter "fh" seems to be an restover of an older version and is half of the calls supplied with a null value. The "op" parameter contains some flags for cache access policies. In spiffs_nucleus.c, line 511 (V0.3.7) you call _spiffs_rd() with this dummy-null and the flags swapped! The flag SPIFFS_OP_T_OBJ_LU2 is acted on in the called function spiffs_phys_rd() to directly read the flash instead of trying to access the cache. The comment says, that you don't want to "shredder". By swapping these two arguments, you supply unsed info to an ignored parameter and a zero to the flags parameter. I can't tell, if that has any further harm (and I indeed didn't notice any), but maybe you should fix it - just in case ... :-)

Andreas

nathanjamesboyd commented 5 years ago

Hi Andreas,

I spotted this as well then saw your issue submission. FWIW, I think your assessment is correct: no real harm, just eviction of a cache entry.