commit b882138b34579acabbaddc112324c73a020c6cfa
parent c57024b273b1a56ce4cc5b7fb3c0acdf1d857108
Author: cfillion <cfillion@users.noreply.github.com>
Date: Sun, 12 Feb 2017 18:04:01 -0500
refactoring – remove useless array intialization
Diffstat:
10 files changed, 27 insertions(+), 29 deletions(-)
diff --git a/src/about.cpp b/src/about.cpp
@@ -170,7 +170,7 @@ void About::setDelegate(const DelegatePtr &delegate, const bool focus)
void About::setTitle(const string &what)
{
- auto_char title[255] = {};
+ auto_char title[255];
auto_snprintf(title, auto_size(title),
AUTO_STR("About %s"), make_autostring(what).c_str());
SetWindowText(handle(), title);
@@ -335,7 +335,7 @@ void AboutIndexDelegate::initInstalledFiles()
}
catch(const reapack_error &e) {
const auto_string &desc = make_autostring(e.what());
- auto_char msg[255] = {};
+ auto_char msg[255];
auto_snprintf(msg, auto_size(msg),
AUTO_STR("The file list is currently unavailable.\x20")
AUTO_STR("Retry later when all installation task are completed.\r\n")
diff --git a/src/browser.cpp b/src/browser.cpp
@@ -326,7 +326,7 @@ void Browser::fillMenu(Menu &menu)
if(entry->test(InstalledFlag)) {
if(entry->test(OutOfDateFlag)) {
- auto_char installLabel[32] = {};
+ auto_char installLabel[32];
auto_snprintf(installLabel, auto_size(installLabel),
AUTO_STR("U&pdate to v%s"),
make_autostring(entry->latest->name().toString()).c_str());
@@ -336,7 +336,7 @@ void Browser::fillMenu(Menu &menu)
menu.check(actionIndex);
}
- auto_char reinstallLabel[32] = {};
+ auto_char reinstallLabel[32];
auto_snprintf(reinstallLabel, auto_size(reinstallLabel),
AUTO_STR("&Reinstall v%s"),
make_autostring(entry->regEntry.version.toString()).c_str());
@@ -348,7 +348,7 @@ void Browser::fillMenu(Menu &menu)
menu.check(actionIndex);
}
else {
- auto_char installLabel[32] = {};
+ auto_char installLabel[32];
auto_snprintf(installLabel, auto_size(installLabel),
AUTO_STR("&Install v%s"),
make_autostring(entry->latest->name().toString()).c_str());
@@ -398,7 +398,7 @@ void Browser::fillMenu(Menu &menu)
menu.setEnabled(!entry->test(ObsoleteFlag),
menu.addAction(AUTO_STR("About this &package"), ACTION_ABOUT_PKG));
- auto_char aboutLabel[35] = {};
+ auto_char aboutLabel[35];
const auto_string &name = make_autostring(getValue(RemoteColumn, *entry));
auto_snprintf(aboutLabel, auto_size(aboutLabel),
AUTO_STR("&About %s..."), name.c_str());
@@ -407,7 +407,7 @@ void Browser::fillMenu(Menu &menu)
void Browser::updateDisplayLabel()
{
- auto_char btnLabel[32] = {};
+ auto_char btnLabel[32];
auto_snprintf(btnLabel, auto_size(btnLabel), AUTO_STR("%d/%zu package%s..."),
m_list->rowCount(), m_entries.size(),
m_entries.size() == 1 ? AUTO_STR("") : AUTO_STR("s"));
@@ -601,7 +601,7 @@ void Browser::populate(const vector<IndexPtr> &indexes)
}
catch(const reapack_error &e) {
const auto_string &desc = make_autostring(e.what());
- auto_char msg[255] = {};
+ auto_char msg[255];
auto_snprintf(msg, auto_size(msg),
AUTO_STR("ReaPack could not read from the local package registry.\r\n")
AUTO_STR("Retry later once all installation task are completed.\r\n")
@@ -1043,7 +1043,7 @@ bool Browser::confirm() const
const size_t count = m_actions.size();
- auto_char msg[255] = {};
+ auto_char msg[255];
auto_snprintf(msg, auto_size(msg),
AUTO_STR("Confirm execution of %zu action%s?\n"),
count, count == 1 ? AUTO_STR("") : AUTO_STR("s"));
diff --git a/src/database.cpp b/src/database.cpp
@@ -90,7 +90,7 @@ void Database::setVersion(const Version &version)
{
int32_t value = version.minor | (int32_t)version.major << 16;
- char sql[255] = {};
+ char sql[255];
sprintf(sql, "PRAGMA user_version = %" PRId32, value);
exec(sql);
}
diff --git a/src/import.cpp b/src/import.cpp
@@ -143,6 +143,8 @@ void Import::read()
bool Import::import(const Remote &remote)
{
+ auto_char msg[1024];
+
if(const Remote &existing = m_reapack->remote(remote.name())) {
if(existing.isProtected()) {
MessageBox(handle(),
@@ -152,7 +154,6 @@ bool Import::import(const Remote &remote)
return true;
}
else if(existing.url() != remote.url()) {
- auto_char msg[1024] = {};
auto_snprintf(msg, auto_size(msg),
AUTO_STR("%s is already configured with a different URL.\r\n")
AUTO_STR("Do you want to overwrite it?"),
@@ -164,7 +165,6 @@ bool Import::import(const Remote &remote)
return false;
}
else if(existing.isEnabled()) {
- auto_char msg[1024] = {};
auto_snprintf(msg, auto_size(msg),
AUTO_STR("%s is already configured.\r\nNothing to do!"),
make_autostring(remote.name()).c_str());
@@ -183,7 +183,6 @@ bool Import::import(const Remote &remote)
m_reapack->config()->write();
- auto_char msg[1024] = {};
auto_snprintf(msg, auto_size(msg), AUTO_STR("%s has been enabled."),
make_autostring(remote.name()).c_str());
MessageBox(handle(), msg, TITLE, MB_OK);
@@ -198,7 +197,6 @@ bool Import::import(const Remote &remote)
FS::write(Index::pathFor(remote.name()), m_download->contents());
- auto_char msg[1024] = {};
auto_snprintf(msg, auto_size(msg),
AUTO_STR("%s has been successfully imported into your repository list."),
make_autostring(remote.name()).c_str());
diff --git a/src/main.cpp b/src/main.cpp
@@ -54,7 +54,7 @@ static bool loadAPI(void *(*getFunc)(const char *))
*func.ptr = getFunc(func.name);
if(func.required && *func.ptr == nullptr) {
- auto_char msg[1024] = {};
+ auto_char msg[1024];
auto_snprintf(msg, auto_size(msg),
AUTO_STR("ReaPack v%s is incompatible with this version of REAPER.\r\n\r\n")
AUTO_STR("(Unable to import the following API function: %s)"),
@@ -99,7 +99,7 @@ static void menuHook(const char *name, HMENU handle, int f)
menu.addSeparator();
- auto_char aboutLabel[32] = {};
+ auto_char aboutLabel[32];
auto_snprintf(aboutLabel, auto_size(aboutLabel),
AUTO_STR("&About ReaPack v%s"), make_autocstring(ReaPack::VERSION));
menu.addAction(aboutLabel, NamedCommandLookup("_REAPACK_ABOUT"));
@@ -126,7 +126,7 @@ static bool checkLocation(REAPER_PLUGIN_HINSTANCE module)
if(current == expected)
return true;
- auto_char msg[4096] = {};
+ auto_char msg[4096];
auto_snprintf(msg, auto_size(msg),
AUTO_STR("ReaPack was not loaded from the standard extension path")
AUTO_STR(" or its filename was altered.\n")
diff --git a/src/manager.cpp b/src/manager.cpp
@@ -204,7 +204,7 @@ bool Manager::fillContextMenu(Menu &menu, const int index) const
menu.addSeparator();
- auto_char aboutLabel[35] = {};
+ auto_char aboutLabel[35];
const auto_string &name = make_autostring(remote.name());
auto_snprintf(aboutLabel, auto_size(aboutLabel),
AUTO_STR("&About %s..."), name.c_str());
@@ -514,7 +514,7 @@ bool Manager::confirm() const
const size_t uninstallSize = m_uninstall.size();
- auto_char msg[255] = {};
+ auto_char msg[255];
auto_snprintf(msg, auto_size(msg), AUTO_STR("Uninstall %zu %s?\n")
AUTO_STR("Every file they contain will be removed from your computer."),
uninstallSize,
diff --git a/src/progress.cpp b/src/progress.cpp
@@ -80,7 +80,7 @@ void Progress::addDownload(Download *dl)
void Progress::updateProgress()
{
- auto_char label[1024] = {};
+ auto_char label[1024];
auto_snprintf(label, auto_size(label), AUTO_STR("Downloading %d of %d: %s"),
min(m_done + 1, m_total), m_total, m_currentName.c_str());
@@ -89,7 +89,7 @@ void Progress::updateProgress()
const double pos = (double)(min(m_done+1, m_total)) / max(2, m_total);
const int percent = (int)(pos * 100);
- auto_char title[255] = {};
+ auto_char title[255];
auto_snprintf(title, auto_size(title),
AUTO_STR("ReaPack: Download in progress (%d%%)"), percent);
diff --git a/src/reapack.cpp b/src/reapack.cpp
@@ -327,7 +327,7 @@ void ReaPack::doFetchIndex(const Remote &remote, DownloadQueue *queue,
return;
const auto warn = [=] (const string &desc, const auto_char *title) {
- auto_char msg[512] = {};
+ auto_char msg[512];
auto_snprintf(msg, auto_size(msg),
AUTO_STR("ReaPack could not download %s's index.\n\n")
@@ -369,7 +369,7 @@ IndexPtr ReaPack::loadIndex(const Remote &remote, HWND parent)
catch(const reapack_error &e) {
const auto_string &desc = make_autostring(e.what());
- auto_char msg[512] = {};
+ auto_char msg[512];
auto_snprintf(msg, auto_size(msg),
AUTO_STR("ReaPack could not read %s's index.\n\n")
@@ -400,7 +400,7 @@ Transaction *ReaPack::setupTransaction()
catch(const reapack_error &e) {
const auto_string &desc = make_autostring(e.what());
- auto_char msg[512] = {};
+ auto_char msg[512];
auto_snprintf(msg, auto_size(msg),
AUTO_STR("The following error occurred while creating a transaction:\n\n%s"),
desc.c_str()
@@ -480,7 +480,7 @@ void ReaPack::registerSelf()
catch(const reapack_error &e) {
const auto_string &desc = make_autostring(e.what());
- auto_char msg[255] = {};
+ auto_char msg[255];
auto_snprintf(msg, auto_size(msg),
AUTO_STR("ReaPack could not register itself! Please report this issue.\n\n")
AUTO_STR("Error description: %s"), desc.c_str());
diff --git a/src/registry.cpp b/src/registry.cpp
@@ -299,7 +299,7 @@ void Registry::forget(const Entry &entry)
void Registry::savepoint()
{
- char sql[64] = {};
+ char sql[64];
sprintf(sql, "SAVEPOINT sp%zu", m_savePoint++);
m_db.exec(sql);
@@ -307,7 +307,7 @@ void Registry::savepoint()
void Registry::restore()
{
- char sql[64] = {};
+ char sql[64];
sprintf(sql, "ROLLBACK TO SAVEPOINT sp%zu", --m_savePoint);
m_db.exec(sql);
@@ -315,7 +315,7 @@ void Registry::restore()
void Registry::release()
{
- char sql[64] = {};
+ char sql[64];
sprintf(sql, "RELEASE SAVEPOINT sp%zu", --m_savePoint);
m_db.exec(sql);
diff --git a/test/encoding.cpp b/test/encoding.cpp
@@ -27,6 +27,6 @@ TEST_CASE("string to wstring to string", M) {
}
TEST_CASE("auto_size", M) {
- auto_char test[42] = {};
+ auto_char test[42];
REQUIRE(auto_size(test) == 42);
}