summaryrefslogtreecommitdiff
path: root/Source/Core/Common/SDCardUtil.cpp
diff options
context:
space:
mode:
authorLioncash <mathew1800@gmail.com>2018-05-11 08:29:36 -0400
committerLioncash <mathew1800@gmail.com>2018-05-11 08:29:37 -0400
commitc26de8107dcd4843e154c97284a204f9dc519bc9 (patch)
tree9904b40a1f68827fef495500ce086e2d56460e6e /Source/Core/Common/SDCardUtil.cpp
parent5fc18aa63944b247a0daa0cd87b1553a6e3da5a7 (diff)
SDCardUtil: Convert return type of write_* functions to bool
Converts them from 0 == success, 1 == failure to using the built-in standard bool. Also while we're at it, const qualify write_sector's "sector" parameter, since nothing in the function modifies the data being pointed to.
Diffstat (limited to 'Source/Core/Common/SDCardUtil.cpp')
-rw-r--r--Source/Core/Common/SDCardUtil.cpp34
1 files changed, 17 insertions, 17 deletions
diff --git a/Source/Core/Common/SDCardUtil.cpp b/Source/Core/Common/SDCardUtil.cpp
index d57a43fb9d..5719c1552f 100644
--- a/Source/Core/Common/SDCardUtil.cpp
+++ b/Source/Core/Common/SDCardUtil.cpp
@@ -177,12 +177,12 @@ static void fat_init(u8* fat)
POKEW(fat + 8, 0x0fffffff); /* End of cluster chain for root dir */
}
-static unsigned int write_sector(FILE* file, u8* sector)
+static bool write_sector(FILE* file, const u8* sector)
{
- return fwrite(sector, 1, BYTES_PER_SECTOR, file) != BYTES_PER_SECTOR;
+ return fwrite(sector, 1, BYTES_PER_SECTOR, file) == BYTES_PER_SECTOR;
}
-static unsigned int write_empty(FILE* file, u64 count)
+static bool write_empty(FILE* file, u64 count)
{
static u8 empty[64 * 1024];
@@ -194,11 +194,11 @@ static unsigned int write_empty(FILE* file, u64 count)
len = count;
if (fwrite(empty, 1, (size_t)len, file) != (size_t)len)
- return 1;
+ return false;
count -= len;
}
- return 0;
+ return true;
}
bool SDCardCreate(u64 disk_size /*in MB*/, const std::string& filename)
@@ -245,45 +245,45 @@ bool SDCardCreate(u64 disk_size /*in MB*/, const std::string& filename)
* zero sectors
*/
- if (write_sector(f, s_boot_sector))
+ if (!write_sector(f, s_boot_sector))
goto FailWrite;
- if (write_sector(f, s_fsinfo_sector))
+ if (!write_sector(f, s_fsinfo_sector))
goto FailWrite;
if (BACKUP_BOOT_SECTOR > 0)
{
- if (write_empty(f, BACKUP_BOOT_SECTOR - 2))
+ if (!write_empty(f, BACKUP_BOOT_SECTOR - 2))
goto FailWrite;
- if (write_sector(f, s_boot_sector))
+ if (!write_sector(f, s_boot_sector))
goto FailWrite;
- if (write_sector(f, s_fsinfo_sector))
+ if (!write_sector(f, s_fsinfo_sector))
goto FailWrite;
- if (write_empty(f, RESERVED_SECTORS - 2 - BACKUP_BOOT_SECTOR))
+ if (!write_empty(f, RESERVED_SECTORS - 2 - BACKUP_BOOT_SECTOR))
goto FailWrite;
}
else
{
- if (write_empty(f, RESERVED_SECTORS - 2))
+ if (!write_empty(f, RESERVED_SECTORS - 2))
goto FailWrite;
}
- if (write_sector(f, s_fat_head))
+ if (!write_sector(f, s_fat_head))
goto FailWrite;
- if (write_empty(f, sectors_per_fat - 1))
+ if (!write_empty(f, sectors_per_fat - 1))
goto FailWrite;
- if (write_sector(f, s_fat_head))
+ if (!write_sector(f, s_fat_head))
goto FailWrite;
- if (write_empty(f, sectors_per_fat - 1))
+ if (!write_empty(f, sectors_per_fat - 1))
goto FailWrite;
- if (write_empty(f, sectors_per_disk - RESERVED_SECTORS - 2 * sectors_per_fat))
+ if (!write_empty(f, sectors_per_disk - RESERVED_SECTORS - 2 * sectors_per_fat))
goto FailWrite;
return true;