mirror of
https://github.com/loot/libloot.git
synced 2026-07-27 14:16:01 -07:00
Add cppcoreguidelines-init-variables clang-tidy check
Fix the warnings it emits.
This commit is contained in:
@@ -488,6 +488,7 @@ if(RUN_CLANG_TIDY)
|
||||
"cppcoreguidelines-avoid-c-arrays"
|
||||
"cppcoreguidelines-c-copy-assignment-signature"
|
||||
"cppcoreguidelines-explicit-virtual-functions"
|
||||
"cppcoreguidelines-init-variables"
|
||||
"cppcoreguidelines-interfaces-global-init"
|
||||
"cppcoreguidelines-macro-usage"
|
||||
"cppcoreguidelines-narrowing-conventions"
|
||||
|
||||
@@ -116,8 +116,8 @@ std::vector<std::string> LoadOrderHandler::GetLoadOrder() const {
|
||||
logger->trace("Getting load order.");
|
||||
}
|
||||
|
||||
char** pluginArr;
|
||||
size_t pluginArrSize;
|
||||
char** pluginArr = nullptr;
|
||||
size_t pluginArrSize = 0;
|
||||
|
||||
unsigned int ret = lo_get_load_order(gh_, &pluginArr, &pluginArrSize);
|
||||
|
||||
@@ -136,8 +136,8 @@ std::vector<std::string> LoadOrderHandler::GetActivePlugins() const {
|
||||
logger->trace("Getting active plugins.");
|
||||
}
|
||||
|
||||
char** pluginArr;
|
||||
size_t pluginArrSize;
|
||||
char** pluginArr = nullptr;
|
||||
size_t pluginArrSize = 0;
|
||||
|
||||
unsigned int ret = lo_get_active_plugins(gh_, &pluginArr, &pluginArrSize);
|
||||
|
||||
@@ -156,8 +156,8 @@ std::vector<std::string> LoadOrderHandler::GetImplicitlyActivePlugins() const {
|
||||
logger->trace("Getting implicitly active plugins.");
|
||||
}
|
||||
|
||||
char** pluginArr;
|
||||
size_t pluginArrSize;
|
||||
char** pluginArr = nullptr;
|
||||
size_t pluginArrSize = 0;
|
||||
|
||||
unsigned int ret =
|
||||
lo_get_implicitly_active_plugins(gh_, &pluginArr, &pluginArrSize);
|
||||
|
||||
@@ -199,15 +199,9 @@ void ConditionEvaluator::RefreshActivePluginsState(
|
||||
activePluginNameCStrings.push_back(pluginName.c_str());
|
||||
}
|
||||
|
||||
const char* const* cActivePluginNames;
|
||||
if (activePluginNameCStrings.empty()) {
|
||||
cActivePluginNames = {};
|
||||
} else {
|
||||
cActivePluginNames = &activePluginNameCStrings[0];
|
||||
}
|
||||
|
||||
int result = lci_state_set_active_plugins(
|
||||
lciState_.get(), cActivePluginNames, activePluginNameCStrings.size());
|
||||
int result = lci_state_set_active_plugins(lciState_.get(),
|
||||
activePluginNameCStrings.data(),
|
||||
activePluginNameCStrings.size());
|
||||
HandleError("cache active plugins for condition evaluation", result);
|
||||
}
|
||||
|
||||
@@ -242,26 +236,12 @@ void ConditionEvaluator::RefreshLoadedPluginsState(
|
||||
}
|
||||
}
|
||||
|
||||
const plugin_version* cPluginVersions;
|
||||
if (pluginVersions.empty()) {
|
||||
cPluginVersions = {};
|
||||
} else {
|
||||
cPluginVersions = &pluginVersions[0];
|
||||
}
|
||||
|
||||
int result = lci_state_set_plugin_versions(
|
||||
lciState_.get(), cPluginVersions, pluginVersions.size());
|
||||
lciState_.get(), pluginVersions.data(), pluginVersions.size());
|
||||
HandleError("cache plugin versions for condition evaluation", result);
|
||||
|
||||
const plugin_crc* cPluginCrcs;
|
||||
if (pluginCrcs.empty()) {
|
||||
cPluginCrcs = {};
|
||||
} else {
|
||||
cPluginCrcs = &pluginCrcs[0];
|
||||
}
|
||||
|
||||
result =
|
||||
lci_state_set_crc_cache(lciState_.get(), cPluginCrcs, pluginCrcs.size());
|
||||
result = lci_state_set_crc_cache(
|
||||
lciState_.get(), pluginCrcs.data(), pluginCrcs.size());
|
||||
HandleError("fill CRC cache for condition evaluation", result);
|
||||
}
|
||||
|
||||
|
||||
+11
-11
@@ -90,7 +90,7 @@ Plugin::Plugin(const GameType gameType,
|
||||
std::string Plugin::GetName() const { return name_; }
|
||||
|
||||
std::optional<float> Plugin::GetHeaderVersion() const {
|
||||
float version;
|
||||
float version = 0.0f;
|
||||
|
||||
auto ret = esp_plugin_header_version(esPlugin.get(), &version);
|
||||
if (ret != ESP_OK) {
|
||||
@@ -110,8 +110,8 @@ std::optional<std::string> Plugin::GetVersion() const {
|
||||
}
|
||||
|
||||
std::vector<std::string> Plugin::GetMasters() const {
|
||||
char** masters;
|
||||
uint8_t numMasters;
|
||||
char** masters = nullptr;
|
||||
uint8_t numMasters = 0;
|
||||
auto ret = esp_plugin_masters(esPlugin.get(), &masters, &numMasters);
|
||||
if (ret != ESP_OK) {
|
||||
throw FileAccessError(name_ +
|
||||
@@ -130,7 +130,7 @@ std::vector<Tag> Plugin::GetBashTags() const { return tags_; }
|
||||
std::optional<uint32_t> Plugin::GetCRC() const { return crc_; }
|
||||
|
||||
bool Plugin::IsMaster() const {
|
||||
bool isMaster;
|
||||
bool isMaster = false;
|
||||
auto ret = esp_plugin_is_master(esPlugin.get(), &isMaster);
|
||||
if (ret != ESP_OK) {
|
||||
throw FileAccessError(name_ +
|
||||
@@ -141,7 +141,7 @@ bool Plugin::IsMaster() const {
|
||||
}
|
||||
|
||||
bool Plugin::IsLightPlugin() const {
|
||||
bool isLightPlugin;
|
||||
bool isLightPlugin = false;
|
||||
auto ret = esp_plugin_is_light_plugin(esPlugin.get(), &isLightPlugin);
|
||||
if (ret != ESP_OK) {
|
||||
throw FileAccessError(name_ +
|
||||
@@ -152,7 +152,7 @@ bool Plugin::IsLightPlugin() const {
|
||||
}
|
||||
|
||||
bool Plugin::IsValidAsLightPlugin() const {
|
||||
bool isValid;
|
||||
bool isValid = false;
|
||||
auto ret = esp_plugin_is_valid_as_light_plugin(esPlugin.get(), &isValid);
|
||||
if (ret != ESP_OK) {
|
||||
throw FileAccessError(name_ +
|
||||
@@ -170,7 +170,7 @@ bool Plugin::DoFormIDsOverlap(const PluginInterface& plugin) const {
|
||||
try {
|
||||
auto otherPlugin = dynamic_cast<const Plugin&>(plugin);
|
||||
|
||||
bool doPluginsOverlap;
|
||||
bool doPluginsOverlap = false;
|
||||
auto ret = esp_plugin_do_records_overlap(
|
||||
esPlugin.get(), otherPlugin.esPlugin.get(), &doPluginsOverlap);
|
||||
if (ret != ESP_OK) {
|
||||
@@ -202,7 +202,7 @@ size_t Plugin::GetOverlapSize(
|
||||
esPlugins.push_back(plugin->esPlugin.get());
|
||||
}
|
||||
|
||||
size_t overlapSize;
|
||||
size_t overlapSize = 0;
|
||||
auto ret = esp_plugin_records_overlap_size(
|
||||
esPlugin.get(), &esPlugins[0], esPlugins.size(), &overlapSize);
|
||||
if (ret != ESP_OK) {
|
||||
@@ -232,7 +232,7 @@ bool Plugin::IsValid(const GameType gameType,
|
||||
const std::filesystem::path& pluginPath) {
|
||||
// Check that the file has a valid extension.
|
||||
if (hasPluginFileExtension(pluginPath.filename().u8string(), gameType)) {
|
||||
bool isValid;
|
||||
bool isValid = false;
|
||||
auto returnCode = esp_plugin_is_valid(GetEspluginGameId(gameType),
|
||||
pluginPath.u8string().c_str(),
|
||||
true,
|
||||
@@ -269,7 +269,7 @@ uintmax_t Plugin::GetFileSize(std::filesystem::path pluginPath) {
|
||||
void Plugin::Load(const std::filesystem::path& path,
|
||||
GameType gameType,
|
||||
bool headerOnly) {
|
||||
::Plugin* plugin;
|
||||
::Plugin* plugin = nullptr;
|
||||
auto ret = esp_plugin_new(
|
||||
&plugin, GetEspluginGameId(gameType), path.u8string().c_str());
|
||||
if (ret != ESP_OK) {
|
||||
@@ -288,7 +288,7 @@ void Plugin::Load(const std::filesystem::path& path,
|
||||
}
|
||||
|
||||
std::string Plugin::GetDescription() const {
|
||||
char* description;
|
||||
char* description = nullptr;
|
||||
auto ret = esp_plugin_description(esPlugin.get(), &description);
|
||||
if (ret != ESP_OK) {
|
||||
throw FileAccessError(name_ +
|
||||
|
||||
@@ -434,14 +434,9 @@ void PluginGraph::AddSpecificEdges() {
|
||||
if (graph_[*vit].IsMaster() == graph_[*vit2].IsMaster())
|
||||
continue;
|
||||
|
||||
vertex_t vertex, parentVertex;
|
||||
if (graph_[*vit2].IsMaster()) {
|
||||
parentVertex = *vit2;
|
||||
vertex = *vit;
|
||||
} else {
|
||||
parentVertex = *vit;
|
||||
vertex = *vit2;
|
||||
}
|
||||
auto isOtherPluginAMaster = graph_[*vit2].IsMaster();
|
||||
vertex_t vertex = isOtherPluginAMaster ? *vit : *vit2;
|
||||
vertex_t parentVertex = isOtherPluginAMaster ? *vit2 : *vit;
|
||||
|
||||
AddEdge(parentVertex, vertex, EdgeType::masterFlag);
|
||||
}
|
||||
@@ -702,15 +697,12 @@ void PluginGraph::AddOverlapEdges() {
|
||||
continue;
|
||||
}
|
||||
|
||||
vertex_t toVertex, fromVertex;
|
||||
if (graph_[vertex].NumOverrideFormIDs() >
|
||||
graph_[otherVertex].NumOverrideFormIDs()) {
|
||||
fromVertex = vertex;
|
||||
toVertex = otherVertex;
|
||||
} else {
|
||||
fromVertex = otherVertex;
|
||||
toVertex = vertex;
|
||||
}
|
||||
auto thisPluginOverridesMoreFormIDs =
|
||||
graph_[vertex].NumOverrideFormIDs() >
|
||||
graph_[otherVertex].NumOverrideFormIDs();
|
||||
vertex_t fromVertex =
|
||||
thisPluginOverridesMoreFormIDs ? vertex : otherVertex;
|
||||
vertex_t toVertex = thisPluginOverridesMoreFormIDs ? otherVertex : vertex;
|
||||
|
||||
if (!EdgeCreatesCycle(fromVertex, toVertex))
|
||||
AddEdge(fromVertex, toVertex, EdgeType::overlap);
|
||||
@@ -772,14 +764,10 @@ void PluginGraph::AddTieBreakEdges() {
|
||||
for (vertex_it vit2 = std::next(vit); vit2 != vitend; ++vit2) {
|
||||
vertex_t otherVertex = *vit2;
|
||||
|
||||
vertex_t toVertex, fromVertex;
|
||||
if (ComparePlugins(graph_[vertex], graph_[otherVertex]) < 0) {
|
||||
fromVertex = vertex;
|
||||
toVertex = otherVertex;
|
||||
} else {
|
||||
fromVertex = otherVertex;
|
||||
toVertex = vertex;
|
||||
}
|
||||
auto thisPluginShouldLoadEarlier =
|
||||
ComparePlugins(graph_[vertex], graph_[otherVertex]) < 0;
|
||||
vertex_t fromVertex = thisPluginShouldLoadEarlier ? vertex : otherVertex;
|
||||
vertex_t toVertex = thisPluginShouldLoadEarlier ? otherVertex : vertex;
|
||||
|
||||
if (!EdgeCreatesCycle(fromVertex, toVertex))
|
||||
AddEdge(fromVertex, toVertex, EdgeType::tieBreak);
|
||||
|
||||
Reference in New Issue
Block a user