flint++ static analyzer detected items (not all that were likely legit positives, but a start) as well as some clang detected unused vars, cleanup_

This commit is contained in:
DarthArgus
2016-02-18 22:56:34 -06:00
parent 13019a2b14
commit 3c50042abc
29 changed files with 20 additions and 358 deletions
@@ -53,8 +53,6 @@
#include <stdlib.h> // for tolower()
//================================================= static vars assignment ==
const int entryPointVersion = 1; // constantly check DataEntryPoint.h to see if this value has changed
OutputFileHandler *outfileHandler = nullptr;
const int bufferSize = 16 * 1024 * 1024;
const int maxStringSize = 256;
@@ -22,12 +22,6 @@ namespace CommandNames
#undef MAKE_COMMAND
}
const CommandParser::CmdInfo cmds[] =
{
{"runState", 0, "", "Return the running state of the CentralServer. It should always return 'running'"},
{"", 0, "", ""} // this must be last
};
//-----------------------------------------------------------------------
ConsoleCommandParserLoginServer::ConsoleCommandParserLoginServer() :
@@ -18,10 +18,6 @@ class TaskUpdatePurgeAccountList : public DB::TaskRequest
TaskUpdatePurgeAccountList();
virtual bool process (DB::Session *session);
virtual void onComplete ();
private:
StationId m_account;
int m_purgePhase;
};
// ======================================================================
@@ -26,7 +26,7 @@ public:
void onReceive (const Archive::ByteStream & message);
void receiveMessage (const MessageDispatch::Emitter & source, const MessageDispatch::MessageBase & message);
private:
CentralServerConnection(CentralServerConnection&);
CentralServerConnection(const CentralServerConnection&);
CentralServerConnection& operator=(CentralServerConnection&);
};
@@ -31,7 +31,7 @@ private:
ChunkCompleteQueueType * const m_chunkCompleteQueue;
private:
GameServerConnection(GameServerConnection&);
GameServerConnection(const GameServerConnection&);
GameServerConnection& operator=(GameServerConnection&);
};
@@ -47,7 +47,7 @@ class LazyDeleter
~LazyDeleter();
private:
LazyDeleter(LazyDeleter&); //disable
LazyDeleter(const LazyDeleter&); //disable
LazyDeleter &operator=(const LazyDeleter&); //disable
private:
@@ -191,7 +191,7 @@ class Persister : public MessageDispatch::Receiver
static void installDerived(Persister *derivedInstance);
private:
Persister(Persister&); //disable
Persister(const Persister&); //disable
Persister &operator=(const Persister&); //disable
private:
@@ -20,7 +20,7 @@ public:
void onConnectionOpened ();
private:
TaskManagerConnection(TaskManagerConnection&);
TaskManagerConnection(const TaskManagerConnection&);
TaskManagerConnection& operator=(TaskManagerConnection&);
};
@@ -45,12 +45,6 @@ namespace CommandQueueNamespace
const bool cs_debug = false;
#endif
/**
* @brief used to assign sequence Ids to server-generated commands
* that need to be replicated on the client.
*/
const uint32 cs_sequenceStart = 0x40000000;
/**
* @brief the maximum number of combat commands that are allowed in
* the queue at any given time.
@@ -21,7 +21,7 @@ public:
void onReceive (const Archive::ByteStream & message);
private:
TaskManagerConnection(TaskManagerConnection&);
TaskManagerConnection(const TaskManagerConnection&);
TaskManagerConnection& operator=(TaskManagerConnection&);
};
@@ -124,14 +124,6 @@
namespace TangibleObjectNamespace
{
int const s_minCombatDuration = 4;
const int NUM_DAMAGE_TYPES = 9;
const int s_ignoreDamageTypes =
static_cast<int>(ServerArmorTemplate::DT_environmental_heat) |
static_cast<int>(ServerArmorTemplate::DT_environmental_cold) |
static_cast<int>(ServerArmorTemplate::DT_environmental_acid) |
static_cast<int>(ServerArmorTemplate::DT_environmental_electrical);
bool isEmpty(const ServerObject& obj)
{
const Container* container = obj.getContainerProperty();
@@ -30,8 +30,6 @@
namespace PathAutoGeneratorNamespace
{
char const * const s_pathWaypointTemplate = "object/path_waypoint/path_waypoint.iff";
char const * const s_pathObstacleTemplate = "object/resource_container/energy_solid_lg.iff";
}
using namespace PathAutoGeneratorNamespace;
@@ -2684,7 +2684,6 @@ namespace
// custom_var TypeId definitions
const jint CVT_UNKNOWN = static_cast<jint>(0);
const jint CVT_CONST_STRING = static_cast<jint>(1);
const jint CVT_RANGED_INT = static_cast<jint>(2);
const jint CVT_PALCOLOR = static_cast<jint>(3);
@@ -92,7 +92,6 @@ namespace ChatLogManagerNamespace
time_t s_purgeTime = 0;
int s_currentIndex = 0;
time_t s_chatLogMemoryTimer = 0;
time_t const s_chatLogMemoryTime = 30;
int s_cacheHits = 0;
int s_cacheMisses = 0;
@@ -33,80 +33,6 @@
#include <ctime>
//==============================================================================
// subclass Perforce API class ClientUser in order to trap errors
static const int SUBMIT_NO_FILE_ERR = 17; // need to add file before submitting
//class MyPerforceUser : public ClientUser
//{
//public:
// MyPerforceUser(void) : ClientUser(), m_errorOccurred(false) {}
// virtual ~MyPerforceUser() {}
// virtual void HandleError( Error *err )
// {
// if (err != nullptr && err->Test())
// {
// m_errorOccurred = true;
// m_lastError = err->GetGeneric();
// // test for filtered errors
// for (size_t i = 0; i < m_filteredErrors.size(); ++i)
// {
// if (m_lastError == m_filteredErrors[i])
// return;
// }
// }
// ClientUser::HandleError(err);
// }
//
// bool errorOccurred(void) const
// {
// return m_errorOccurred;
// }
//
// int getLastError(void) const
// {
// return m_lastError;
// }
//
// void clearLastError(void)
// {
// m_errorOccurred = false;
// m_lastError = 0;
// }
//
// void addFilteredError(int error)
// {
// m_filteredErrors.push_back(error);
// }
//
// void clearFilteredErrors(void)
// {
// m_filteredErrors.clear();
// }
//
//private:
// bool m_errorOccurred;
// int m_lastError;
// std::vector<int> m_filteredErrors;
//};
//==============================================================================
// subclass of the PerforceAPI StrBuf class, to workaround a bug
// in the destructor. We can't fix the bug because it's an external library
//class StrBufFixed : public StrBuf
//{
//public:
// ~StrBufFixed()
// {
// delete buffer;
// StringInit();
// }
//};
//==============================================================================
// functions
@@ -287,155 +213,6 @@ TpfFile templateFile;
return result;
} // verifyTemplate
/**
* Adds or removes parameters from a template based on the current template
* definition.
*
* @param filename the filename of the template
*
* @return 0 on success, error code on fail
*
int updateTemplate(const char *filename)
{
TpfFile templateFile;
Filename templateFileName(nullptr, nullptr, filename, TEMPLATE_EXTENSION);
return templateFile.updateTemplate(templateFileName);
} // updateTemplate
*/
/**
* Checks out a template file and the iff files associated with it from Perforce.
*
* @param filename the filename of the template
*
* @return 0 on success, error code on fail
*/
//int checkOut(const char *filename)
//{
//MyPerforceUser ui;
//ClientApi client;
//Error e;
//
// // check filename extensions
// Filename templateFileName(nullptr, nullptr, filename, TEMPLATE_EXTENSION);
// Filename iffFileName = templateFileName;
// iffFileName.setExtension(IFF_EXTENSION);
//
// // Connect to Perforce server
// client.Init( &e );
// if (e.Test())
// {
// StrBufFixed msg;
// e.Fmt(&msg);
// fprintf(stderr, msg.Text());
// return -1;
// }
//
// // check out the template file
// const char * commands[2];
// commands[0] = "edit";
// commands[1] = templateFileName;
// client.SetArgv( 1, const_cast<char **>(&commands[1]) );
// client.Run( commands[0], &ui );
// if (ui.errorOccurred())
// return -1;
//
// // find the client and server paths
// TpfFile templateFile;
// IGNORE_RETURN(templateFile.loadTemplate(templateFileName));
//
// // check out the client template iff file
// Filename iffName(nullptr, templateFile.getIffPath().c_str(), iffFileName, IFF_EXTENSION);
// commands[1] = iffName;
// client.SetArgv( 1, const_cast<char **>(&commands[1]) );
// client.Run( commands[0], &ui );
// if (ui.errorOccurred())
// return -1;
//
// // Close connection
// return client.Final( &e );
//} // checkOut
/**
* Checks in a template file and the iff files associated with it to Perforce.
*
* @param filename the filename of the template
*
* @return 0 on success, error code on fail
*/
//int checkIn(const char *filename)
//{
//MyPerforceUser ui;
//ClientApi client;
//Error e;
//
// // check filename extensions
// Filename templateFileName(nullptr, nullptr, filename, TEMPLATE_EXTENSION);
// Filename iffFileName = templateFileName;
// iffFileName.setExtension(IFF_EXTENSION);
//
// // find the client and server paths
// TpfFile templateFile;
// int result = templateFile.loadTemplate(templateFileName);
// if (result != 0)
// {
// // don't allow check-in if there are errors
// return result;
// }
//
// // Connect to Perforce server
// client.Init( &e );
// if (e.Test())
// {
// StrBufFixed msg;
// e.Fmt(&msg);
// fprintf(stderr, msg.Text());
// return -1;
// }
//
// // try to submit the files
// const char * commands[4];
// char param1[256];
// for (;;)
// {
// sprintf(param1, "//depot/.../%s.*", templateFileName.getName().c_str());
// commands[0] = "submit";
// commands[1] = param1;
//
// // don't report an error if the files need to be added before submitting
// ui.addFilteredError(SUBMIT_NO_FILE_ERR);
// client.SetArgv( 1, const_cast<char **>(&commands[1]) );
// client.Run( commands[0], &ui );
// if (!ui.errorOccurred())
// break;
// if (ui.getLastError() != SUBMIT_NO_FILE_ERR)
// return -1;
// ui.clearLastError();
// ui.clearFilteredErrors();
//
// // we need to add the files to Perforce before submitting
// commands[0] = "add";
//
// // add the template file
// commands[1] = templateFileName;
// client.SetArgv( 1, const_cast<char **>(&commands[1]) );
// client.Run( commands[0], &ui );
// if (ui.errorOccurred())
// return -1;
//
// // add the client iff file
// Filename iffName(nullptr, templateFile.getIffPath().c_str(), iffFileName, nullptr);
// commands[1] = iffName;
// client.SetArgv( 1, const_cast<char **>(&commands[1]) );
// client.Run( commands[0], &ui );
// if (ui.errorOccurred())
// return -1;
// }
//
// // Close connection
// return client.Final( &e );
//} // checkIn
/**
* Prints the command syntax to the console.
*/
@@ -444,13 +221,8 @@ void printSyntax(void)
printf("TemplateCompiler " __DATE__ " " __TIME__ "\n\n");
printf("Compiler commands:\n");
printf("-generate <defname>[.tdf] <templatename>[.tpf]\n");
// printf("-update <filename1>[.tpf] [<filename2>[.tpf] ...]\n");
// printf("-derive <basename>[.tpf] <derivedname>[.tpf]\n");
printf("-compile <filename1>[.tpf] [<filename2>[.tpf] ...]\n");
printf("-verify <filename1>[.tpf] [<filename2>[.tpf] ...]\n");
// printf("Perforce commands:\n");
// printf("-edit <filename1>[.tpf] [<filename2>[.tpf] ...]\n");
// printf("-submit <filename1>[.tpf] [<filename2>[.tpf] ...]\n");
} // printSyntax
/**
@@ -473,20 +245,6 @@ int processArgs(int argc, char *argv[ ])
}
return generateTemplate(argv[2], argv[3]);
}
// else if (strcmp(argv[1], "-update") == 0)
// {
// if (argc < 3)
// {
// printSyntax();
// return 0;
// }
// for (int i = 2; i < argc; ++i)
// {
// int result = updateTemplate(argv[i]);
// if (result != 0)
// return result;
// }
// }
else if (strcmp(argv[1], "-derive") == 0)
{
if (argc != 4)
@@ -542,34 +300,6 @@ int processArgs(int argc, char *argv[ ])
}
return result;
}
//else if (strcmp(argv[1], "-edit") == 0)
//{
// if (argc < 3)
// {
// printSyntax();
// return 0;
// }
// for (int i = 2; i < argc; ++i)
// {
// int result = checkOut(argv[i]);
// if (result != 0)
// return result;
// }
//}
//else if (strcmp(argv[1], "-submit") == 0)
//{
// if (argc < 3)
// {
// printSyntax();
// return 0;
// }
// for (int i = 2; i < argc; ++i)
// {
// int result = checkIn(argv[i]);
// if (result != 0)
// return result;
// }
//}
else
{
printSyntax();
@@ -30,7 +30,6 @@
namespace SpaceAvoidanceManagerNamespace
{
// Lag/Slop factors.
float const cs_lookAheadGain = 1.5f;
float const cs_shipBoundSphereRadiusGain = 1.5f;
// Dynamic and static query flags.
@@ -100,7 +100,7 @@ void SetupSharedFoundation::callbackWithExceptionHandling( void (*callback)(void
{
callback();
}
catch (__exception * mathException)
catch (const __exception * mathException)
{
FATAL(true, ("Math Exception: %s\n", mathException->name));
}
@@ -237,8 +237,6 @@ namespace SharedSaddleManagerNamespace
ConstCharCrcString const cs_defaultCoveringLogicalAppearanceName("lookup/mnt_wr_default_covering");
ConstCharCrcString const cs_saddleHardpointName("saddle");
char const * const cs_driverHardpointName = "player";
char const * const cs_passengerHardpointName = "passenger";
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
@@ -88,10 +88,6 @@ namespace TargaFormatNamespace
#pragma pack(pop)
#endif
const uint ms_attributeMask = BINARY2(0000,1111);
const uint ms_xOriginLocationMask = BINARY2(0001,0000);
const uint ms_yOriginLocationMask = BINARY2(0010,0000);
static bool _loadImage(AbstractFile *, Image **image, Image::PixelFormat format=Image::PF_nonStandard);
static void _readUncompressedColorMapped1(
@@ -140,7 +140,7 @@ private:
void load_0005(const PortalPropertyTemplate &portalPropertyTemplate, int cellIndex, Iff &iff);
// disabled
PortalPropertyTemplateCell(PortalPropertyTemplateCell &);
PortalPropertyTemplateCell(const PortalPropertyTemplateCell &);
PortalPropertyTemplateCell &operator =(PortalPropertyTemplateCell &);
private:
@@ -22,13 +22,13 @@
const char WIN32_PATH_SEPARATOR = '\\';
const char LINUX_PATH_SEPARATOR = '/';
//#if defined(WIN32)
//const char PATH_SEPARATOR = WIN32_PATH_SEPARATOR;
//#elif defined(linux)
#if defined(WIN32)
const char PATH_SEPARATOR = WIN32_PATH_SEPARATOR;
#elif defined(linux)
const char PATH_SEPARATOR = LINUX_PATH_SEPARATOR;
//#else
//#error unknown OS
//#endif
#else
#error unknown OS
#endif
/**
@@ -176,36 +176,6 @@ static const char * const DefaultDataReturnValue[] =
"DefaultString"
};
// map enum ParamType to string equivalent
static const char * const EnumTypeNames[] =
{
"TYPE_NONE",
"TYPE_COMMENT",
"TYPE_INTEGER",
"TYPE_FLOAT",
"TYPE_BOOL",
"TYPE_STRING",
"TYPE_STRINGID",
"TYPE_VECTOR",
"TYPE_DYNAMIC_VAR",
"TYPE_TEMPLATE",
"TYPE_ENUM",
"TYPE_STRUCT",
"TYPE_TRIGGER_VOLUME",
"TYPE_FILENAME",
"NUM_PARAM_TYPES"
};
// map enum TemplateLocation to string equivalent
static const char * const EnumLocationNames[] =
{
"LOC_NONE",
"LOC_CLIENT",
"LOC_SERVER",
"LOC_SHARED"
};
//==============================================================================
// class methods
+1 -1
View File
@@ -16,7 +16,7 @@ namespace Base
mMutex->Lock();
}
CScopeLock::CScopeLock(CScopeLock& lock) :
CScopeLock::CScopeLock(const CScopeLock& lock) :
mMutex(lock.mMutex)
{
mMutex->Lock();
+1 -1
View File
@@ -24,7 +24,7 @@ namespace Base
{
public:
CScopeLock(CMutex& mutex);
CScopeLock(CScopeLock& lock);
CScopeLock(const CScopeLock& lock);
virtual ~CScopeLock();
private:
CMutex *mMutex;
@@ -16,7 +16,7 @@ namespace Base
mMutex->Lock();
}
CScopeLock::CScopeLock(CScopeLock& lock) :
CScopeLock::CScopeLock(const CScopeLock& lock) :
mMutex(lock.mMutex)
{
mMutex->Lock();
@@ -24,7 +24,7 @@ namespace Base
{
public:
CScopeLock(CMutex& mutex);
CScopeLock(CScopeLock& lock);
CScopeLock(const CScopeLock& lock);
virtual ~CScopeLock();
private:
@@ -16,7 +16,7 @@ namespace Base
mMutex->Lock();
}
CScopeLock::CScopeLock(CScopeLock& lock) :
CScopeLock::CScopeLock(const CScopeLock& lock) :
mMutex(lock.mMutex)
{
mMutex->Lock();
@@ -24,7 +24,7 @@ namespace Base
{
public:
CScopeLock(CMutex& mutex);
CScopeLock(CScopeLock& lock);
CScopeLock(const CScopeLock& lock);
virtual ~CScopeLock();
private:
@@ -30,7 +30,6 @@ namespace ObjectTableBufferNamespace
{
static const int s_numPositions = 20;
static const int s_positionMasks[20] = {1,2,4,8,16,32,64,128,256,512,1024,2048,4096,8192,16384,32768,65536,131072,262144,524288};
static const int s_allPositionsSet = 1048575;
}
using namespace ObjectTableBufferNamespace;