BASE: Use nullptr

Using clang-tidy modernize-use-nullptr
This commit is contained in:
Orgad Shaneh 2021-11-13 23:33:52 +02:00 committed by Filippos Karapetis
parent 44219dfa1a
commit e92e232788
3 changed files with 23 additions and 23 deletions

View File

@ -520,7 +520,7 @@ Common::String parseCommandLine(Common::StringMap &settings, int argc, const cha
// Iterate over all command line arguments and parse them into our string map.
for (int i = 1; i < argc; ++i) {
s = argv[i];
s2 = (i < argc-1) ? argv[i+1] : 0;
s2 = (i < argc-1) ? argv[i+1] : nullptr;
if (s[0] != '-') {
// The argument doesn't start with a dash, so it's not an option.
@ -1463,7 +1463,7 @@ void upgradeTargets() {
DetectionResults detectionResults = EngineMan.detectGames(files);
DetectedGames candidates = detectionResults.listRecognizedGames();
DetectedGame *g = 0;
DetectedGame *g = nullptr;
// We proceed as follows:
// * If detection failed to produce candidates, skip.

View File

@ -118,18 +118,18 @@ static const Plugin *detectPlugin() {
// At this point the engine ID and game ID must be known
if (engineId.empty()) {
warning("The engine ID is not set for target '%s'", ConfMan.getActiveDomainName().c_str());
return 0;
return nullptr;
}
if (gameId.empty()) {
warning("The game ID is not set for target '%s'", ConfMan.getActiveDomainName().c_str());
return 0;
return nullptr;
}
const Plugin *plugin = EngineMan.findPlugin(engineId);
if (!plugin) {
warning("'%s' is an invalid engine ID. Use the --list-engines command to list supported engine IDs", engineId.c_str());
return 0;
return nullptr;
}
// Query the plugin for the game descriptor
@ -139,7 +139,7 @@ static const Plugin *detectPlugin() {
PlainGameDescriptor game = metaEngine.findGame(gameId.c_str());
if (!game.gameId) {
warning("'%s' is an invalid game ID for the engine '%s'. Use the --list-games option to list supported game IDs", gameId.c_str(), engineId.c_str());
return 0;
return nullptr;
}
return plugin;
@ -163,7 +163,7 @@ static Common::Error runGame(const Plugin *plugin, const Plugin *enginePlugin, O
Common::FSNode dir(ConfMan.get("path"));
Common::String target = ConfMan.getActiveDomainName();
Common::Error err = Common::kNoError;
Engine *engine = 0;
Engine *engine = nullptr;
#if defined(SDL_BACKEND) && defined(USE_OPENGL) && defined(USE_RGB_COLOR)
// HACK: We set up the requested graphics mode setting here to allow the
@ -435,7 +435,7 @@ extern "C" int scummvm_main(int argc, const char * const argv[]) {
// soonest possible moment to ensure debug output starts early on, if
// requested.
if (settings.contains("debuglevel")) {
gDebugLevel = (int)strtol(settings["debuglevel"].c_str(), 0, 10);
gDebugLevel = (int)strtol(settings["debuglevel"].c_str(), nullptr, 10);
printf("Debuglevel (from command line): %d\n", gDebugLevel);
settings.erase("debuglevel"); // This option should not be passed to ConfMan.
} else if (ConfMan.hasKey("debuglevel"))
@ -569,13 +569,13 @@ extern "C" int scummvm_main(int argc, const char * const argv[]) {
#endif
// Unless a game was specified, show the launcher dialog
if (0 == ConfMan.getActiveDomain())
if (nullptr == ConfMan.getActiveDomain())
launcherDialog();
// FIXME: We're now looping the launcher. This, of course, doesn't
// work as well as it should. In theory everything should be destroyed
// cleanly, so this is now enabled to encourage people to fix bits :)
while (0 != ConfMan.getActiveDomain()) {
while (nullptr != ConfMan.getActiveDomain()) {
saveLastLaunchedTarget(ConfMan.getActiveDomainName());
EngineMan.upgradeTargetIfNecessary(ConfMan.getActiveDomainName());
@ -703,7 +703,7 @@ extern "C" int scummvm_main(int argc, const char * const argv[]) {
// reset the graphics to default
setupGraphics(system);
if (0 == ConfMan.getActiveDomain()) {
if (nullptr == ConfMan.getActiveDomain()) {
launcherDialog();
}
}

View File

@ -254,7 +254,7 @@ void FilePluginProvider::addCustomDirectories(Common::FSList &dirs) const {
#pragma mark -
PluginManager *PluginManager::_instance = NULL;
PluginManager *PluginManager::_instance = nullptr;
PluginManager &PluginManager::instance() {
if (_instance)
@ -345,7 +345,7 @@ void PluginManagerUncached::init() {
_allEnginePlugins.clear();
ConfMan.setBool("always_run_fallback_detection_extern", false);
unloadPluginsExcept(PLUGIN_TYPE_ENGINE, NULL, false); // empty the engine plugins
unloadPluginsExcept(PLUGIN_TYPE_ENGINE, nullptr, false); // empty the engine plugins
#ifndef DETECTION_STATIC
Common::String detectPluginName = "detection";
@ -433,7 +433,7 @@ bool PluginManagerUncached::loadPluginByFileName(const Common::String &filename)
if (filename.empty())
return false;
unloadPluginsExcept(PLUGIN_TYPE_ENGINE, NULL, false);
unloadPluginsExcept(PLUGIN_TYPE_ENGINE, nullptr, false);
PluginList::iterator i;
for (i = _allEnginePlugins.begin(); i != _allEnginePlugins.end(); ++i) {
@ -509,7 +509,7 @@ void PluginManagerUncached::unloadDetectionPlugin() {
#endif
void PluginManagerUncached::loadFirstPlugin() {
unloadPluginsExcept(PLUGIN_TYPE_ENGINE, NULL, false);
unloadPluginsExcept(PLUGIN_TYPE_ENGINE, nullptr, false);
// let's try to find one we can load
for (_currentPlugin = _allEnginePlugins.begin(); _currentPlugin != _allEnginePlugins.end(); ++_currentPlugin) {
@ -521,7 +521,7 @@ void PluginManagerUncached::loadFirstPlugin() {
}
bool PluginManagerUncached::loadNextPlugin() {
unloadPluginsExcept(PLUGIN_TYPE_ENGINE, NULL, false);
unloadPluginsExcept(PLUGIN_TYPE_ENGINE, nullptr, false);
if (!_currentPlugin || _currentPlugin == _allEnginePlugins.end())
return false;
@ -590,11 +590,11 @@ void PluginManager::loadAllPluginsOfType(PluginType type) {
void PluginManager::unloadAllPlugins() {
for (int i = 0; i < PLUGIN_TYPE_MAX; i++)
unloadPluginsExcept((PluginType)i, NULL);
unloadPluginsExcept((PluginType)i, nullptr);
}
void PluginManager::unloadPluginsExcept(PluginType type, const Plugin *plugin, bool deletePlugin /*=true*/) {
Plugin *found = NULL;
Plugin *found = nullptr;
for (PluginList::iterator p = _pluginsInMem[type].begin(); p != _pluginsInMem[type].end(); ++p) {
if (*p == plugin) {
found = *p;
@ -606,7 +606,7 @@ void PluginManager::unloadPluginsExcept(PluginType type, const Plugin *plugin, b
}
}
_pluginsInMem[type].clear();
if (found != NULL) {
if (found != nullptr) {
_pluginsInMem[type].push_back(found);
}
}
@ -816,7 +816,7 @@ const Plugin *EngineManager::findPlugin(const Common::String &engineId) const {
if (engineId == (*iter)->get<MetaEngineDetection>().getEngineId())
return *iter;
return 0;
return nullptr;
}
const Plugin *PluginManager::findLoadedPlugin(const Common::String &engineId) {
@ -826,7 +826,7 @@ const Plugin *PluginManager::findLoadedPlugin(const Common::String &engineId) {
if (engineId == (*iter)->get<MetaEngine>().getName())
return *iter;
return 0;
return nullptr;
}
const Plugin *PluginManager::findEnginePlugin(const Common::String &engineId) {
@ -855,7 +855,7 @@ const Plugin *PluginManager::findEnginePlugin(const Common::String &engineId) {
}
} while (PluginMan.loadNextPlugin());
return 0;
return nullptr;
}
QualifiedGameDescriptor EngineManager::findTarget(const Common::String &target, const Plugin **plugin) const {
@ -1030,7 +1030,7 @@ Plugin *ScalerManager::findScalerPlugin(const char *name) const {
}
}
return 0;
return nullptr;
}
uint ScalerManager::findScalerPluginIndex(const char *name) const {