summaryrefslogtreecommitdiff
path: root/Source/Core/Common/SDCardUtil.cpp
diff options
context:
space:
mode:
authorLioncash <mathew1800@gmail.com>2018-05-11 08:51:27 -0400
committerLioncash <mathew1800@gmail.com>2018-05-11 08:55:05 -0400
commit1ffd0d2572c7fc4ee0c5072316f68fcbceb41166 (patch)
tree8bdd00bc1a49aac24a1d96367a73041edae56157 /Source/Core/Common/SDCardUtil.cpp
parentc26de8107dcd4843e154c97284a204f9dc519bc9 (diff)
SDCardUtil: Make type of write_empty's "count" parameter size_t
This allows getting rid of casts. We can also leverage std::min to allow making relevant variables const. Also make the "empty" table const to allow it to be read-only.
Diffstat (limited to 'Source/Core/Common/SDCardUtil.cpp')
-rw-r--r--Source/Core/Common/SDCardUtil.cpp14
1 files changed, 7 insertions, 7 deletions
diff --git a/Source/Core/Common/SDCardUtil.cpp b/Source/Core/Common/SDCardUtil.cpp
index 5719c1552f..7e6ed5ed1f 100644
--- a/Source/Core/Common/SDCardUtil.cpp
+++ b/Source/Core/Common/SDCardUtil.cpp
@@ -32,6 +32,9 @@
// A simple and portable piece of code used to generate a blank FAT32 image file.
// Modified for Dolphin.
+#include "Common/SDCardUtil.h"
+
+#include <algorithm>
#include <cinttypes>
#include <cstddef>
#include <cstdio>
@@ -43,7 +46,6 @@
#include "Common/CommonTypes.h"
#include "Common/File.h"
#include "Common/Logging/Log.h"
-#include "Common/SDCardUtil.h"
#ifndef _WIN32
#include <unistd.h> // for unlink()
@@ -182,18 +184,16 @@ static bool write_sector(FILE* file, const u8* sector)
return fwrite(sector, 1, BYTES_PER_SECTOR, file) == BYTES_PER_SECTOR;
}
-static bool write_empty(FILE* file, u64 count)
+static bool write_empty(FILE* file, std::size_t count)
{
- static u8 empty[64 * 1024];
+ static constexpr u8 empty[64 * 1024] = {};
count *= BYTES_PER_SECTOR;
while (count > 0)
{
- u64 len = sizeof(empty);
- if (len > count)
- len = count;
+ const std::size_t len = std::min(sizeof(empty), count);
- if (fwrite(empty, 1, (size_t)len, file) != (size_t)len)
+ if (fwrite(empty, 1, len, file) != len)
return false;
count -= len;