Преглед изворни кода

Fix cache bug for FAT16/FAT32

Bill Greiman пре 4 година
родитељ
комит
887e0a6730
2 измењених фајлова са 3 додато и 3 уклоњено
  1. 1 1
      library.properties
  2. 2 2
      src/FatLib/FatFile.cpp

+ 1 - 1
library.properties

@@ -1,5 +1,5 @@
 name=SdFat
 name=SdFat
-version=2.0.0
+version=2.0.1
 license=MIT
 license=MIT
 author=Bill Greiman <fat16lib@sbcglobal.net>
 author=Bill Greiman <fat16lib@sbcglobal.net>
 maintainer=Bill Greiman <fat16lib@sbcglobal.net>
 maintainer=Bill Greiman <fat16lib@sbcglobal.net>

+ 2 - 2
src/FatLib/FatFile.cpp

@@ -764,7 +764,7 @@ int FatFile::read(void* buf, size_t nbyte) {
       n = ns << m_vol->bytesPerSectorShift();
       n = ns << m_vol->bytesPerSectorShift();
       // Check for cache sector in read range.
       // Check for cache sector in read range.
       if (sector <= m_vol->cacheSectorNumber()
       if (sector <= m_vol->cacheSectorNumber()
-          && sector < (m_vol->cacheSectorNumber() + ns)) {
+          && m_vol->cacheSectorNumber() < (sector + ns)) {
         // Flush cache if cache sector is in the range.
         // Flush cache if cache sector is in the range.
         if (!m_vol->cacheSyncData()) {
         if (!m_vol->cacheSyncData()) {
           DBG_FAIL_MACRO;
           DBG_FAIL_MACRO;
@@ -1402,7 +1402,7 @@ size_t FatFile::write(const void* buf, size_t nbyte) {
       n = nSector << m_vol->bytesPerSectorShift();
       n = nSector << m_vol->bytesPerSectorShift();
       // Check for cache sector in write range.
       // Check for cache sector in write range.
       if (sector <= m_vol->cacheSectorNumber()
       if (sector <= m_vol->cacheSectorNumber()
-          && sector < (m_vol->cacheSectorNumber() + nSector)) {
+          && m_vol->cacheSectorNumber() < (sector + nSector)) {
         // Invalidate cache if cache sector is in the range.
         // Invalidate cache if cache sector is in the range.
         m_vol->cacheInvalidate();
         m_vol->cacheInvalidate();
       }
       }