mirror of
https://github.com/wiiu-env/libfat.git
synced 2024-11-22 09:59:18 +01:00
Fixed _FAT_cache_constructor to return NULL on error, not false
Fixed _FAT_cache_flush to return false on error. With thanks to xorloser
This commit is contained in:
parent
23a406ddd1
commit
bef33572eb
@ -31,6 +31,10 @@
|
|||||||
THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
||||||
(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE,
|
(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE,
|
||||||
EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||||
|
|
||||||
|
2007-11-14 - Chishm
|
||||||
|
* Fixed _FAT_cache_constructor to return NULL on error, not false
|
||||||
|
* Fixed _FAT_cache_flush to return false on error. With thanks to xorloser
|
||||||
*/
|
*/
|
||||||
|
|
||||||
#include <string.h>
|
#include <string.h>
|
||||||
@ -54,7 +58,7 @@ CACHE* _FAT_cache_constructor (u32 numberOfPages, const IO_INTERFACE* discInterf
|
|||||||
|
|
||||||
cache = (CACHE*) _FAT_mem_allocate (sizeof(CACHE));
|
cache = (CACHE*) _FAT_mem_allocate (sizeof(CACHE));
|
||||||
if (cache == NULL) {
|
if (cache == NULL) {
|
||||||
return false;
|
return NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
cache->disc = discInterface;
|
cache->disc = discInterface;
|
||||||
@ -64,7 +68,7 @@ CACHE* _FAT_cache_constructor (u32 numberOfPages, const IO_INTERFACE* discInterf
|
|||||||
cacheEntries = (CACHE_ENTRY*) _FAT_mem_allocate ( sizeof(CACHE_ENTRY) * numberOfPages);
|
cacheEntries = (CACHE_ENTRY*) _FAT_mem_allocate ( sizeof(CACHE_ENTRY) * numberOfPages);
|
||||||
if (cacheEntries == NULL) {
|
if (cacheEntries == NULL) {
|
||||||
_FAT_mem_free (cache);
|
_FAT_mem_free (cache);
|
||||||
return false;
|
return NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
for (i = 0; i < numberOfPages; i++) {
|
for (i = 0; i < numberOfPages; i++) {
|
||||||
@ -79,7 +83,7 @@ CACHE* _FAT_cache_constructor (u32 numberOfPages, const IO_INTERFACE* discInterf
|
|||||||
if (cache->pages == NULL) {
|
if (cache->pages == NULL) {
|
||||||
_FAT_mem_free (cache->cacheEntries);
|
_FAT_mem_free (cache->cacheEntries);
|
||||||
_FAT_mem_free (cache);
|
_FAT_mem_free (cache);
|
||||||
return false;
|
return NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
return cache;
|
return cache;
|
||||||
@ -217,7 +221,7 @@ bool _FAT_cache_flush (CACHE* cache) {
|
|||||||
for (i = 0; i < cache->numberOfPages; i++) {
|
for (i = 0; i < cache->numberOfPages; i++) {
|
||||||
if (cache->cacheEntries[i].dirty) {
|
if (cache->cacheEntries[i].dirty) {
|
||||||
if (!_FAT_disc_writeSectors (cache->disc, cache->cacheEntries[i].sector, 1, cache->pages + CACHE_PAGE_SIZE * i)) {
|
if (!_FAT_disc_writeSectors (cache->disc, cache->cacheEntries[i].sector, 1, cache->pages + CACHE_PAGE_SIZE * i)) {
|
||||||
return CACHE_FREE;
|
return false;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
cache->cacheEntries[i].count = 0;
|
cache->cacheEntries[i].count = 0;
|
||||||
@ -235,3 +239,4 @@ void _FAT_cache_invalidate (CACHE* cache) {
|
|||||||
cache->cacheEntries[i].dirty = false;
|
cache->cacheEntries[i].dirty = false;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -116,3 +116,4 @@ CACHE* _FAT_cache_constructor (u32 numberOfPages, const IO_INTERFACE* discInterf
|
|||||||
void _FAT_cache_destructor (CACHE* cache);
|
void _FAT_cache_destructor (CACHE* cache);
|
||||||
|
|
||||||
#endif // _CACHE_H
|
#endif // _CACHE_H
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user